Subject: 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 22:43:20 +0200

> On Thu, 17 Mar 2022 at 19:05, Juri Linkov <[email-masked]> wrote:
>
>>>> 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.
>
> Interesting, I can't see thing flash at that particular place.  But I've
> replaced the unwind-protect by a more fine-grained condition-case.  Let
> me know if it helps.
>
>> 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?
>
> The only refactoring opportunity I see it to define
>
>     (defun replace-regexp-function (delimited-flag)
>       (or replace-regexp-function
>           delimited-flag
>           (and replace-char-fold
>                (not regexp-flag)
>                #'char-fold-to-regexp)))
>
> which can be used in 3 places.  Should I do that?
>
> Otherwise, I dont' see much room for improvement.  There are a lot of
> moving parts there, so to me things already turned out surprisingly
> short.

I meant a function that translates arguments of query-replace/perform-replace
to search parameters.  They are currently used in replace-search and
replace-highlight.  But maybe could be reused by query-replace-read-args?