Simply checking the buffer-list is not enough, because an interactive command can be invoked via various ways, not just directly or via M-x. E.g. if you invoke it via a Helm-like selector package which creates various buffers for selection then the buffer list is affected.
Is there a reliable way to determine the origin buffer of a command which uses the minibuffer for input?
current-buffer
provide it?ivy
) calling the following command:(defun test (dir) (interactive "D") (print (current-buffer)))
, it printed the buffer from where I invokedivy-switch-buffer
, instead of the minibuffer. I remember something thathelm
does not use the minibuffer, which could be relevent (or not)... (I can not get the code block formatted 'correctly' here in the comments)minibuffer-setup-hook
which is called when the cursor is in the minibuffer.