Next: Window Parameters, Previous: Mouse Window Auto-selection, Up: Windows
A window configuration records the entire layout of one
frame—all windows, their sizes, which buffers they contain, how those
buffers are scrolled, and their value of point; also their
fringes, margins, and scroll bar settings. It also includes the value
of minibuffer-scroll-window. As a special exception, the window
configuration does not record the value of point in the selected window
for the current buffer.
You can bring back an entire frame layout by restoring a previously saved window configuration. If you want to record the layout of all frames instead of just one, use a frame configuration instead of a window configuration. See Frame Configurations.
This function returns a new object representing frame's current window configuration. The default for frame is the selected frame. The variable
window-persistent-parametersspecifies which window parameters (if any) are saved by this function. See Window Parameters.
This function restores the configuration of windows and buffers as specified by configuration, for the frame that configuration was created for.
The argument configuration must be a value that was previously returned by
current-window-configuration. The configuration is restored in the frame from which configuration was made, whether that frame is selected or not. In some rare cases this may trigger execution of thewindow-size-change-functions(see Window Hooks) even if the size of windows did not change at all. Thewindow-configuration-change-hookfunctions will be called if and only if at least one window was added to or deleted from the frame.If the frame from which configuration was saved is dead, all this function does is restore the three variables
window-min-height,window-min-widthandminibuffer-scroll-window. In this case, the function returnsnil. Otherwise, it returnst.Here is a way of using this function to get the same effect as
save-window-excursion:(let ((config (current-window-configuration))) (unwind-protect (progn (split-window-below nil) ...) (set-window-configuration config)))
This macro records the window configuration of the selected frame, executes forms in sequence, then restores the earlier window configuration. The return value is the value of the final form in forms.
Most Lisp code should not use this macro;
save-selected-windowis typically sufficient. In particular, this macro cannot reliably prevent the code in forms from opening new windows, because new windows might be opened in other frames (see Choosing Window), andsave-window-excursiononly saves and restores the window configuration on the current frame.Do not use this macro in
window-size-change-functions; exiting the macro triggers execution ofwindow-size-change-functions, leading to an endless loop.
This function returns
tif object is a window configuration.
This function compares two window configurations as regards the structure of windows, but ignores the values of point and the saved scrolling positions—it can return
teven if those aspects differ.The function
equalcan also compare two window configurations; it regards configurations as unequal if they differ in any respect, even a saved point.
This function returns the frame for which the window configuration config was made.
Other primitives to look inside of window configurations would make sense, but are not implemented because we did not need them. See the file winner.el for some more operations on windows configurations.
The objects returned by current-window-configuration die
together with the Emacs process. In order to store a window
configuration on disk and read it back in another Emacs session, you
can use the functions described next. These functions are also useful
to clone the state of a frame into an arbitrary live window
(set-window-configuration effectively clones the windows of a
frame into the root window of that very frame only).
This function returns the state of window as a Lisp object. The argument window must be a valid window and defaults to the root window of the selected frame.
If the optional argument writable is non-
nil, this means to not use markers for sampling positions likewindow-pointorwindow-start. This argument should be non-nilwhen the state will be written to disk and read back in another session.Together, the argument writable and the variable
window-persistent-parametersspecify which window parameters are saved by this function. See Window Parameters.
The value returned by window-state-get can be used in the same
session to make a clone of a window in another window. It can be also
written to disk and read back in another session. In either case, use
the following function to restore the state of the window.
This function puts the window state state into window. The argument state should be the state of a window returned by an earlier invocation of
window-state-get, see above. The optional argument window can be either a live window or an internal window (see Windows and Frames) and defaults to the selected one. If window is not live, it is replaced by a live window before putting state into it.If the optional argument ignore is non-
nil, it means to ignore minimum window sizes and fixed-size restrictions. If ignore issafe, this means windows can get as small as one line and/or two columns.
The functions window-state-get and window-state-put also
allow to exchange the contents of two live windows. The following
function does precisely that:
This command swaps the states of the two live windows window-1 and window-2. window-1 must specify a live window and defaults to the selected one. window-2 must specify a live window and defaults to the window following window-1 in the cyclic ordering of windows, excluding minibuffer windows and including live windows on all visible frames.
Optional argument size non-
nilmeans to try swapping the sizes of window-1 and window-2 as well. A value ofheightmeans to swap heights only, a value ofwidthmeans to swap widths only, whiletmeans to swap both widths and heights, if possible. Frames are not resized by this function.