Reputation: 4218
I am not even sure this is a previous command or a non-finished command or whatever, but I do know I really don't like it.
My problem is that some commands (or messages, or whatever) get stuck in the mini-buffer so that when I type a new command it appears there really quickly, and then the mini-buffer is back to the stubborn command. Some commands seem to be chosen, and after using lots of commands something else gets stuck there, but there is always something being shown that I don't want to see. I tried typing C-g lots of times to see if it would quit, but that does not work.
This is a picture of what I have now:
It does not matter what I do, that bit
Label: hl-line
will not leave. It does leave momentarily when a new command is typed, but it goes back. I don't like it, it is confusing, and I would much rather see there the last used command.
I did check the customisation options for the mini-buffer (the bottom part of it can be seen in my picture), but I found nothing that seemed to be what I was looking for.
Any ideas?
Upvotes: 10
Views: 1916
Reputation: 327
Similar to the other answers, I often find myself in this situation when I've changed focus out of the Minibuffer a while ago and not noticed that it's still active.
My somewhat heavy-handed approach, inspired by Trey's answer, is to have C-g
always abort the minibuffer - even if the minibuffer is not focused.
(defun keyboard-quit-minibuffer-aware ()
"Abort minibuffer if it's open (even if unfocused), otherwise send keyboard-quit"
(interactive)
(if (active-minibuffer-window)
(abort-recursive-edit)
(keyboard-quit)))
(global-set-key (kbd "C-g") 'keyboard-quit-minibuffer-aware)
I think this may also cause emacs to abort a recursive edit early (i.e. if you have a recurse edit going and then you've opened the minibuffer and then type C-g
into it you might lose the edit). On balance I find this much less frustrating than mashing C-g
a few times before realising I have to switch focus to the Minibuffer window before pressing C-g
one more time and then going back to whatever I was trying to do before.
Upvotes: 0
Reputation: 74440
Chances are you're getting into the situation because you started a command and used your mouse to select something in a different window. If that's the case, you can have Emacs automatically abort the command when you do such an action.
This is the code you'd add to your .emacs:
(defun stop-using-minibuffer ()
"kill the minibuffer"
(when (and (>= (recursion-depth) 1) (active-minibuffer-window))
(abort-recursive-edit)))
(add-hook 'mouse-leave-buffer-hook 'stop-using-minibuffer)
Note: I grabbed this from my blog post on the topic.
And there is also a super user question that addresses this issue, and my answer there provides a command to jump back to the minibuffer.
Upvotes: 20
Reputation: 27184
The mini-buffer has lost focus. Try C-x o (Control+x o) to regain focus. To cancel the command press C-g when you have focus in the mini-buffer.
Upvotes: 11