Next: Buffer Display Action Alists, Previous: Choosing Window, Up: Displaying Buffers
An action function is a function display-buffer calls for
choosing a window to display a buffer. Action functions take two
arguments: buffer, the buffer to display, and alist, an
action alist (see Buffer Display Action Alists). They are
supposed to return a window displaying buffer if they succeed
and nil if they fail.
The following basic action functions are defined in Emacs.
This function tries to display buffer in the selected window. It fails if the selected window is a minibuffer window or is dedicated to another buffer (see Dedicated Windows). It also fails if alist has a non-
nilinhibit-same-windowentry.
This function tries to display buffer by finding a window that is already displaying it.
If alist has a non-
nilinhibit-same-windowentry, the selected window is not eligible for reuse. The set of frames to search for a window already displaying buffer can be specified with the help of thereusable-framesaction alist entry. If alist contains noreusable-framesentry, this function searches just the selected frame.If this function chooses a window on another frame, it makes that frame visible and, unless alist contains an
inhibit-switch-frameentry, raises that frame if necessary.
This function tries to display buffer by finding a window that is displaying a buffer in a given mode.
If alist contains a
modeentry, its value specifes a major mode (a symbol) or a list of major modes. If alist contains nomodeentry, the current major mode of buffer is used instead. A window is a candidate if it displays a buffer whose mode derives from one of the modes specified thusly.The behavior is also controlled by alist entries for
inhibit-same-window,reusable-framesandinhibit-switch-frame, likedisplay-buffer-reuse-windowdoes.
This function tries to display buffer by splitting the largest or least recently-used window (usually located on the selected frame). It actually performs the split by calling the function specified by
split-window-preferred-function(see Choosing Window Options).The size of the new window can be adjusted by supplying
window-heightandwindow-widthentries in alist. If alist contains apreserve-sizeentry, Emacs will also try to preserve the size of the new window during future resize operations (see Preserving Window Sizes).This function fails if no window can be split. More often than not, this happens because no window is large enough to allow splitting. Setting
split-height-thresholdorsplit-width-thresholdto lower values may help in this regard. Splitting also fails when the selected frame has anunsplittableframe parameter; see Buffer Parameters.
This function tries to display buffer in a window where it was displayed previously.
If alist contains a non-
nilinhibit-same-windowentry, the selected window is not eligible for use. A dedicated window is usable only if it already shows buffer. If alist contains aprevious-windowentry, the window specified by that entry is usable even if it never showed buffer before.If alist contains a
reusable-framesentry (see Buffer Display Action Alists), its value determines which frames to search for a suitable window. If alist contains noreusable-framesentry, this function searches just the selected frame ifdisplay-buffer-reuse-framesandpop-up-framesare bothnil; it searches all frames on the current terminal if either of those variables is non-nil.If more than one window qualifies as usable according to these rules, this function makes a choice in the following order of preference:
- The window specified by any
previous-windowalist entry, provided it is not the selected window.- A window that showed buffer before, provided it is not the selected window.
- The selected window if it is either specified by a
previous-windowalist entry or showed buffer before.
This function tries to display buffer by choosing an existing window and displaying the buffer in that window. It can fail if all windows are dedicated to other buffers (see Dedicated Windows).
This function tries to display buffer in a window below the selected window. If there is a window below the selected one and that window already displays buffer, it reuses that window.
If there is no such window, this function tries to create a new window by splitting the selected one, and displays buffer there. It will also try to adjust that window's size provided alist contains a suitable
window-heightorwindow-widthentry, see above.If splitting the selected window fails and there is a non-dedicated window below the selected one showing some other buffer, this function tries to use that window for showing buffer.
This function tries to display buffer in a window at the bottom of the selected frame.
This either tries to split the window at the bottom of the frame or the frame's root window, or to reuse an existing window at the bottom of the selected frame.
This function creates a new frame, and displays the buffer in that frame's window. It actually performs the frame creation by calling the function specified in
pop-up-frame-function(see Choosing Window Options). If alist contains apop-up-frame-parametersentry, the associated value is added to the newly created frame's parameters.
This function tries to display buffer in a child frame (see Child Frames) of the selected frame, either reusing an existing child frame or by making a new one. If alist has a non-
nilchild-frame-parametersentry, the corresponding value is an alist of frame parameters to give the new frame. Aparent-frameparameter specifying the selected frame is provided by default. If the child frame should become the child of another frame, a corresponding entry must be added to alist.The appearance of child frames is largely dependent on the parameters provided via alist. It is advisable to use at least ratios to specify the size (see Size Parameters) and the position (see Position Parameters) of the child frame, and to add a
keep-ratioparameter (see Frame Interaction Parameters), in order to make sure that the child frame remains visible. For other parameters that should be considered see Child Frames.
This function tries to display buffer by finding a frame that meets a predicate (by default any frame other than the selected frame).
If this function chooses a window on another frame, it makes that frame visible and, unless alist contains an
inhibit-switch-frameentry, raises that frame if necessary.If alist has a non-
nilframe-predicateentry, its value is a function taking one argument (a frame), returning non-nilif the frame is a candidate; this function replaces the default predicate.If alist has a non-
nilinhibit-same-windowentry, the selected window is not used; thus if the selected frame has a single window, it is not used.
If alist has a non-
nilallow-no-windowentry, then this function does not display buffer and returns the symbolfail. This constitutes the only exception to the convention that an action function returns eithernilor a window showing buffer. If alist has no suchallow-no-windowentry, this function returnsnil.If this function returns
fail,display-bufferwill skip the execution of any further display actions and returnnilimmediately. If this function returnsnil,display-bufferwill continue with the next display action, if any.It is assumed that when a caller of
display-bufferspecifies a non-nilallow-no-windowentry, it is also able to handle anilreturn value.
Two other action functions are described in their proper
sections—display-buffer-in-side-window (see Displaying Buffers in Side Windows) and display-buffer-in-atom-window
(see Atomic Windows).