How can I prevent the mini-buffer from displaying previous commands in Emacs?
Asked Answered
H

2

11

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:

alt text

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?

Hagi answered 11/6, 2010 at 12:58 Comment(1)
You are in (two levels of) recursive edit, as can be seen by the [[..]] around the parentheses that surround the mode names. You can abort the recursive edit by using 'C-]'. See cs.cmu.edu/cgi-bin/info2www?(emacs)Recursive%20Edit for more info.Shawana
U
11

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.

Universalism answered 11/6, 2010 at 13:2 Comment(1)
Oh, so it was like an unfinished command? I did the C-x o and had to finish all that stream of commands (to insert an environment in latex, put label, position, etc) so that the thing would disappear. Thanks for that!Hagi
R
20

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.

Remunerate answered 11/6, 2010 at 15:25 Comment(8)
Quite possible I did that... I am trying though not to use the mouse, so hopefully I this command will be redundant soon. Does this happen when I use ** C-x b ** as well? By the way, I prefer the code you put on the answer to a superuser question and linked in a comment to your blog post :) (the one which gives a key binding to go to the active minibuffer window)Hagi
@Hagi Ahhh... right the SU answer. I am not so happy how SO and SU split the Emacs questions. I'll link that one as well in this answer.Remunerate
This can happen if you start a command and get an error condition. The trick to get focus into the mini-buffer and then Ctrl-G to abort will fix it.Tahsildar
why do you need to check the recursion depth?Home
also, is there an equivalent that would work if something other than the mouse changed the focus?Home
@fommil, I think the recursion depth check is because this is going to be triggered every time there is a click, so you want to check you are in the mini-buffer and not try to cancel it if you're not there. I don't know the answer to your other question, but I bet it it "yes".Nonu
@Home - Gordon is correct, it's to avoid an error message from Emacs telling you "No recursive edit is in progress"Remunerate
@TreyJackson: This does not work when I move around splitted windows in the terminalLisalisabet
U
11

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.

Universalism answered 11/6, 2010 at 13:2 Comment(1)
Oh, so it was like an unfinished command? I did the C-x o and had to finish all that stream of commands (to insert an environment in latex, put label, position, etc) so that the thing would disappear. Thanks for that!Hagi

© 2022 - 2024 — McMap. All rights reserved.