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.devel Subject: Re: master 2b3f3d421a: Make minibuffer lazy highlight setup buffer-local where appropriate Date: Sun, 15 May 2022 23:10:03 +0200 Message-ID: <87lev2h590.fsf@gmail.com> References: <165264034407.21518.7194358780844409479@vcs2.savannah.gnu.org> <20220515184546.6304CC01683@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25414"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1.50 (gnu/linux) Cc: emacs-devel@gnu.org, Juri Linkov To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 15 23:11:25 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nqLWO-0006Sj-7T for ged-emacs-devel@m.gmane-mx.org; Sun, 15 May 2022 23:11:24 +0200 Original-Received: from localhost ([::1]:33046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqLWM-0000DI-Um for ged-emacs-devel@m.gmane-mx.org; Sun, 15 May 2022 17:11:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqLVB-0007tD-B7 for emacs-devel@gnu.org; Sun, 15 May 2022 17:10:09 -0400 Original-Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:46839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nqLV9-0006jK-3D for emacs-devel@gnu.org; Sun, 15 May 2022 17:10:09 -0400 Original-Received: by mail-ed1-x534.google.com with SMTP id j28so1987713eda.13 for ; Sun, 15 May 2022 14:10:06 -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=i1UUDCBBljizmcnIsTPM8LU3OjosoSZ5Pxhk9th8rvU=; b=lO5f6FJqGO65x6JoXSXQkSAWmnDRFB5OO7ttrOAUqar3WgBWuGtk1RtJwbl56ZIWEB C7zggrgGMlokfG/HwK21+Uk+cfl3cD+rxFglS2ab4qz/obRCQu4aLpCvSCAhkOhSlZHr e8C07e6SWf4P4IZXfeYql+CcRsyycXmHdXIMvxqUkFb03jTVE670UNMqqPAZY6Jbl1UA PpkviIBT57L42SoZXcBH+PSicmxU6480EVHq9jyTQ3baY6D/zQdyFqf8AbnamsfULIwk DSkSgcFJBNhK0uX984uFaTV3LWxej9ET0oBgoe4eBQ61J1lSnMHTGe3evskXQ9vxmX9B WQGw== 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=i1UUDCBBljizmcnIsTPM8LU3OjosoSZ5Pxhk9th8rvU=; b=LDHl0BoqnUhmfMqw0PvPHAGtU7wxrwH/lrj59ZSTCTE6p0DzvpB3SBbk1UDrBwYRM9 HmXHO+LaLz1r1jNOmmAbT2BB6tyUAxYr4VzLqU1BVkwTos9tpai/At+vbQ5CkEl1Nx+7 0V5+/uD6axgTU4QID7z4rNsatIqTxABwOg1f1ucedADYFUav3isQYsc9+KcKW39eCxIm JlRWLwbsDNCBveduOh8V/FG/a5qQPsv1W+YMKhIZUOLfza1VWPjRGLb+m9etxnfHF6d1 6teF1XlVl8ND/J9IK7uGoCjc1nZPxRpxlr284TvcxPmMnKLwr7zplduXiXx6sJu5zVUj C3BQ== X-Gm-Message-State: AOAM531OnbFPc19TSxdWxO/+3UfKdEMy32FWGlJKA8dirNeGOlF4zZJ9 iUtE0LJdMpbZ5hVCgSkLpw8= X-Google-Smtp-Source: ABdhPJyoOD25+DHYKfFrhCWbx9JekObvJJKrNi7PDFACnkZIB4gxkCy5xsil+MX2nZhOuxKanWWV4w== X-Received: by 2002:aa7:c3ca:0:b0:425:ecfc:4258 with SMTP id l10-20020aa7c3ca000000b00425ecfc4258mr10030980edr.266.1652649005286; Sun, 15 May 2022 14:10:05 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8ac0:56d0::1b06]) by smtp.gmail.com with ESMTPSA id n21-20020a17090673d500b006f506ed0b42sm3004992ejl.48.2022.05.15.14.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 May 2022 14:10:04 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sun, 15 May 2022 16:16:53 -0400") Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=arstoffel@gmail.com; helo=mail-ed1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:289799 Archived-At: --=-=-= Content-Type: text/plain On Sun, 15 May 2022 at 16:16, Stefan Monnier wrote: >> (when filter >> + (make-local-variable 'isearch-filter-predicate) >> (add-function :after-while isearch-filter-predicate filter)) > > `add-function` is modeled after `add-hook`, so the above > `make-local-variable` would be better replaced with > > (add-function :after-while (local 'isearch-filter-predicate) filter) > > [ Of course, that's pure theory. You'd better test it first. ] Yes, I guess that's the right way to approach this. The attached patch implements it. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-last-change-in-minibuffer-lazy-highlight-setup.patch >From 6699f0b1313f475e83757dc954ee59c8171e9500 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Sun, 15 May 2022 22:48:50 +0200 Subject: [PATCH] Fix last change in minibuffer-lazy-highlight-setup * lisp/isearch.el (minibuffer-lazy-highlight-setup): Apply advices buffer-locally. --- lisp/isearch.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lisp/isearch.el b/lisp/isearch.el index 3e1dab4d15..31fbdf01bf 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -4410,14 +4410,17 @@ minibuffer-lazy-highlight-setup (let ((unwind (make-symbol "minibuffer-lazy-highlight--unwind")) (after-change (make-symbol "minibuffer-lazy-highlight--after-change")) (display-count (make-symbol "minibuffer-lazy-highlight--display-count")) + (buffer (current-buffer)) overlay) (fset unwind (lambda () - (remove-function isearch-filter-predicate filter) + (when filter + (with-current-buffer buffer + (remove-function (local 'isearch-filter-predicate) filter))) (remove-hook 'lazy-count-update-hook display-count) (when overlay (delete-overlay overlay)) - (remove-hook 'after-change-functions after-change) - (remove-hook 'minibuffer-exit-hook unwind) + (remove-hook 'after-change-functions after-change t) + (remove-hook 'minibuffer-exit-hook unwind t) (let ((lazy-highlight-cleanup cleanup)) (lazy-highlight-cleanup)))) (fset after-change @@ -4447,8 +4450,8 @@ minibuffer-lazy-highlight-setup (setq overlay (make-overlay (point-min) (point-min) (current-buffer) t)) (add-hook 'lazy-count-update-hook display-count)) (when filter - (make-local-variable 'isearch-filter-predicate) - (add-function :after-while isearch-filter-predicate filter)) + (with-current-buffer buffer + (add-function :after-while (local 'isearch-filter-predicate) filter))) (funcall after-change nil nil nil))))) -- 2.36.1 --=-=-= Content-Type: text/plain Now, I had tried it earlier and noticed something looked fishy. Now I can reproduce the problem: 1. With an active region, call C-M-% 2. Switch from the minibuffer back to the original buffer 3. Call keyboard-escape-quit (maybe twice) to quit the minibuffer prompt. Then the buffer-local value of `isearch-filter-predicate' is not cleaned up. Is it by any chance intentional that minibuffer-exit-hook doesn't run in this case? --=-=-=--