I'd like to cycle between an active minibuffer window and the last recent buffer.
1 (defun cycle-to-minibuffer-window ()
2 (interactive)
3 (when (active-minibuffer-window)
4 (if (minibuffer-window-active-p (get-buffer-window))
5 (select-window (other-buffer (current-buffer)))
6 (select-window (active-minibuffer-window)))))
7
8 (global-set-key (kbd "C-<f9>") #'cycle-to-minibuffer-window)
To bad that line 5 (other-buffer (current-buffer))
returns, in this case, the wrong buffer. :(
Which elisp construct could I use instead to get the buffer|window I wanted?
Example (tested with emacs -Q
):
- There are 3 buffers:
*scratch*
,*Messages*
and*Minibuffer-0*
. - My active buffer is
*scratch*
. I dofind-file
akaC-x C-f
. - Now pressing
C-<F9>
(calling my function), wants to switch to*Messages*
buffer, but*scratch*
buffer would be correct.