Next: Change Window, Previous: Pop Up Window, Up: Windows
Certain Emacs commands switch to a specific buffer with special contents. For example, M-x shell switches to a buffer named ‘*shell*’. By convention, all these commands are written to pop up the buffer in a separate window. But you can specify that certain of these buffers should appear in the selected window.
If you add a buffer name to the list same-window-buffer-names
,
the effect is that such commands display that particular buffer by
switching to it in the selected window. For example, if you add the
element "*grep*"
to the list, the grep
command will
display its output buffer in the selected window.
The default value of same-window-buffer-names
is not
nil
: it specifies buffer names ‘*info*’, ‘*mail*’ and
‘*shell*’ (as well as others used by more obscure Emacs packages).
This is why M-x shell normally switches to the ‘*shell*’
buffer in the selected window. If you delete this element from the
value of same-window-buffer-names
, the behavior of M-x
shell will change—it will pop up the buffer in another window
instead.
You can specify these buffers more generally with the variable
same-window-regexps
. Set it to a list of regular expressions;
then any buffer whose name matches one of those regular expressions is
displayed by switching to it in the selected window. (Once again, this
applies only to buffers that normally get displayed for you in a
separate window.) The default value of this variable specifies Telnet
and rlogin buffers.
An analogous feature lets you specify buffers which should be displayed in their own individual frames. See Special Buffer Frames.