From: Augusto Stoffel <arstoffel@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org, Juri Linkov <juri@linkov.net>
Subject: Re: master 2b3f3d421a: Make minibuffer lazy highlight setup buffer-local where appropriate
Date: Sun, 15 May 2022 23:10:03 +0200 [thread overview]
Message-ID: <87lev2h590.fsf@gmail.com> (raw)
In-Reply-To: <jwvlev2d02z.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 15 May 2022 16:16:53 -0400")
[-- Attachment #1: Type: text/plain, Size: 592 bytes --]
On Sun, 15 May 2022 at 16:16, Stefan Monnier <monnier@iro.umontreal.ca> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-last-change-in-minibuffer-lazy-highlight-setup.patch --]
[-- Type: text/x-patch, Size: 2173 bytes --]
From 6699f0b1313f475e83757dc954ee59c8171e9500 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
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)))))
\f
--
2.36.1
[-- Attachment #3: Type: text/plain, Size: 435 bytes --]
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?
next prev parent reply other threads:[~2022-05-15 21:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <165264034407.21518.7194358780844409479@vcs2.savannah.gnu.org>
[not found] ` <20220515184546.6304CC01683@vcs2.savannah.gnu.org>
2022-05-15 20:16 ` master 2b3f3d421a: Make minibuffer lazy highlight setup buffer-local where appropriate Stefan Monnier
2022-05-15 21:10 ` Augusto Stoffel [this message]
2022-05-18 18:59 ` Juri Linkov
2022-05-18 20:51 ` Stefan Monnier
2022-05-19 16:20 ` Juri Linkov
2022-05-22 14:40 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lev2h590.fsf@gmail.com \
--to=arstoffel@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=juri@linkov.net \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.