[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
search-backward returning matches which end after point
From: |
Spencer Baugh |
Subject: |
search-backward returning matches which end after point |
Date: |
Fri, 23 Aug 2024 10:18:14 -0400 |
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.
- search-backward returning matches which end after point,
Spencer Baugh <=
Re: search-backward returning matches which end after point, Andreas Röhler, 2024/08/26