2
votes

I usually work switching between several buffers; and I usually choose another buffer to move to with C-x b <name of buffer>. This is fine. But if I choose a buffer from the "Buffers" menu, then it opens in a new frame, which I don't want. How do I prevent Emacs from opening a buffer in a new frame - is this menubar behaviour, or buffers behaviour?

I'm using:

GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2014-03-08 on lamiak, modified by Debian

in Ubuntu 14.04

1
By "frame", you probably mean a "window" in Emacspeak. - choroba
What is the value of menu-bar-select-buffer-function? (Find out via C-h v menu-bar-select-buffer-function RET.) I'm running Emacs 24.3 as well, and for me it is switch-to-buffer which displays buffers in the selected window (which seems to be the behavior you want). - itsjeyd
In addition to the previous comments: Do you see this behavior when you start from emacs -Q (no init file)? If not, recursively bisect your init file until you find the culprit code. That is quick to do. That's the general way to proceed. In this case, perhaps you will discover that your init file is just setting menu-bar-select-buffer-function or something, but it is still the way to go, to find where you are shooting yourself in the foot. - Drew
Many thanks - it turns out I'd enabled menu-bar+ which redefines several variables, including menu-bar-select-buffer-function. So I redefined that variable right back with a setq statement. And now it's all fine. - Alasdair

1 Answers

1
votes

The function that is run when you click "Buffers" followed by the name of an open buffer is controlled by a variable called menu-bar-select-buffer-function. You are either modifying this variable directly in your .emacs file or you are using an add-on package that redefines it: By default, menu-bar-select-buffer-function is set to switch-to-buffer, which

Display(s) buffer BUFFER-OR-NAME in the selected window.

This seems to be the behavior you want, so adding a simple

(setq menu-bar-select-buffer-function 'switch-to-buffer)

to your .emacs file should do the trick.