Deleting a window removes it from the frame’s window tree. If the window is a live window, it disappears from the screen. If the window is an internal window, its child windows are deleted too.
Even after a window is deleted, it continues to exist as a Lisp object, until there are no more references to it. Window deletion can be reversed, by restoring a saved window configuration (see Window Configurations).
This function removes window from display and returns
nil. If window is omitted or nil, it defaults to
the selected window.
If deleting the window would leave no more windows in the window tree (e.g., if it is the only live window in the frame) or all remaining windows on window’s frame are side windows (see Side Windows), an error is signaled. If window is part of an atomic window (see Atomic Windows), this function tries to delete the root of that atomic window instead.
By default, the space taken up by window is given to one of its
adjacent sibling windows, if any. However, if the variable
window-combination-resize is non-nil, the space is
proportionally distributed among any remaining windows in the same
window combination. See Recombining Windows.
The behavior of this function may be altered by the window parameters of
window, so long as the variable ignore-window-parameters is
nil. If the value of the delete-window window parameter
is t, this function ignores all other window parameters.
Otherwise, if the value of the delete-window window parameter is
a function, that function is called with the argument window, in
lieu of the usual action of delete-window. See Window Parameters.
When delete-window deletes the selected window of its frame, it
has to make another window the new selected window of that frame. The
following option allows configuring which window is chosen.
This option allows specifying which window should become a frame’s
selected window after delete-window has deleted the previously
selected one. Possible choices are
mru
(the default) choose the most recently used window on that frame.
pos
choose the window comprising the frame coordinates of point of the
previously selected window on that frame.
nil
choose the first window (the window returned by
frame-first-window) on that frame.
A window for which window-no-other-p (see Cyclic Ordering of Windows) returns non-nil is chosen only if all other windows on
that frame have their no-other-window parameter set to a
non-nil value too.
This function makes window fill its frame, deleting other
windows as necessary. If window is omitted or nil, it
defaults to the selected window. An error is signaled if window
is a side window (see Side Windows). If window is part of
an atomic window (see Atomic Windows), this function tries to make
the root of that atomic window fill its frame. The return
value is nil.
The behavior of this function may be altered by the window parameters of
window, so long as the variable ignore-window-parameters is
nil. If the value of the delete-other-windows window
parameter is t, this function ignores all other window
parameters. Otherwise, if the value of the delete-other-windows
window parameter is a function, that function is called with the
argument window, in lieu of the usual action of
delete-other-windows. See Window Parameters.
Also, if ignore-window-parameters is nil, this function
does not delete any window whose no-delete-other-windows
parameter is non-nil.
This function deletes all windows showing buffer-or-name, by
calling delete-window on those windows. buffer-or-name
should be a buffer, or the name of a buffer; if omitted or nil,
it defaults to the current buffer. If there are no windows showing
the specified buffer, this function does nothing. If the specified
buffer is a minibuffer, an error is signaled.
If there is a dedicated window showing the buffer, and that window is the only one on its frame, this function also deletes that frame if it is not the only frame on the terminal.
The optional argument frame specifies which frames to operate on:
nil
means operate on all frames.
t
means operate on the selected frame.
visible
means operate on all visible frames.
0
means operate on all visible or iconified frames.
Note that this argument does not have the same meaning as in other
functions which scan all live windows (see Cyclic Ordering of Windows). Specifically, the meanings of t and nil here
are the opposite of what they are in those other functions.
The above commands delete windows explicitly. However, Emacs may also
delete a window implicitly when it thinks that it’s more intuitive to
eliminate it rather than showing some unrelated buffer in it. Functions
that may delete windows implicitly are kill-buffer
(see Killing Buffers), quit-restore-window (see Quitting Windows) and bury-buffer (see The Buffer List). Some of these
delete a window if and only if that window is dedicated to its buffer
(see Dedicated Windows). Others delete a window when that window
has been created by display-buffer (see Displaying a Buffer in a Suitable Window).
Some will also try to delete a window’s frame together with the window,
provided there are other frames on the same terminal and the frame does
not host the active minibuffer window.
The hook described next can be used to avoid that a window gets deleted by these functions.
This is an abnormal hook that can be used to avoid that a window gets
deleted implicitly. The value should be a list of functions that take
two arguments. The first argument is the window about to be deleted.
The second argument, if non-nil, means that the window is the
only window on its frame and would be deleted together with its frame.
The window’s buffer is current when running this hook.
If any of these functions returns nil, the window will not be
deleted and another buffer will be shown in it. This hook is run
(indirectly) by the functions quit-restore-window,
kill-buffer and bury-buffer. It is not run by functions
that delete windows explicitly like delete-window,
delete-other-windows or delete-windows-on.
The purpose of this hook is to give its clients a chance to save a window or its frame from deletion because they might still want to use that window or frame for their own purposes.