Post by Drew Adams`isearch-yank-string' can yank a regexp string as well.
But it escape the string if isearch-regexp is not nil.
Yes. That's why Isearch+ adds `isearchp-regexp-quote-yank-flag'
(and a key to toggle that during Isearch): to give you a choice
(control).
Post by Drew AdamsIf you use Isearch+ then you have option
`isearchp-regexp-quote-yank-flag':...
With this escaping turned off, you can yank text such
as `^\*.*' without it being transformed to `\^\\\*\.\*'.
https://www.emacswiki.org/emacs/IsearchPlus
I see it. It is a big package. It is too big for my use case. I just
want to yank a regexp.
It's not very big, if you remove the Commentary. But
yes, it's purpose is not just to let you yank regexp.
If you don't want to use Isearch+ then just advise or
redefine `isearch-yank-string', like Isearch+ does.
It's trivial to do. E.g., change this:
(if isearch-regexp (setq string (regexp-quote string)))
to this:
(when (and isearch-regexp your-variable)
(setq string (regexp-quote string)))
Or define a separate command that yanks without doing
`regexp-quote' - same defun but without that line
(if regexp-quote...). And bind that command to a different
key.
IOW, either use a variable with two values (and maybe a
toggle command) or two different keys. Pretty simple.