Next: Convenience Features for Window Handling, Previous: Deleting and Resizing Windows, Up: Multiple Windows [Contents][Index]
It is a common Emacs operation to display or pop up some buffer in response to a user command. There are several different ways in which commands do this.
Many commands, like C-x C-f (find-file
), by default
display the buffer by “taking over” the selected window, expecting
that the user’s attention will be diverted to that buffer.
Some commands try to display intelligently, trying not to take
over the selected window, e.g., by splitting off a new window and
displaying the desired buffer there. Such commands, which include the
various help commands (see Help), work by calling
display-buffer
internally. See How display-buffer
works, for details.
Other commands do the same as display-buffer
, and
additionally select the displaying window so that you can begin
editing its buffer. The command M-g M-n (next-error
) is
one example (see Compilation Mode). Such commands work by calling
the function pop-to-buffer
internally. See Switching to a Buffer in a Window in The Emacs Lisp
Reference Manual.
Commands with names ending in -other-window
behave like
display-buffer
, except that they never display in the selected
window. Several of these commands are bound in the C-x 4 prefix
key (see Displaying in Another Window).
Commands with names ending in -other-frame
behave like
display-buffer
, except that they (i) never display in the
selected window and (ii) prefer to either create a new frame or use a
window on some other frame to display the desired buffer. Several of
these commands are bound in the C-x 5 prefix key.
Sometimes, a window is “dedicated” to its current buffer.
See Dedicated Windows in The Emacs Lisp Reference Manual.
display-buffer
will avoid reusing dedicated windows most of the
time. This is indicated by a ‘d’ in the mode line (see The Mode Line). A window can also be strongly dedicated, which prevents any
changes to the buffer displayed in the window. This is indicated by a
‘D’ in the mode line.
Usually, dedicated windows are used to display specialized buffers,
but dedication can sometimes be useful interactively. For example,
when viewing errors with M-g M-n next-error
, newly
displayed source code may replace a buffer you want to refer to. If
you dedicate a window to that buffer, the command (through
display-buffer
) will prefer to use a different window instead.
You can use the command C-x w d (toggle-window-dedicated
)
to toggle whether the selected window is dedicated to the current
buffer. With a prefix argument, it makes the window strongly dedicated.
Next: Convenience Features for Window Handling, Previous: Deleting and Resizing Windows, Up: Multiple Windows [Contents][Index]