unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Zhang Haijun <ccsmile2008@outlook.com>
To: Drew Adams <drew.adams@oracle.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: How to yank a regexp in isearch-mode?
Date: Mon, 12 Nov 2018 10:43:01 +0000	[thread overview]
Message-ID: <SG2PR0601MB14054B531DEFE65E0E2446DAA8C10@SG2PR0601MB1405.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <3aa3f0c4-363e-4f4b-b368-0c81690db1d6@default>



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	other threads:[~2018-11-12 10:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-11  0:46 How to yank a regexp in isearch-mode? Zhang Haijun
2018-11-11  2:22 ` Drew Adams
     [not found]   ` <C911266F-D49A-4164-ABAF-BF84D9C2C8F9@outlook.com>
2018-11-11 17:13     ` Drew Adams
2018-11-12 10:43       ` Zhang Haijun [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SG2PR0601MB14054B531DEFE65E0E2446DAA8C10@SG2PR0601MB1405.apcprd06.prod.outlook.com \
    --to=ccsmile2008@outlook.com \
    --cc=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).