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: Mon, 10 Jan 2022 21:09:40 +0200 Organization: LINKOV.NET Message-ID: <8635lvif0r.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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19025"; 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 Mon Jan 10 20:19:22 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 1n70CQ-0004la-9i for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Jan 2022 20:19:22 +0100 Original-Received: from localhost ([::1]:49240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n70CP-0000vF-3Z for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Jan 2022 14:19:21 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n705K-0001ni-W4 for bug-gnu-emacs@gnu.org; Mon, 10 Jan 2022 14:12:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n705K-00048k-2J for bug-gnu-emacs@gnu.org; Mon, 10 Jan 2022 14:12:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n705J-0006xP-SM for bug-gnu-emacs@gnu.org; Mon, 10 Jan 2022 14:12:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Jan 2022 19:12: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.164184188326688 (code B ref 53126); Mon, 10 Jan 2022 19:12:01 +0000 Original-Received: (at 53126) by debbugs.gnu.org; 10 Jan 2022 19:11:23 +0000 Original-Received: from localhost ([127.0.0.1]:53318 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n704h-0006wO-6x for submit@debbugs.gnu.org; Mon, 10 Jan 2022 14:11:23 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:40987) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n704f-0006w9-0x for 53126@debbugs.gnu.org; Mon, 10 Jan 2022 14:11:22 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 98B38FF803; Mon, 10 Jan 2022 19:11:12 +0000 (UTC) In-Reply-To: <87o84jcx5x.fsf@gmail.com> (Augusto Stoffel's message of "Mon, 10 Jan 2022 18:34:18 +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:223893 Archived-At: > I attached a new patch (still a sketch) that requires no changes in > comint.el and simple.el. Perhaps you will find this approach more > acceptable. Thanks, no changes in other files is certainly a big plus. >> 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? > > I tried this and it's relatively simple to do, but there is a problem. > Suppose you want to replace all "a" with "z", and your buffer has 20 > "a"s initially. Then, as you keep hitting "y" to confirm a replacement > the count will be > > 1/20, 1/19, ..., 1/1 This is an interesting question. I tried in other editors, and e.g. in the editor xed that is installed by default, this is exactly what is displayed: 1/20, 1/19, ..., 1/1. > since the number of "a"s decrease, and the point is always at the first > of the still-existing ones. But probably one should count the number of > prompts, so > > 1/20, 2/20, ..., 20/20 > > I think this means `perform-replace' has to implement its own way to > display a count. Maybe this makes more sense, when the users will learn what do these numbers mean. >> 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. > > 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) > But note that there are two possible types > of counts: a "current/total" counter or just a "total" counter. Each > use case calls for a different count style. The format of the total counter needs to be defined in a separate variable. > By the way, I'm debating a bit whether > `isearch-lazy-count-display-function' should be: > > 1. Either nil or function, as it is right now, > 2. #'ignore by default, so similar to 1) but a bit easier to use with > `add-function' > 3. a hook, the main inconvenience being that it can't be easily let-bound. This can be answered only by testing with all possible cases ;-)