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: Sun, 09 Jan 2022 20:58:32 +0200 Organization: LINKOV.NET Message-ID: <861r1g7n3b.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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2194"; 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 Sun Jan 09 20:05:40 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 1n6dVc-0000Nz-K2 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Jan 2022 20:05:40 +0100 Original-Received: from localhost ([::1]:35466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6dVb-0006bB-5h for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Jan 2022 14:05:39 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6dV1-0006b1-Sh for bug-gnu-emacs@gnu.org; Sun, 09 Jan 2022 14:05:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58367) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6dV0-00058n-Q4 for bug-gnu-emacs@gnu.org; Sun, 09 Jan 2022 14:05:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n6dV0-0007aU-I6 for bug-gnu-emacs@gnu.org; Sun, 09 Jan 2022 14:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Jan 2022 19:05:02 +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.164175506429116 (code B ref 53126); Sun, 09 Jan 2022 19:05:02 +0000 Original-Received: (at 53126) by debbugs.gnu.org; 9 Jan 2022 19:04:24 +0000 Original-Received: from localhost ([127.0.0.1]:51270 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n6dUJ-0007ZS-Jx for submit@debbugs.gnu.org; Sun, 09 Jan 2022 14:04:24 -0500 Original-Received: from relay12.mail.gandi.net ([217.70.178.232]:47495) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n6dUD-0007Z8-O6 for 53126@debbugs.gnu.org; Sun, 09 Jan 2022 14:04:18 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 63FEC20000A; Sun, 9 Jan 2022 19:04:05 +0000 (UTC) In-Reply-To: <87tuedp6pl.fsf@gmail.com> (Augusto Stoffel's message of "Sun, 09 Jan 2022 11:02:46 +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:223856 Archived-At: >> Or for asynchronous lazy-count a new hook needs to be run at the end >> of isearch-lazy-highlight-buffer-update in addition to the call of >> isearch-message. > > That's what the patch does (but with a variable pointing to a function > instead of a hook, although this can be changed). But note that it's > not enough to do something “in addition to the call of isearch-message”; > it's necessary to _suppress_ the call to isearch-message. 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? >> Maybe then this feature could be added to read-regexp or even >> to read-from-minibuffer? And activated by adding a setup function >> to minibuffer-setup-hook like other minibuffer's features do, such as >> icomplete-minibuffer-setup, minibuffer-depth-setup, rfn-eshadow-setup-minibuffer. > > This is what the patch does, with code of this kind: > > ``` > (let ((isearch-regexp t) > ;; Whatever else isearch / lazy-highlight settings might be needed > (isearch-lazy-count-display-function #'isearch-read-with-highlight-count)) > (minibuffer-with-setup-hook #'isearch-read-with-highlight-setup > (read-from-minibuffer "Type a regexp with preview: "))) > ``` > > There could be a convenience wrapper for this code, but I'm not sure > that makes much sense, because isearch and lazy-highlight have too many > parameters one might need to set so it's better to be explicit/flexible. 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. >> Then maybe a new feature could be named e.g. "lazy-minibuffer"? This feature has little to do with isearch. This is why there are efforts to move away from the prefix isearch- for lazy-related functions and variables, so we have now: lazy-count-prefix-format lazy-count-suffix-format lazy-highlight-buffer lazy-highlight-buffer-max-at-a-time lazy-highlight-cleanup lazy-highlight-initial-delay lazy-highlight-interval lazy-highlight-max-at-a-time ... There are still isearch-specific names like isearch-lazy-count that enables lazy-count in isearch-mode. What would be a similar name for the minibuffer? Maybe minibuffer-lazy-count? Then the prefix isearch- needs to be removed from other names too, e.g. isearch-lazy-count-display-function -> lazy-count-display-function isearch-read-with-highlight-setup maybe to minibuffer-lazy-highlight-setup, etc.