This section describes low-level functions to examine windows or to display buffers in windows in a precisely controlled fashion. See Displaying Buffers, for related functions that find a window to use and specify a buffer for it. The functions described there are easier to use, but they employ heuristics in choosing or creating a window; use the functions described here when you need complete control.
This function makes window display buffer-or-name as its contents. It returns
nil. The default for window is the selected window. The argument buffer-or-name must specify a buffer or the name of an existing buffer.
set-window-bufferis the fundamental primitive for changing which buffer is displayed in a window, and all ways of doing that call this function.(set-window-buffer (selected-window) "foo") ⇒ nilNormally, displaying buffer-or-name in window resets the window's position, display margins, fringe widths, and scroll bar settings based on the local variables of that buffer. However, if keep-margins is non-
nil, display margins and fringe widths of window remain unchanged. See Fringes.
set-window-buffersignals an error when window is strongly dedicated to its buffer (see Dedicated Windows) and does not already display buffer-or-name.Note that this function runs
window-scroll-functionsbefore runningwindow-configuration-change-hook.
This buffer-local variable records the number of times a buffer has been displayed in a window. It is incremented each time
set-window-bufferis called for the buffer.
This function returns the buffer that window is displaying. The default for window is the selected window.
(window-buffer) ⇒ #<buffer windows.texi>
This function returns a window currently displaying buffer-or-name, or
nilif there is none. If there are several such windows, then the function returns the first one in the cyclic ordering of windows, starting from the selected window. See Cyclic Window Ordering.The argument BUFFER-OR-NAME may be a buffer or a buffer name and defaults to the current buffer. The optional argument all-frames specifies which windows to consider:
nilmeans consider windows on the selected frame.tmeans consider windows on all existing frames.visiblemeans consider windows on all visible frames.- 0 means consider windows on all visible or iconified frames.
- A frame means consider windows on that frame only.
Observe that the behavior of
get-buffer-windowmay differ from that ofnext-window(see Cyclic Window Ordering) when all-frames equalsnilor any value not listed here. Perhaps we will changeget-buffer-windowin the future to make it compatible with the other functions.
This function returns a list of all windows currently displaying buffer-or-name. The argument buffer-or-name may be a buffer or the name of an existing buffer and defaults to the current buffer.
The two remaining arguments work like the same-named arguments of
next-window; they are not like the optional arguments ofget-buffer-window.
This variable records the time at which a buffer was last made visible in a window. It is always local in each buffer; each time
set-window-bufferis called, it sets this variable to(current-time)in the specified buffer (see Time of Day). When a buffer is first created,buffer-display-timestarts out with the valuenil.