From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs 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 Organization: LINKOV.NET Message-ID: <86zglrl4gq.fsf@mail.linkov.net> References: <87sftyweb2.fsf@gmail.com> <861r1iyrvw.fsf@mail.linkov.net> <87zgo6owaf.fsf@gmail.com> <86k0f9xnrn.fsf@mail.linkov.net> <87tuedp6pl.fsf@gmail.com> <861r1g7n3b.fsf@mail.linkov.net> <87o84jcx5x.fsf@gmail.com> <8635lvif0r.fsf@mail.linkov.net> <87mtidip1w.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10613"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 53126@debbugs.gnu.org To: Augusto Stoffel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 15 18:28:34 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nUAyI-0002eh-Ko for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Mar 2022 18:28:34 +0100 Original-Received: from localhost ([::1]:52320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUAyG-0006dT-3F for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Mar 2022 13:28:32 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUAxm-0005mP-KG for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 13:28:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUAxm-0002VF-B8 for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 13:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nUAxl-0005OW-VL for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 13:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Mar 2022 17:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 53126-submit@debbugs.gnu.org id=B53126.164736524520676 (code B ref 53126); Tue, 15 Mar 2022 17:28:01 +0000 Original-Received: (at 53126) by debbugs.gnu.org; 15 Mar 2022 17:27:25 +0000 Original-Received: from localhost ([127.0.0.1]:49529 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUAxB-0005NO-Bf for submit@debbugs.gnu.org; Tue, 15 Mar 2022 13:27:25 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:56419) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUAx8-0005N7-PH for 53126@debbugs.gnu.org; Tue, 15 Mar 2022 13:27:23 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 232E3C0006; Tue, 15 Mar 2022 17:27:14 +0000 (UTC) In-Reply-To: <87mtidip1w.fsf@gmail.com> (Augusto Stoffel's message of "Sat, 26 Feb 2022 17:13:31 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:228415 Archived-At: > 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.