20.6 Displaying a Buffer in a Window
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 Window Choice, 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 Pop Up 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.
• Window Choice |   | How display-buffer works. |
• Temporary Displays |   | Displaying non-editable buffers. |