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
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Hi Juri,
Sorry for getting back to this after such a long time. I've attached a
new patch that hopefully is good to merge, except for adding some NEWS
entry. Let me know what you think.
Inlined below some further comments.
[0001-Display-lazy-highlight-and-match-count-in-when-readi.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
On Mon, 10 Jan 2022 at 21:09, Juri Linkov <juri <at> linkov.net> wrote:
>> I attached a new patch (still a sketch) that requires no changes in
>> comint.el and simple.el. Perhaps you will find this approach more
>> acceptable.
>
> Thanks, no changes in other files is certainly a big plus.
>
>>> It would be great to use your new variable with a function
>>> to show replacement counts in perform-replace. IIUC,
>>> let-binding isearch-lazy-count-display-function to
>>> isearch-read-with-highlight-count will suppress isearch-message?
>>
>> I tried this and it's relatively simple to do, but there is a problem.
>> Suppose you want to replace all "a" with "z", and your buffer has 20
>> "a"s initially. Then, as you keep hitting "y" to confirm a replacement
>> the count will be
>>
>> 1/20, 1/19, ..., 1/1
>
> This is an interesting question. I tried in other editors,
> and e.g. in the editor xed that is installed by default,
> this is exactly what is displayed: 1/20, 1/19, ..., 1/1.
Let's do this at a later point, to keep this patch smaller and more
focused.
Note that there is one further fancy feature from anzu that we could add
eventually, namely the preview of the replacement text during replace.
This was requested in some recent bug. I think it's not so often that
such a thing would be useful, but it can be very handy occasionally.
>> since the number of "a"s decrease, and the point is always at the first
>> of the still-existing ones. But probably one should count the number of
>> prompts, so
>>
>> 1/20, 2/20, ..., 20/20
>>
>> I think this means `perform-replace' has to implement its own way to
>> display a count.
>
> Maybe this makes more sense, when the users will learn
> what do these numbers mean.
>
>>> I meant using simply
>>>
>>> (add-hook 'minibuffer-setup-hook 'isearch-read-with-highlight-setup)
>>>
>>> But it seems isearch-read-with-highlight-setup doesn't set
>>> isearch-lazy-count-display-function.
What used to be 'isearch-read-with-highlight-setup' is now
'minibuffer-lazy-highlight-setup'.
Just to make sure I understood you: your suggestion is for this function
to remove itself automagically from the minibuffer setup hook, to
dispense with the need of 'minibuffer-with-setup-hook'? This seems
handy but unusual, hence my question.
>> I guess this could be done.
>
> Maybe two separate hooks could be defined? One highlights like
> lazy-highlight, and another counts like lazy-count does:
>
> (add-hook 'minibuffer-setup-hook 'isearch-read-with-highlight-setup)
> (add-hook 'minibuffer-setup-hook 'isearch-read-with-count-setup)
The highlight without counting can be achieved by binding a suitable new
variable. Counting without highlight is not supported by isearch AFAIU.
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.