From: Alexander Shukaev <haroogan@gmail.com>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Isearch: add variable to control search match group
Date: Tue, 25 Aug 2015 01:55:12 +0200 [thread overview]
Message-ID: <CAKu-7WxshjUw1DiTn3kXnFTktZiKYNHCdTAVnF5JRa1mPLjgYg@mail.gmail.com> (raw)
Hello,
would it be reasonable to add
(defcustom isearch-regexp-group 0
"Number used to match concrete group in search pattern."
:group 'isearch
:type 'number)
and substitute all the calls to `(match-beginning 0)' and `(match-end
0)' with `(match-beginning (or isearch-regexp-group 0))' and
`(match-end (or isearch-regexp-group 0))' accordingly in 'isearch.el'?
For instance, I develop my own search module on top of Isearch
currently, and I really have problem with the fact that the choice of
group 0 is hard-coded in Isearch. Let me give you a simple example,
where this makes things stiff. Note, though, that the following
example (and the corresponding change above) are meant for
programmatic use of Isearch in the first place (rather than
interactive one). Imagine that my search module wants to search for
\(^\|\s-+?\)(;;)\($\|\s-+?\)
and I am actually only interested in the "(;;)" part since I also want
to highlight it (with both, current match highlighting and all matches
lazy highlighting). Then, clearly, "\(^\|\s-+?\)" and "\($\|\s-+?\)"
are just anchors. Also, note that I deliberately chosen non-word
constituent to prevent any speculations on the usage of "\<" and "\>"
for this example. Now, since Emacs does not have Vim-like "\zs" and
"\ze" to control beginning and end of match respectively on the one
hand, and does not have something like (hypothetical, but very welcome
too) "\sb", which would essentially stand for "space boundary" (i.e.
do for spaces what "\<" and "\>" do for words) on the other hand (in
which case I would simply transform the original search RE into
\(^\|\sb\)(;;)\($\|\sb\)
and be done with it), I have no choice, but to use something like this
\(^\|\s-+?\)\(?1:(;;)\)\($\|\s-+?\)
and then extract exactly the 1st group from it. Unfortunately,
Isearch internally does not support that at all. Will it be possible
to follow my suggestion and/or maybe somebody has better ideas?
Regards,
Alexander
next reply other threads:[~2015-08-24 23:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 23:55 Alexander Shukaev [this message]
2015-08-25 14:45 ` Isearch: add variable to control search match group Stefan Monnier
2015-08-25 15:06 ` Alexander Shukaev
2015-08-25 22:08 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKu-7WxshjUw1DiTn3kXnFTktZiKYNHCdTAVnF5JRa1mPLjgYg@mail.gmail.com \
--to=haroogan@gmail.com \
--cc=emacs-devel@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.