Subject: bug#46097: 27.1; Minibuffer may not be current when running minibuffer-exit-hook

From: martin rudalics <[email-masked]>
Date: Mon, 25 Jan 2021 20:04:42 +0100

> Open the minibuffer with C-x C-f, switch to another window with C-x o
 > and abort the minibuffer with C-] (abort-recursive-edit).
 > minibuffer-exit-hook ends up running without the minibuffer being the
 > current buffer.
 >
 > This may cause problems if a minibuffer adds a cleanup function the hook
 > locally, see for example discussion at
 > https://github.com/oantolin/embark/issues/114
 > The cleanup function fails to run in this situation because the local
 > value of the hook isn't considered.

But both, current buffer and selected window, might be of interest for
the function running that hook.  So I think we should not change the
current behavior but rather document it and provide better access to
find the minibuffer that was just aborted.  The only way I found is

(window-buffer (active-minibuffer-window))

Why don't we provide a function like 'active-minibuffer'?  Or even a
function like 'minibuffer-list'?

martin