On Thu, Feb 14, 2019 at 08:10:54AM +0100, Marcin Borkowski wrote: > Hi all, > > I am writing an interactive command to be used while in the minibuffer. > I need to know the buffer I was in when I issued the command that put me > in the minibuffer (like M-: or M-!). I tried (other-buffer > (current-buffer)) and (last-buffer (current-buffer)), but to no avail. > Then I re-read the docs for `other-buffer' and used this: (other-buffer > (current-buffer) t), and it seemed to work. The question is, how > reliable it is. Am I doing this correctly? There's also minibuffer-selected-window (Emacs 27.0.50 here): minibuffer-selected-window is a built-in function in ‘C source code’. (minibuffer-selected-window) Return window selected just before minibuffer window was selected. Return nil if the selected window is not a minibuffer window. This function does not change global state, including the match data. HTH -- tomás