03/06/2008

goto-minibuffer

I almost posted this yesterday, but I got stuck trying to explain when it's useful. Every example that I came up with seemed to have a perfectly acceptable workaround.

However, after another day of emacs usage, I decided that there are indeed times when you need to move the focus to the minibuffer window. Sometimes that is easier said than done. It's especially hard if you have a lot of windows open in one frame and move around a lot, particularly when you do that in the middle of entering a command in the minibuffer.

I couldn't find anything built in that would do that. So I wrote a tiny function to handle it. Without further ado, here is some elisp to move the focus directly to the minibuffer.

(defun teds-goto-minibuffer ()
  "Move cursor to minibuffer window"
  (interactive)
  (select-window (minibuffer-window)))
(global-set-key (kbd "C-c m") 'teds-goto-minibuffer)

If you know of a simpler1 way of doing this, please let me know.


1. Hitting control-o a bunch of times doesn't count as simple. We're talking about when you have a bunch of windows open.