From: Spencer Baugh <sbaugh@janestreet.com>
To: help-gnu-emacs@gnu.org
Subject: search-backward returning matches which end after point
Date: Fri, 23 Aug 2024 10:18:14 -0400 [thread overview]
Message-ID: <ierjzg7b9w9.fsf@janestreet.com> (raw)
search-backward (and re-search-backward, and looking-back) don't return
matches which end after point. Is there a version which does?
For example,
(with-temp-buffer
(insert "foo")
(save-excursion (insert "bar"))
(search-backward "foobar"))
fails to find the match.
Is there a function which will find this match?
Specifically, I noticed this when trying to use
easy-mmode-define-navigation to define navigation commands for a major
mode based on a regex.
The -prev commands defined by easy-mmode-define-navigation use
re-search-backward. So if the point is inside the thing which the regex
matches, then thing-prev command will not go to the start of the thing.
But if point is after the thing, then thing-prev will go to the start of
the thing. This is because of this behavior of search-backward.
I'd like to instead define movement commands which will always go to the
start of the thing when point is inside the thing. But to do that for
an arbitrary regex/string, I need a version of search-backward which
will return matches which end after point.
next reply other threads:[~2024-08-23 14:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 14:18 Spencer Baugh [this message]
2024-08-24 15:20 ` search-backward returning matches which end after point Stefan Monnier via Users list for the GNU Emacs text editor
2024-08-26 14:26 ` Spencer Baugh
2024-08-26 16:54 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-08-28 13:45 ` Spencer Baugh via Users list for the GNU Emacs text editor
2024-08-29 1:24 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-08-26 18:27 ` Andreas Röhler
2024-08-26 19:37 ` Stefan Monnier via Users list for the GNU Emacs text editor
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=ierjzg7b9w9.fsf@janestreet.com \
--to=sbaugh@janestreet.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).