all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Isearch: add variable to control search match group
@ 2015-08-24 23:55 Alexander Shukaev
  2015-08-25 14:45 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Shukaev @ 2015-08-24 23:55 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-25 22:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24 23:55 Isearch: add variable to control search match group Alexander Shukaev
2015-08-25 14:45 ` Stefan Monnier
2015-08-25 15:06   ` Alexander Shukaev
2015-08-25 22:08     ` Stefan Monnier

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.