From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel 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:25:01 +0100 Message-ID: <871qz11w82.fsf@gmail.com> 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> <868rt9wwji.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11183"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) Cc: 53126@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 16 21:26:25 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 1nUaDw-0002fK-RQ for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 16 Mar 2022 21:26:24 +0100 Original-Received: from localhost ([::1]:51134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUaDv-0002Ou-TG for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 16 Mar 2022 16:26:23 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:59780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUaDa-0002Ok-38 for bug-gnu-emacs@gnu.org; Wed, 16 Mar 2022 16:26:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58478) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUaDZ-0006t8-R0 for bug-gnu-emacs@gnu.org; Wed, 16 Mar 2022 16:26:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nUaDZ-00047X-OK for bug-gnu-emacs@gnu.org; Wed, 16 Mar 2022 16:26:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Mar 2022 20:26: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.164746231115769 (code B ref 53126); Wed, 16 Mar 2022 20:26:01 +0000 Original-Received: (at 53126) by debbugs.gnu.org; 16 Mar 2022 20:25:11 +0000 Original-Received: from localhost ([127.0.0.1]:52375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUaCl-00046H-AM for submit@debbugs.gnu.org; Wed, 16 Mar 2022 16:25:11 -0400 Original-Received: from mail-ej1-f53.google.com ([209.85.218.53]:41614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUaCj-00045z-2r for 53126@debbugs.gnu.org; Wed, 16 Mar 2022 16:25:09 -0400 Original-Received: by mail-ej1-f53.google.com with SMTP id a8so6566110ejc.8 for <53126@debbugs.gnu.org>; Wed, 16 Mar 2022 13:25:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=kqarn9g76UQ6L+KvgmF1gBQzmJSDFgBnopK1Q7A5CFg=; b=pYlnYlA/zi/K2Ch1rY3NPZ5iLVh4378O6ST+V5oojC+NIBnye0v2omof80szrbHmU/ 8jXcSxiv8V1+CkTuV4TGHuYxVcP08n5k34nU5fYvhtDUjbfpc0nfKCDWSCrVRhVsmSWv szXagPJyQ9fL/GlfVcvk0lwwKnw3N6O4x7QEdigWDRAOz9tYq4O8ShLsuluUj9Oapcjg 8jrrqTeFyZKjhnz0EjmsCq2crt1xq0PqKL+ShdeaAJBrCKt8bQEd5bxLid1u0ljA2ecr /ONrHKe9DPNZq6q8wVQ2f7JxG0JxBPzxy8m7i7KeEXZg7Qjuli/SISicHzloSbTchrQ0 ddmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=kqarn9g76UQ6L+KvgmF1gBQzmJSDFgBnopK1Q7A5CFg=; b=A1yin5tXJPwX6J225KIs6hEPc9D2AVBAW1fd+rA2WRP4klMm8iot7pP/nV8yqc5xvv XhG0Q0tJjEr/yIrpPUvFBkxSbli31hHOB0ocq6Frb37MmROU/aEsJNRNQMpupqLFC08q aJROtWlA8QYbCLIiYTF7B3RasarNMkBFRRO7CaZaF+8NfYC6/z+5+ziDcRcZ0XdGMLpQ VCUdNG3f+wjG3iW3EclQFEhN8CMeh8iCJLvXp2eeVhUu3x/9CDhdKJgJKm40xoUeqW5p yO6T/UH6rl3+FUDgCCfbXCV3lGyet1X94k1HtOz9RsQIiJyxpI9PfdBokbdUNrhy8N8o 9lRw== X-Gm-Message-State: AOAM53075jfxB/Pj8KG64AqELXuliDnnzkXgl9nZKN8UQKDO+wunpcwO tqOouGVKSl7x3M9wh5164ZEaRd7yJJ0= X-Google-Smtp-Source: ABdhPJzHvjEGj4YvUyIpADYs2JYG/RJOX8RI3EY1to/8xzXdZspeKAGL1hcLmvydmHwK6gdf/5UZ8A== X-Received: by 2002:a17:907:86a3:b0:6da:870c:af44 with SMTP id qa35-20020a17090786a300b006da870caf44mr1403025ejc.445.1647462302877; Wed, 16 Mar 2022 13:25:02 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::758e]) by smtp.gmail.com with ESMTPSA id k23-20020a1709062a5700b006ccd8fdc300sm1314907eje.180.2022.03.16.13.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 13:25:02 -0700 (PDT) In-Reply-To: <868rt9wwji.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 16 Mar 2022 21:02:25 +0200") 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:228451 Archived-At: On Wed, 16 Mar 2022 at 21:02, Juri Linkov wrote: >>>> @@ -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. Does it always happen for you? I see this occasionally, and as far as I can tell it's random. >>> 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. Okay, the patch from yesterday already does that. >>> 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. Great. >>> 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. Ah, I see. I must say, in isearch.el I don't like this trichotomy of the regexp/literal/with isearch-regexp-function cases. Ideally, the regexp and literal search cases would be handled by isearch-regexp-function set to identity respectively regexp-quote. But it would be a large refactoring, perhaps with only aesthetic benefits.