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: Wed, 16 Mar 2022 21:02:25 +0200 Organization: LINKOV.NET Message-ID: <868rt9wwji.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> <86sfrjia5u.fsf@mail.linkov.net> <87ilseyks7.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="6022"; 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 Wed Mar 16 20:05:30 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 1nUYxd-0001Iw-JU for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 16 Mar 2022 20:05:29 +0100 Original-Received: from localhost ([::1]:49846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUYxc-00022Y-9J for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 16 Mar 2022 15:05:28 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:42326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUYxD-00022D-LA for bug-gnu-emacs@gnu.org; Wed, 16 Mar 2022 15:05:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUYxC-0002ID-7V for bug-gnu-emacs@gnu.org; Wed, 16 Mar 2022 15:05:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nUYxC-0001vn-38 for bug-gnu-emacs@gnu.org; Wed, 16 Mar 2022 15:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Mar 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.16474574677359 (code B ref 53126); Wed, 16 Mar 2022 19:05:02 +0000 Original-Received: (at 53126) by debbugs.gnu.org; 16 Mar 2022 19:04:27 +0000 Original-Received: from localhost ([127.0.0.1]:52311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUYwc-0001ud-SS for submit@debbugs.gnu.org; Wed, 16 Mar 2022 15:04:27 -0400 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:60561) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUYwY-0001uA-VX for 53126@debbugs.gnu.org; Wed, 16 Mar 2022 15:04:23 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id DDAEE60002; Wed, 16 Mar 2022 19:04:15 +0000 (UTC) In-Reply-To: <87ilseyks7.fsf@gmail.com> (Augusto Stoffel's message of "Tue, 15 Mar 2022 22:21:12 +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:228445 Archived-At: >>> @@ -2350,7 +2352,9 @@ isearch-query-replace >>> + (let ((lazy-highlight-cleanup (and lazy-highlight-cleanup >>> + (not query-replace-lazy-highlight)))) >>> + (isearch-done nil t)) >> >> Is this some optimization? It seems it's intended to leave >> some existing highlighting? Is this to avoid double highlighting? > > The weird let-binding for lazy-highlight-cleanup is indeed an > optimization. Without it, you can see the lazy highlights briefly flash > off an on again after you hit RET to confirm the replacement string. > > (Same remark explains why condition-case is used instead of a > unwind-protect in query-replace-read-args). When I tried your latest patch, it still flashes when it starts the perform-replace loop. >> The problem is that when these conditions 'isearch-mode (null isearch-message-function)' >> are removed, now this shows wrong counts in the minibuffer history search >> (e.g. 'M-! C-r s C-r C-r ...') and the shell history search >> (e.g. 'M-x shell RET M-r s C-r C-r ...'). Before this change >> counting was disabled in the history search because it shows wrong numbers. > > Okay, so this means we should bind isearch-lazy-count to nil in these > commands, do you agree? It has always looked like a hack to me to check > for (null isearch-message-function). Binding isearch-lazy-count to nil could serve as a temporary measure until lazy-count will be supported in the history search. >> For some reasons the package lisp/mb-depth.el uses 'after-string' >> instead of 'before-string', and (make-overlay (point-min) (1+ (point-min))) >> instead of (make-overlay (point-min) (point-min)), >> so maybe better to do the same? > > Okay, but do you know the reasons? I've changed to before-string, but I > don't like to make the overlay 1 char longer than it has to be :-P I don't know the reason. Since it works in your patch, then it's ok. >> Highlighting is still incorrect for word replacement ('C-u M-%') >> and for non-nil 'replace-char-fold'. To handle these cases correctly, >> 'replace-highlight' uses: >> >> (isearch-regexp-function (or replace-regexp-function >> delimited-flag >> (and replace-char-fold >> (not regexp-flag) >> #'char-fold-to-regexp))) > > Okay, fixed this. (BTW, where is replace-regexp-function used? It's > not set anywhere in Emacs, and it's not a defcustom either.) 'replace-regexp-function' was added recently in bug#52558 to allow implementing more regexp types in bug#54017.