Next: , Previous: Splitting Windows, Up: Windows

28.6 Deleting Windows

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).

— Command: delete-window &optional window

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), an error is signaled.

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 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. Otherwise, this function obeys the window-atom or window-side window parameter, if any. See Window Parameters.

— Command: delete-other-windows &optional window

This function makes window fill its frame, by deleting other windows as necessary. If window is omitted or nil, it defaults to the selected window. 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. Otherwise, this function obeys the window-atom or window-side window parameter, if any. See Window Parameters.

— Command: delete-windows-on &optional buffer-or-name frame

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:

Note that this argument does not have the same meaning as in other functions which scan all live windows (see Cyclic Window Ordering). Specifically, the meanings of t and nil here are the opposite of what they are in those other functions.