[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#54733: Match again in perform-replace
From: |
Juri Linkov |
Subject: |
bug#54733: Match again in perform-replace |
Date: |
Wed, 22 Jun 2022 10:36:39 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) |
>>> + (replace-search search-string limit
>>> + regexp-flag delimited-flag
>>> + case-fold-search backward))
>>
>> I don't know this code too well, but perhaps SEARCH_STRING here should be
>> anchored with something like "\\=" at the beginning?
>>
>> Otherwise the search can succeed here even if the next match is not
>> here. Not sure how important that is, though.
>
> I'm afraid that prepending "\\=" might break a complex regexp somehow.
Another variant without modifying the original regexp is still to call
replace-search, but afterwards check if it stayed at the old position
with something like
(let ((old-pos (point)))
(and (replace-search ...)
(eq (match-beginning 0) old-pos)))
Less efficient, but looking-at is a real problem since it's incompatible
with search functions. This is one of the problems faced in bug#14013
where isearch matches `C-M-r ^' outside of positions handled by the
search function because `isearch-search-and-update' uses a hack with
looking-at. This is a long-standing flaw in isearch that needs to be fixed.
Any uses of looking-at in search/replace should be substituted
with an equivalent code that relies on the search function.