[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-repl
From: |
Juri Linkov |
Subject: |
bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc. |
Date: |
Tue, 15 Mar 2022 19:09:49 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) |
> Inlined below some further comments.
>
>>>> 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.
> ...
> - In a previous message, you seemed to suggest making
> `minibuffer-lazy-highlight-setup' self-cleaning form the
> minibuffer-setup-hook, so as to dispense with the need for
> `with-minibuffer-setup-hook'. I did exactly that, but since I haven't
> seen this convention before, I wanted to double check.
Actually, my comment was about having the line that you already added
in your latest patch in 'minibuffer-lazy-highlight-setup':
(add-hook 'lazy-count-update-hook #'minibuffer-lazy-highlight--count)
So I don't see the need to have this line:
(remove-hook 'minibuffer-setup-hook #'minibuffer-lazy-highlight-setup)
Also I noticed that you changed the function
'isearch-lazy-count-display-function'
to the hook 'lazy-count-update-hook', and this looks fine,
I see no problem with this.
> - Besides query-replace, I only added lazy highlight to
> isearch-edit-string for now.
BTW, what is the relation between the minibuffer-lazy-highlight feature
and another proposed feature that immediately updates the search in
the buffer while editing the string in the minibuffer by isearch-edit-string?
Can minibuffer-lazy-highlight be considered as a lightweight version of
the buffer search from the minibuffer?
> There are a few more we could add (perhaps later),
> such as `occur' and `keep-lines'.
I tried (add-hook 'minibuffer-setup-hook #'minibuffer-lazy-highlight-setup)
in the minibuffer of 'occur' and others, and it works nicely.
Maybe it could even semi-deprecate the package re-builder.el.
Thanks for this generally usable feature.
> - There's no customization variable to enable the minibuffer lazy
> highlight. The rationale is that each command that will use it should
> define its own user option (or use an existing one). For
> `isearch-edit-string' it's `isearch-lazy-highlight'; for
> `query-replace' it's `query-replace-lazy-highlight'; and so on.
A common customizable option to enable this everywhere would be nice too.
Maybe disabling is already possible by customizing
'minibuffer-lazy-count-format' to nil? Then the checks for
non-nil 'minibuffer-lazy-count-format' could be added to
more places, such as to wrap the whole '(condition-case error'
in query-replace-read-args with the 'when' condition, etc.
> - As to the lazy count during `perform-replace': I would like to leave
> this for later. In fact, I think the lazy highlight has some issues
> that need fixing beforehand. For instance, if I replace "a" with
> "aba", then the "a"'s from the replacement text also get lazy
> highlighted. We shouldn't refresh the lazy highlight during
> `preform-replace'. Then adding lazy count on top should be easy.
Patches welcome.
>>> 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.
Counting without highlighting is only possible by redefining the function
'isearch-lazy-highlight-match' to a no-op function.
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc.,
Juri Linkov <=
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc., Augusto Stoffel, 2022/03/15
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc., Juri Linkov, 2022/03/16
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc., Augusto Stoffel, 2022/03/16
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc., Juri Linkov, 2022/03/17
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc., Augusto Stoffel, 2022/03/17
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc., Juri Linkov, 2022/03/17
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc., Augusto Stoffel, 2022/03/17
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc., Augusto Stoffel, 2022/03/20
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc., Juri Linkov, 2022/03/20
- bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc., Augusto Stoffel, 2022/03/24