I know, Emacs allows calling ELisp while replacing a text with a regex, aka C-M-%
, which is bound to query-replace-regexp
. I'm trying to make use of that to store an unwieldy regexp as a variable, so instead of writing it out every time, I could just extract it from a variable.
For the sake of simplification, in the testcase here I'm using just a text, so no backslashes are involved:
(setq foo "text")
Text is:
text text
Here's what I tried as the REGEXP in query-replace-regexp
:
\,foo
\,'foo
\,(eval 'foo)
\,(eval foo)
None of those work for me. How can I make it work?