From: Augusto Stoffel <arstoffel@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: 53126@debbugs.gnu.org
Subject: bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc.
Date: Thu, 17 Mar 2022 20:10:34 +0100 [thread overview]
Message-ID: <87sfrgz979.fsf@gmail.com> (raw)
In-Reply-To: <86mtho5y56.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 17 Mar 2022 19:09:13 +0200")
On Thu, 17 Mar 2022 at 19:09, Juri Linkov <juri@linkov.net> wrote:
>> My idea is:
>>
>> - The users of the feature are Elisp programmers / package authors.
>> - I don't think end users can meaningfully do anything directly with
>> this new minibuffer hook.
>> - If package X wants to take advantage of the feature, then it will
>> either add minibuffer-lazy-highlight-setup to the
>> minibuffer-setup-hook unconditionally, or it will define an
>> X-lazy-highlight customization option to control this.
>>
>> So I think the conclusion is that the current approach in my patch is an
>> good way to proceed here?
>
> So do you think end users should not be able to decide where they want
> to use this feature? For example, if one user will want it for 'occur',
> but another user doesn't want it in the 'occur' regexp-reading minibuffer,
> they should have no choice?
Of course there should an option, maybe occur-lazy-highlight. This is
why isearch.el itself should _not_ contain a customization option called
`minibuffer-lazy-highlight': each use (or group of uses) of this
functionality should define their own customization option.
>>>>> 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.
>>
>> I would suggest taking a look at isearch-mb. I think the code is pretty
>> tight, and I would be unable to shorten the implementation other than by
>> deleting comment :-)
>
> I already looked at isearch-mb. Adding the same to isearch.el
> will take only 52 lines.
Okay, I can give my opinion about these changes if you wish.
>>>>>> 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.
>>
>> For one thing, isearch-mode has 2 essential commands (repeat forward and
>> backwards), a couple more necessary ones (quit, abort, scroll,
>> beginning/end of buffer, mode toggles), and then a number of commands
>> that end the search with a special action (query-replace, etc.).
>>
>> These little details add up to the 283 lines in isearch-mb.el currently
>> has.
>
> I wonder how this is affected by scroll, beginning/end of buffer, mode toggles?
> These commands don't use the minibuffer.
I probably misunderstood you then. I thought you wanted to allow C-s
and C-r in isearch-edit-string to go back and forth in the search
buffer, but apparently this is not the case. (Then I need to see your
52-line patch to understand what exactly you mean...)
>>>>>> - 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?
>>
>> Okay, I'm not against this, but let's think about the names of these user
>> options. The existing option is named query-replace-lazy-highlight,
>> which seems to exactly describe the new feature. The existing feature
>> would more specifically be called perform-replace-lazy highlight.
>
> Do you mean lazy-highlight in the minibuffer that reads a string to replace?
> Then it could be named query-replace-read-lazy-highlight.
I personally find it a bit unnecessary to have separate options for
query-replace-read-lazy-highlight and query-replace-lazy-highlight. Of
course it's nice to have fine-grained control, but at some point it just
becomes too difficult to configure things. But I don't mind adding it.
next prev parent reply other threads:[~2022-03-17 19:10 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-08 13:24 bug#53126: 29.0.50; [PATCH] Lazy highlight/count when reading query-replace string, etc Augusto Stoffel
2022-01-08 18:59 ` Juri Linkov
2022-01-08 19:35 ` Augusto Stoffel
2022-01-09 9:10 ` Juri Linkov
2022-01-09 10:02 ` Augusto Stoffel
2022-01-09 10:30 ` Augusto Stoffel
2022-01-09 18:58 ` Juri Linkov
2022-01-10 17:34 ` Augusto Stoffel
2022-01-10 19:09 ` Juri Linkov
2022-02-26 16:13 ` Augusto Stoffel
2022-03-15 17:09 ` Juri Linkov
2022-03-15 21:33 ` Augusto Stoffel
2022-03-16 18:56 ` Juri Linkov
2022-03-16 20:09 ` Augusto Stoffel
2022-03-17 17:09 ` Juri Linkov
2022-03-17 19:10 ` Augusto Stoffel [this message]
2022-03-17 20:40 ` Juri Linkov
2022-03-17 21:42 ` Augusto Stoffel
2022-03-20 9:38 ` Augusto Stoffel
2022-03-20 18:51 ` Juri Linkov
2022-03-24 19:03 ` Augusto Stoffel
2022-03-25 8:39 ` Juri Linkov
2022-03-25 9:43 ` Augusto Stoffel
2022-03-27 7:46 ` Juri Linkov
2022-04-01 9:06 ` Augusto Stoffel
2022-04-01 16:35 ` Juri Linkov
2022-04-01 18:12 ` Augusto Stoffel
2022-04-02 18:23 ` Juri Linkov
2022-04-03 8:32 ` Augusto Stoffel
2022-04-03 17:06 ` Juri Linkov
2022-04-04 16:37 ` Juri Linkov
2022-04-05 16:38 ` Augusto Stoffel
2022-04-05 17:12 ` Juri Linkov
2022-04-07 19:32 ` Augusto Stoffel
2022-04-08 7:32 ` Juri Linkov
2022-04-08 7:53 ` Augusto Stoffel
2022-04-09 11:06 ` Augusto Stoffel
2022-04-10 19:38 ` Juri Linkov
2022-03-15 17:24 ` Juri Linkov
2022-03-15 21:21 ` Augusto Stoffel
2022-03-16 19:02 ` Juri Linkov
2022-03-16 20:25 ` Augusto Stoffel
2022-03-17 17:05 ` Juri Linkov
2022-03-17 19:06 ` Augusto Stoffel
2022-03-20 19:24 ` Juri Linkov
2022-03-20 19:59 ` Augusto Stoffel
2022-03-20 20:29 ` Juri Linkov
2022-03-20 20:56 ` Augusto Stoffel
2022-03-23 18:20 ` Juri Linkov
2022-03-23 18:54 ` Augusto Stoffel
2022-03-23 19:17 ` Eli Zaretskii
2022-03-23 19:53 ` Juri Linkov
2022-03-23 20:06 ` Juri Linkov
2022-03-23 20:30 ` Augusto Stoffel
2022-03-23 20:43 ` Juri Linkov
2022-03-17 19:45 ` Augusto Stoffel
2022-03-17 20:43 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sfrgz979.fsf@gmail.com \
--to=arstoffel@gmail.com \
--cc=53126@debbugs.gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.