help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to yank a regexp in isearch-mode?


From: Zhang Haijun
Subject: Re: How to yank a regexp in isearch-mode?
Date: Mon, 12 Nov 2018 10:43:01 +0000


On 11/12/2018 01:13 AM, Drew Adams wrote:
>>> `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).
> 
>>> If 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 `\^\\\*\.\*'.
>>>
>>> Isearch+:
>>>
>>> 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.
> 

OK. Thank you for your advice.I will try it.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]