ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial
Web Hosting by 1&1

28.6 Buffers and Windows

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.

— Function: set-window-buffer window buffer-or-name &optional keep-margins

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-buffer is 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")
               ⇒ nil

Normally, 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-buffer signals 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-functions before running window-configuration-change-hook.

— Variable: buffer-display-count

This buffer-local variable records the number of times a buffer has been displayed in a window. It is incremented each time set-window-buffer is called for the buffer.

— Function: window-buffer &optional window

This function returns the buffer that window is displaying. The default for window is the selected window.

          (window-buffer)
               ⇒ #<buffer windows.texi>
— Function: get-buffer-window &optional buffer-or-name all-frames

This function returns a window currently displaying buffer-or-name, or nil if 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:

Observe that the behavior of get-buffer-window may differ from that of next-window (see Cyclic Window Ordering) when all-frames equals nil or any value not listed here. Perhaps we will change get-buffer-window in the future to make it compatible with the other functions.

— Function: get-buffer-window-list &optional buffer-or-name minibuf all-frames

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 of get-buffer-window.

— Variable: buffer-display-time

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-buffer is called, it sets this variable to (current-time) in the specified buffer (see Time of Day). When a buffer is first created, buffer-display-time starts out with the value nil.

blog comments powered by Disqus