If I modify the isearch-filter-predicate variable with add-function and I do:

(message "%s" isearch-filter-predicate)

I get:

"#[128 \304\300"\205\0\304\301"\207 [skip-comments isearch-filter-visible :before-while nil apply] 4 advice]"

But if I do M-x descrive-function RET isearch-filter-predicate RET I get the variable in this format:

Its value is
#f(advice skip-comments :before-while isearch-filter-visible)

I searched for a function to format the printed value of the variables in the help-fns.el file, where describe-variable is defined and, of course, I made a search on the web but I didn't find such a function.

Is there a way to achieve this kind of format using an existing function?

Edit. I'm building a function that allows me to temporarily modify isearch-filter-predicate. To do this, I'm doing something like this:

(defvar-local typ-isearch-filter-predicates-list '()
  "List of predicates usable through the `with-temp-isearch-filter-predicate' function.")

(add-to-list 'typ-isearch-filter-predicates-list 'skip-comments)

(defun with-temp-isearch-filter-predicate ()
  "Temporarily assigns a series of predicates to the variable
`isearch-filter-predicate' to make only portions of the buffer
that match specific criteria visible/invisible to search and
replace functions."
  (let* ((isearch-filter-predicate isearch-filter-predicate)
         (IFP-DEFAULT isearch-filter-predicate)
         (DEFAULT "skip-comments")

         ;; See: https://emacs.stackexchange.com/q/80307/15606
         (set-message-function nil)

         (PREDICATES (completing-read-multiple
                      "Specify, separating by commas, which predicates you want to activate: "

         (enable-recursive-minibuffers t))

    (dolist (predicate PREDICATES)
      (add-function :before-while isearch-filter-predicate (intern-soft predicate)))

      "The value assigned to the variable `isearch-filter-predicate' is currently `%s'.
Press ENTER to restore the default value [%s] at the end of the operations:"
  • Please show your code. I guess you're doing something like this: (add-function :before-while isearch-filter-predicate '((name . skip-comments))). But whatever it is, please show it.
    – Drew
    Mar 11 at 0:17
  • @Drew done. Since I use let binding I don't use '((name . skip-comments)).
    – Gabriele
    Mar 11 at 10:40

1 Answer 1


After searching more thoroughly in help-fns.el, I found the function I was looking for: cl-prin1-to-string.

In my code I can do:

 "The value assigned to the variable `isearch-filter-predicate' is currently `%s'.
Press ENTER to restore the default value [%s] at the end of the operations:"
 (cl-prin1-to-string isearch-filter-predicate)
  • 1
    To make the answer more helpful, maybe be a bit more explicit, showing use of that function with message, to get the result you want.
    – Drew
    Mar 11 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.