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

From: Augusto Stoffel <[email-masked]>
Date: Thu, 17 Mar 2022 20:45:57 +0100

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.