Run minibuffer-exit-hook in the right buffer

* src/minibuf.c (run_exit_minibuf_hook): Take the minibuffer as arg
and run the hook in that buffer.
(read_minibuf): Adjust accordingly.
This commit is contained in:
Stefan Monnier 2022-05-22 10:35:02 -04:00
parent 5088ebc8eb
commit cc878319f9

View file

@ -265,7 +265,7 @@ without invoking the usual minibuffer commands. */)
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, minibuffer);
/* Now that we can restore all those variables, start changing them. */
@ -1076,9 +1076,14 @@ static EMACS_INT minibuf_c_loop_level (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 ();
if (BUFFER_LIVE_P (XBUFFER (minibuf)))
Fset_buffer (minibuf);
safe_run_hooks (Qminibuffer_exit_hook);
unbind_to (count, Qnil);
}
/* This variable records the expired minibuffer's frame between the