On Mon, 10 Jan 2022 at 21:09, Juri Linkov 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.