bug-gnu-emacs
[Top][All Lists]
Advanced

[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: Wed, 16 Mar 2022 20:56:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

>> So I don't see the need to have this line:
>>
>>   (remove-hook 'minibuffer-setup-hook #'minibuffer-lazy-highlight-setup)
>
> Okay, but if I remove this line, then all calls to
> minibuffer-lazy-highlight-setup will require a with-minibuffer-setup
> hook.  And this will be awkward:
>
>      (minibuffer-with-setup-hook (if isearch-lazy-highlight
>                                       #'minibuffer-lazy-highlight-setup
>                                     #'ignore)
>          (read-from-minibuffer "Something: "))

The answer depends on another question: how do you intend the users
would enable this feature?  When to enable it in all minibuffers
(like e.g. minibuffer-depth-indicate-mode does) the users will add
to their init files:

  (add-hook 'minibuffer-setup-hook #'minibuffer-lazy-highlight-setup)

Then removing the user's customization would not be a nice thing to do.
OTOH, minibuffer-with-setup-hook will remove only own hook, not the user's one.
So to allow enabling this feature selectively, minibuffer-with-setup-hook
is not quite awkward.

>> 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?
>
> Well, there's a package for that on ELPA (isearch-mb), so extending
> isearch-edit-string to do that seems superfluous now?

It's still possible to add this feature to isearch-edit-string,
when the change would not be too enormous.  I recall squeezing
it into a small patch, but unfortunately it requires changes
in keymap priorities.

>>> 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.
>
> By the way, this is a byproduct of that long discussion that led to
> isearch-mb, so it was not all in vain :-).

Are you sure these features can't be combined?  One feature basically
runs isearch-search-and-update in the buffer from the minibuffer,
and this feature runs isearch-lazy-highlight-new-loop.

>>> - 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.
>
> Yes, the user can set minibuffer-lazy-count-format to nil to get rid of
> the lazy count.
>
> Concerning query-replace, why would anyone want to have lazy highlight
> during the perform-replace loop, but not earlier?  I'm not a fan of
> adding a custom option here, not because it would be hard, but because
> it seems totally unnecessary.

Maybe a new option would make sense for the same reason why there is
the option isearch-lazy-count?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]