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: Tue, 05 Apr 2022 20:12:16 +0300 Organization: LINKOV.NET Message-ID: <86wng3laj3.fsf@mail.linkov.net> References: <87sftyweb2.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> <875ynt41g9.fsf@gmail.com> <86pmm1azkd.fsf@mail.linkov.net> <87a6d43c6n.fsf@gmail.com> <86r16fz6bw.fsf@mail.linkov.net> <87o81i5zzn.fsf@gmail.com> <86v8vo6c2k.fsf@mail.linkov.net> <87bkxfeb8j.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="8768"; 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 Tue Apr 05 19:42:44 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 1nbnCV-00028G-7w for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 05 Apr 2022 19:42:43 +0200 Original-Received: from localhost ([::1]:36710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nbnCU-0001zY-9e for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 05 Apr 2022 13:42:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nbnAt-0001SZ-Kv for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2022 13:41:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nbnAs-0005ZE-Qg for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2022 13:41:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nbnAs-000284-Mb for bug-gnu-emacs@gnu.org; Tue, 05 Apr 2022 13:41: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: Tue, 05 Apr 2022 17:41: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.16491804208085 (code B ref 53126); Tue, 05 Apr 2022 17:41:02 +0000 Original-Received: (at 53126) by debbugs.gnu.org; 5 Apr 2022 17:40:20 +0000 Original-Received: from localhost ([127.0.0.1]:56059 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbnAC-00026L-2T for submit@debbugs.gnu.org; Tue, 05 Apr 2022 13:40:20 -0400 Original-Received: from relay11.mail.gandi.net ([217.70.178.231]:47541) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nbnAA-000260-1W for 53126@debbugs.gnu.org; Tue, 05 Apr 2022 13:40:18 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 9031A100007; Tue, 5 Apr 2022 17:40:10 +0000 (UTC) In-Reply-To: <87bkxfeb8j.fsf@gmail.com> (Augusto Stoffel's message of "Tue, 05 Apr 2022 18:38:52 +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:229454 Archived-At: > But that's a good point, we don't need a macro. Among several > variations, we could make the setup code look like this: > > (minibuffer-with-setup-hook > (minibuffer-lazy-highlight-init :case-fold case-fold-search > :regexp regexp-flag > ...) > (query-replace-read-from prompt regexp-flag)) > > where now `minibuffer-lazy-highlight-init' is not the function that > initializes stuff, but rather a function that returns a closure that > initializes stuff. Looks good. >> Please also note that condition-case can be replaced by >> a hook in minibuffer-exit-hook that can remove highlighting >> after exiting the minibuffer. > > If it was a `unwind-protect', I would agree. But I don't know how to > simulate a `condition-case'. Specifically, how can we determine if some > hook (the minibuffer-exit-hook in this case) is being run "normally" or > as part of the recovery from a signaled error? Shouldn't both cases clean up highlight from the buffer? Then I see no need to distinguish each case. Or if really needed, you can try to bind the cleanup to command-error-function. >> Alternatively, the same lambda above could be added to >> >> (add-hook 'minibuffer-setup-hook (lambda () ...)) > > Why was it again that we want to avoid saying something like this? > > (let ((case-fold-search whatever) > (isearch-regexp regexp-flag)) > (minibuffer-with-setup-hook #'minibuffer-lazy-highlight-init > (query-replace-read-from prompt regexp-flag))) 4 lines look nice, unlike 20 lines in one of your patches ;-)