From: Drew Adams <drew.adams@oracle.com>
To: Zhang Haijun <ccsmile2008@outlook.com>
Cc: help-gnu-emacs@gnu.org
Subject: RE: How to yank a regexp in isearch-mode?
Date: Sun, 11 Nov 2018 09:13:59 -0800 (PST) [thread overview]
Message-ID: <3aa3f0c4-363e-4f4b-b368-0c81690db1d6@default> (raw)
In-Reply-To: <C911266F-D49A-4164-ABAF-BF84D9C2C8F9@outlook.com>
> > `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.
next prev parent reply other threads:[~2018-11-11 17:13 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 [this message]
2018-11-12 10:43 ` Zhang Haijun
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=3aa3f0c4-363e-4f4b-b368-0c81690db1d6@default \
--to=drew.adams@oracle.com \
--cc=ccsmile2008@outlook.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).