Subject: Re: bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc.

From: Juri Linkov <[email-masked]>
Date: Thu, 17 Mar 2022 19:05:34 +0200

>> When I tried your latest patch, it still flashes when it starts
>> the perform-replace loop.
>
> Does it always happen for you?  I see this occasionally, and as far as I
> can tell it's random.

It happens every time when starting perform-replace from isearch.

>>>> 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.
>
> Ah, I see.  I must say, in isearch.el I don't like this trichotomy of
> the regexp/literal/with isearch-regexp-function cases.  Ideally, the
> regexp and literal search cases would be handled by
> isearch-regexp-function set to identity respectively regexp-quote.  But
> it would be a large refactoring, perhaps with only aesthetic benefits.

Yep, too much changes for little benefit.

The biggest hunk in your patch are changes in query-replace-read-args
starting from 'condition-case error'.  Would it be possible to simplify
this part?  Maybe by some refactoring?

OTOH, your changes that add lazy-count-update-hook and remove
'(null isearch-message-function)' can be already pushed.
Could you please send a separate patch for pushing with these changes only?

Then the patch with minibuffer-lazy-count feature will be shorter.