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: Fri, 01 Apr 2022 11:06:46 +0200 Message-ID: <875ynt41g9.fsf@gmail.com> References: <87sftyweb2.fsf@gmail.com> <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> <86zglrl4gq.fsf@mail.linkov.net> <87ee32yk7v.fsf@gmail.com> <861qz1zqfb.fsf@mail.linkov.net> <875yod1wyb.fsf@gmail.com> <86mtho5y56.fsf@mail.linkov.net> <87sfrgz979.fsf@gmail.com> <861qz0475w.fsf@mail.linkov.net> <87sfrd2cbb.fsf@gmail.com> <86fsnc4fvm.fsf@mail.linkov.net> <878rsz6um2.fsf@gmail.com> <86ils2mmbe.fsf@mail.linkov.net> <87v8w2qsee.fsf@gmail.com> <86y20vu9c6.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="5369"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.92 (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 Fri Apr 01 11:22:08 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 1naDTr-0001DG-Qt for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 Apr 2022 11:22:07 +0200 Original-Received: from localhost ([::1]:43862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1naDTq-0001gL-8v for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 Apr 2022 05:22:06 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naDFG-0004NO-Gp for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2022 05:07:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46987) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1naDFG-00057F-7E for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2022 05:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1naDFF-0001fY-VN for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2022 05:07: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: Fri, 01 Apr 2022 09:07: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.16488040176405 (code B ref 53126); Fri, 01 Apr 2022 09:07:01 +0000 Original-Received: (at 53126) by debbugs.gnu.org; 1 Apr 2022 09:06:57 +0000 Original-Received: from localhost ([127.0.0.1]:40884 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1naDFA-0001fF-T9 for submit@debbugs.gnu.org; Fri, 01 Apr 2022 05:06:57 -0400 Original-Received: from mail-ej1-f52.google.com ([209.85.218.52]:38537) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1naDF9-0001f0-51 for 53126@debbugs.gnu.org; Fri, 01 Apr 2022 05:06:55 -0400 Original-Received: by mail-ej1-f52.google.com with SMTP id r13so4491418ejd.5 for <53126@debbugs.gnu.org>; Fri, 01 Apr 2022 02:06:55 -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=Xd4fupytZj1bTQaiwxmxyk4Iz8tXojBsaJG9qo9mDic=; b=YCkdjjw6QwqPoTjB5GmojgyQMXElTOj7aPTgfLvxi6z/1MyNQADoWuEk4gcLYKSINs 206UqN+sLMzICjBYA1dSx9iSA9OdMxxq7zpWOTvMyx7yq+dq1If7CqncCAxMXVNVt3jN qggNk5Nlr/82OdVkRKpA2A+etY37YlPl1v8msLLiQreEwXThDXhiMSnDBcwByDoBOGOB WlZnMrjDxYF06N1zOHrHeRw+fgKCpUH/Zppa3FOf4tBug1GkJ+I2LiTLv+lI1kLKjNI4 W8WW6gSldSklEaBhVw1cbFKDCF6WfcI3Fs1DJzLeHT++7oAMmkcZqppGf11pOkb+WWgG 9d0Q== 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=Xd4fupytZj1bTQaiwxmxyk4Iz8tXojBsaJG9qo9mDic=; b=tyknG/wW1iPp7wsFl1L4z2nKmz3HVKu6mcXtQ1sGLi+XkQSSht3gnGbopiNHlXnqiA sqX8oCEqtYOeLe8paSc5xdJFayikeUkYzHr8IlTUghiPUDa6kQSJo5ZIDsmHQ/7wLbHG d22luFYfn4gaBefiBYjI91TUUmMOQm+fcVA2uEcdWMBhnX74e2mLoBafJ89fRjsy7yBi fUkyhMBcPm08v5uLB2iEkIOQpjRHfNpaSPPkoelxF3nz9wuSY/PAH4jlTG1hDFXl79t9 VFX0Mwd6ESvorx0ZsuEAqYSotoku+uz0zEi+tDmAYcAurcQq/vcb52nSrmJQHxeivwT1 CUwA== X-Gm-Message-State: AOAM5337jLvJxd3VF3cRGOVqW7Zy2UCTgcHRcIMKgdoXvDISbviNDsiT YimGe3wSDcBbLuqbtlbc/fPipSc9j0o= X-Google-Smtp-Source: ABdhPJwTxw9CCZoyiEgYa9xgC48cleeGWuEwrEisV/uu4AsGCTCikDi7fk1sOtiNrnTh7/P5TXpHlA== X-Received: by 2002:a17:906:69d1:b0:6ce:7201:ec26 with SMTP id g17-20020a17090669d100b006ce7201ec26mr8469996ejs.105.1648804008888; Fri, 01 Apr 2022 02:06:48 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::7039]) by smtp.gmail.com with ESMTPSA id rl16-20020a170907217000b006e4c1027beasm767550ejb.55.2022.04.01.02.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Apr 2022 02:06:47 -0700 (PDT) In-Reply-To: <86y20vu9c6.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 27 Mar 2022 10:46:01 +0300") 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:229210 Archived-At: On Sun, 27 Mar 2022 at 10:46, Juri Linkov wrote: >> Lazy highlight is controlled by lots of variables. These variables need >> to be set for the duration of the minibuffer session that reads the >> replacement strings. If we move this to a separate function, we can't >> use 'let' anymore, so we basically need to reinvent the dynamic scoping >> feature of Elisp (i.e., save the current values, set the variables to >> new values, then restore the old values in some hook). And an even ugly >> workaround would be needed to replace the necessary condition-case. Or >> do I misunderstand you altogether? > > Do you think a macro could help to make this function short again? That could be done, of course, but I'm pretty sure that this macro would be used exactly once. I don't think we should have a general-purpose macro to set up the lazy highlighting for arbitrary minibuffer commands, because complex cases like query-replace will be rare, and in any case we can't anticipate all special requirements. Anyway, should I refactor my patch to use a macro? Something else that could make 'query-replace-read-args' slightly shorter is to define (defun replace-regexp-function (delimited-flag) (or replace-regexp-function delimited-flag (and replace-char-fold (not regexp-flag) #'char-fold-to-regexp))) This function could be used in 3 different places in replace.el. > Then when you would want to add highlighting to the minibuffer > reading the TO part of replacement too or to other minibuffers, > it would be easy to just add a single line with that macro. Right, a preview of the replacement text will also need some extra work. This will probably involve some extension to 'isearch-lazy-highlight-update', making it even more complicated...