GNU bug report logs -
#53126
29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc.
Previous Next
Reported by: Augusto Stoffel <arstoffel <at> gmail.com>
Date: Sat, 8 Jan 2022 13:25:01 UTC
Severity: normal
Tags: patch
Merged with 53341
Fixed in version 29.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #52 received at 53126 <at> debbugs.gnu.org (full text, mbox):
>>> @@ -2350,7 +2352,9 @@ isearch-query-replace
>>> + (let ((lazy-highlight-cleanup (and lazy-highlight-cleanup
>>> + (not query-replace-lazy-highlight))))
>>> + (isearch-done nil t))
>>
>> Is this some optimization? It seems it's intended to leave
>> some existing highlighting? Is this to avoid double highlighting?
>
> The weird let-binding for lazy-highlight-cleanup is indeed an
> optimization. Without it, you can see the lazy highlights briefly flash
> off an on again after you hit RET to confirm the replacement string.
>
> (Same remark explains why condition-case is used instead of a
> unwind-protect in query-replace-read-args).
When I tried your latest patch, it still flashes when it starts
the perform-replace loop.
>> The problem is that when these conditions 'isearch-mode (null isearch-message-function)'
>> are removed, now this shows wrong counts in the minibuffer history search
>> (e.g. 'M-! C-r s C-r C-r ...') and the shell history search
>> (e.g. 'M-x shell RET M-r s C-r C-r ...'). Before this change
>> counting was disabled in the history search because it shows wrong numbers.
>
> Okay, so this means we should bind isearch-lazy-count to nil in these
> commands, do you agree? It has always looked like a hack to me to check
> for (null isearch-message-function).
Binding isearch-lazy-count to nil could serve as a temporary measure
until lazy-count will be supported in the history search.
>> For some reasons the package lisp/mb-depth.el uses 'after-string'
>> instead of 'before-string', and (make-overlay (point-min) (1+ (point-min)))
>> instead of (make-overlay (point-min) (point-min)),
>> so maybe better to do the same?
>
> Okay, but do you know the reasons? I've changed to before-string, but I
> don't like to make the overlay 1 char longer than it has to be :-P
I don't know the reason. Since it works in your patch, then it's ok.
>> Highlighting is still incorrect for word replacement ('C-u M-%')
>> and for non-nil 'replace-char-fold'. To handle these cases correctly,
>> 'replace-highlight' uses:
>>
>> (isearch-regexp-function (or replace-regexp-function
>> delimited-flag
>> (and replace-char-fold
>> (not regexp-flag)
>> #'char-fold-to-regexp)))
>
> Okay, fixed this. (BTW, where is replace-regexp-function used? It's
> not set anywhere in Emacs, and it's not a defcustom either.)
'replace-regexp-function' was added recently in bug#52558
to allow implementing more regexp types in bug#54017.
This bug report was last modified 3 years and 39 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.