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, 25 Mar 2022 10:43:21 +0100 Message-ID: <87v8w2qsee.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> <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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1030"; 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 Mar 25 10:44:33 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 1nXgUj-000AcL-0z for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Mar 2022 10:44:33 +0100 Original-Received: from localhost ([::1]:56088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXgUh-00004u-81 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Mar 2022 05:44:31 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXgUI-0008WP-OW for bug-gnu-emacs@gnu.org; Fri, 25 Mar 2022 05:44:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56241) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nXgUI-000745-EK for bug-gnu-emacs@gnu.org; Fri, 25 Mar 2022 05:44:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nXgUI-0001mi-2l for bug-gnu-emacs@gnu.org; Fri, 25 Mar 2022 05:44:06 -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, 25 Mar 2022 09:44:05 +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.16482014206811 (code B ref 53126); Fri, 25 Mar 2022 09:44:05 +0000 Original-Received: (at 53126) by debbugs.gnu.org; 25 Mar 2022 09:43:40 +0000 Original-Received: from localhost ([127.0.0.1]:50138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nXgTo-0001li-9F for submit@debbugs.gnu.org; Fri, 25 Mar 2022 05:43:39 -0400 Original-Received: from mail-ej1-f51.google.com ([209.85.218.51]:46810) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nXgTh-0001lG-Ln for 53126@debbugs.gnu.org; Fri, 25 Mar 2022 05:43:33 -0400 Original-Received: by mail-ej1-f51.google.com with SMTP id qx21so14165818ejb.13 for <53126@debbugs.gnu.org>; Fri, 25 Mar 2022 02:43:29 -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=t/+ucGN/oUCHE9NrMAyTyIOugSW/gRER80sIWt+dcJQ=; b=bGwY4rmJXvXnwuLWzWpbMLTHNnL9Xs5Bp9xX6YwiebIXyIBMkN2g5HZeJe44aN5Tr/ +M2lmdlgRSkx+SQSeMvZQPghdE5RaMJmlEJ/w4HP2p2WAVm+o9HyObwAuEMpAixjLY4/ r73XdP4C33lBnn2RuVDM7dPP8S01wfiqavVhgKB9AVTggaSfw8etX1TkO+2E7VoKIh0t 82nZ8hdbUwgeUWdqQ2dbqFFCmTHl44Wxb5pO0X9TPAl41cJwT8AmxZiwApGT5TtapuLx wM4a7Gr6BKyIasYDWZh9oM/2wYCjbvTZhXvqyUiwA4pz5oKuDuzNYODPtX4y+YFoXnjh OJwg== 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=t/+ucGN/oUCHE9NrMAyTyIOugSW/gRER80sIWt+dcJQ=; b=EUTusW8gg0wRW4ZQ3FaQbUMviiGVQ/zFZ0hPwqkm5g3CGJZXfKDiElstLpEJS1U3OV L+T6EZfbFnDYC5tSk6+h/TAWeXupAJ819SIzqGXNZR/UD2dM05obXCNdLTS5RB0fRBMI YBO6g/Slc/JJQ7tndR2c4CZZ3T9dG84hYB08ZBXmzh2HcSkk17er0g+EmhcP5gMtvLsY qEA9ZlcgguRkXQa1JfnlrR6nWKws4D/IIOK3l8WI3GOT9Wnsm2Cclpt5fCFj6wt0x+bt pK41k8autE4OgBL+Y1/p/ghX+EIpSCZ8ZTo34lA/2x5xg1HHzRcbGyrt7KBm/o5KTgO1 7lig== X-Gm-Message-State: AOAM5308WdWYdT7PFjptdTJcK51CwQ64xqnQvE7ySQVnJ7sYnlV09xqx Ad2WChh4ySX8GZ9Ff7TUEcFb66TyvNA= X-Google-Smtp-Source: ABdhPJz1ZHHrKDL+pi1oEm5Sv9p0fvPR481Gjby4YXuhY37AExfQpBYQJaubExbXjut33V/iknqRgA== X-Received: by 2002:a17:906:c211:b0:6ce:e221:4c21 with SMTP id d17-20020a170906c21100b006cee2214c21mr10201573ejz.691.1648201403258; Fri, 25 Mar 2022 02:43:23 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::7039]) by smtp.gmail.com with ESMTPSA id e9-20020a170906c00900b006d4a45869basm2118756ejz.199.2022.03.25.02.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 02:43:22 -0700 (PDT) In-Reply-To: <86ils2mmbe.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 25 Mar 2022 10:39:12 +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:228922 Archived-At: On Fri, 25 Mar 2022 at 10:39, Juri Linkov wrote: > The name of the function is `query-replace-read-args'. > And now most of the function is dealing with highlighting: The good thing is that it was a rather short function before, so now it's still reasonably sized. Also, the lazy highlight for query-replace is essentially taken care of in one single place. > This highlighting needs to be refactored from `query-replace-read-args' > into a separate highlighting function. Okay, you've said something along these lines before but I don't understand what you mean. 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? The above accounts for most of the additions to query-replace-read-args. What could move elsewhere are the 10 lines starting from (when query-replace-lazy-highlight but this will not change the fact that most of query-replace-read-args now takes care of setting up lazy highlight, so I don't see any real benefits to this. Or maybe the issue is with this line: (add-hook 'minibuffer-exit-hook cleanup) which adds a closure rather than a symbol to the hook? That I could be changed. I think it would require to add a defvar just to store 'region-filter', among other things I don't like, but I can do it.