Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs: Can't Kill Minibuffer

I am fairly new to emacs, and I'm having a problem with the minibuffer remaining active when I don't think it should be. I have the following mapping for 'other-window:

 (global-set-key (kbd "M-s M-s") 'other-window)

I know that this will cycle through the minibuffer if it is active, and I like that behavior. The problem is that my minibuffer keeps getting stuck in the following state:

Next element matching (regexp):

It gets in there sometimes when I am not even trying to do a regex search or even a search at all. When I hit C-g to kill it, I get the Quit message, but the minibuffer stays active and goes right back to

Next element matching (regexp): 

Also, when it is in this state, I cannot use M-s M-s to get to the next window in my frame. C-x o still seems to work though.

I also seem to be able to run other minibuffer commnands (such as file search) just fine, even when I'm stuck like this.

Is there a way that I can do one of the following:

  1. Kill the minibuffer when in that mode.
  2. Set my custom 'other-window M-s M-s function to get out of the minibuffer and on to the next window?

Either solution would be fine, though the 1st might be better since getting the minibuffer stuck may have other unexpected consequences.

like image 238
Alex Hall Avatar asked May 09 '14 16:05

Alex Hall


People also ask

How to exit minibuffer in Emacs?

The simplest way to enter a minibuffer argument is to type the text, then RET to submit the argument and exit the minibuffer. Alternatively, you can type C-g to exit the minibuffer by canceling the command asking for the argument (see Quitting and Aborting).

How to clear buffer in Emacs?

To delete a buffer, type C-x k (for kill-buffer). Emacs shows the name of the buffer currently displayed; press Enter to delete it or type another buffer name if the one being displayed is not the one you want to delete, then press Enter.

What is Emacs minibuffer?

The minibuffer is where Emacs commands read complicated arguments, such as file names, buffer names, Emacs command names, or Lisp expressions. We call it the “minibuffer” because it's a special-purpose buffer with a small amount of screen space.


1 Answers

Just do this:

(define-key minibuffer-local-map "\M-s" nil)

The problem is that M-s is locally bound in the minibuffer (in minibuffer-local-must-match-map and other minibuffer keymaps) to next-matching-history-element, which gives you that prompt and lets you search the history.

What you need to do is unbind M-s in each of the minibuffer keymaps: i.e., bind it to nil. Some of those maps inherit from others; minibuffer-local-map should take care of it, but you might want to do the same thing for minibuffer-local-ns-map. M-x apropos-variable minibuffer map tells you about all of the maps.

[You can use C-h M-k to see the bindings of any keymap, e.g., minibuffer-local-must-match-map -- it is available in library help-fns+.el.]

like image 74
Drew Avatar answered Oct 13 '22 00:10

Drew