emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 2b3f3d421a: Make minibuffer lazy highlight setup buffer-local


From: Stefan Monnier
Subject: Re: master 2b3f3d421a: Make minibuffer lazy highlight setup buffer-local where appropriate
Date: Wed, 18 May 2022 16:51:40 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Juri Linkov [2022-05-18 21:59:04] wrote:

>>> `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.
>
> Thanks, pushed.
>
>> 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?
>
> Indeed, a buffer-local minibuffer-exit-hook is not called
> when the minibuffer is exited outside of the minibuffer.

Looks like a bug.
How 'bout the patch below?


        Stefan


diff --git a/src/minibuf.c b/src/minibuf.c
index df82bcb121a..ac48d0f4714 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -265,7 +265,7 @@ DEFUN ("set-minibuffer-window", Fset_minibuffer_window,
 
 static void read_minibuf_unwind (void);
 static void minibuffer_unwind (void);
-static void run_exit_minibuf_hook (void);
+static void run_exit_minibuf_hook (Lisp_Object minibuf);
 
 
 /* Read a Lisp object from VAL and return it.  If VAL is an empty
@@ -749,7 +749,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, 
Lisp_Object prompt,
      separately from read_minibuf_unwind because we need to make sure that
      read_minibuf_unwind is fully executed even if exit-minibuffer-hook
      signals an error.  --Stef  */
-  record_unwind_protect_void (run_exit_minibuf_hook);
+  record_unwind_protect (run_exit_minibuf_hook, Fcurrent_buffer ());
 
   /* Now that we can restore all those variables, start changing them.  */
 
@@ -1076,9 +1076,13 @@ get_minibuffer (EMACS_INT depth)
 }
 
 static void
-run_exit_minibuf_hook (void)
+run_exit_minibuf_hook (Lisp_Object minibuf)
 {
+  specpdl_ref count = SPECPDL_INDEX ();
+  record_unwind_current_buffer ();
+  Fset_buffer (minibuf);
   safe_run_hooks (Qminibuffer_exit_hook);
+  unbind_to (count, Qnil);
 }
 
 /* This variable records the expired minibuffer's frame between the




reply via email to

[Prev in Thread] Current Thread [Next in Thread]