help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: search-backward returning matches which end after point


From: Spencer Baugh
Subject: Re: search-backward returning matches which end after point
Date: Mon, 26 Aug 2024 10:26:13 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

Stefan Monnier via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

>> search-backward (and re-search-backward, and looking-back) don't return
>> matches which end after point.  Is there a version which does?
>
> No 🙁
> You could write a `while + looking-at` loop to do that, but if you want
> something faster, you'll need to change the C code.
> I don't expect it would be a difficult change, tho (it should not require
> any significant change in the regexp engine, for example).

I'm happy to do that, if this is an addition which is likely to be
accepted into Emacs.

Should the API be a new flag in
search-backward/re-search-backward/looking-back?  Or should it maybe be
a new special variable?

>> 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.
>
> Of course, the same problem appears for search-forward when searching
> from within the thing we're searching.  In both cases the usual
> workaround is to start your search elsewhere (i.e. take "small" step
> back before searching forward or vice-versa).

Yes, that seems to be a common workaround.  Particularly common seems to
be going to pos-bol first, since the search is for something which can't
contain a newline.

In my case this is tricky though because the thing I'm searching for
*can* contain a newline, so it's not totally trivial to determin what
small step is correct to take...




reply via email to

[Prev in Thread] Current Thread [Next in Thread]