From: Stefan Monnier Date: Sun, 22 May 2022 14:35:02 +0000 (-0400) Subject: Run `minibuffer-exit-hook` in the right buffer X-Git-Tag: emacs-29.0.90~1910^2~521 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cc878319f911a63eaab9b8382d38671b67d8abf9;p=emacs.git 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. --- diff --git a/src/minibuf.c b/src/minibuf.c index df82bcb121a..3f06ce7e0e3 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -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