I'm trying to create my first macro. I often change the background color of the query-replace matched string in my script. I usually do:
(let* ((face 'query-replace) (bg (face-background face))) (unwind-protect (progn (set-face-background face "gold") (perform-replace "^%+\n" "" t t nil 1 nil (point-min) (point-max))) (set-face-background face bg)))
Now I'd like to have a macro to do that. Something like:
(with-query-replace-color "gold" (perform-replace "^%+\n" "" t t nil 1 nil (point-min) (point-max)))
I tried with:
(defmacro with-query-replace-color (COLOR &rest body) "Change bg color in `perform-replace'..." (declare (indent 1)) (let* ((face 'query-replace) (bg (face-background face))) `(unwind-protect (progn (set-face-background ,face ,COLOR) ,@body) (set-face-background ,face ,bg))))
Symbol’s value as variable is void: query-replace.
What am I doing wrong?
Should I use a function instead?
(&rest body)as argument. I thought it was non possible. Isn't so?
facevariable, just write
'query-replacein the macro body).