elements of the list specified by @var{window}'s @code{quit-restore}
parameter (@pxref{Window Parameters}).
+@vindex quit-window-hook
+The functions in @code{quit-window-hook} are run before doing anything
+else.
+
The first element of the @code{quit-restore} parameter is one of the
symbols @code{window}, meaning that the window has been specially
created by @code{display-buffer}; @code{frame}, a separate frame has
\f
* Lisp Changes in Emacs 27.1
++++
+** The new 'quit-window-hook' is now run first when executing the
+'quit-window' command.
+
** The variables 'help-enable-completion-auto-load',
'help-enable-auto-load' and 'vhdl-project-auto-load', as well as the
'vhdl-auto-load-project' have been renamed to have "autoload" without
;; Unrecord BUFFER in WINDOW.
(unrecord-window-buffer window buffer)))))
+(defcustom quit-window-hook nil
+ "Hook run before performing any other actions in the `quit-buffer' command."
+ :type 'hook
+ :version "27.1"
+ :group 'windows)
+
(defun quit-restore-window (&optional window bury-or-kill)
"Quit WINDOW and deal with its buffer.
WINDOW must be a live window and defaults to the selected one.
most reliable remedy to not have `switch-to-prev-buffer' switch
to this buffer again without killing the buffer.
-`kill' means to kill WINDOW's buffer."
+`kill' means to kill WINDOW's buffer.
+
+The functions in `quit-window-hook' will be run before doing
+anything else."
+ (run-hooks 'quit-window-hook)
(setq window (window-normalize-window window t))
(let* ((buffer (window-buffer window))
(quit-restore (window-parameter window 'quit-restore))
parameter either (1) delete WINDOW and its frame, (2) delete
WINDOW, (3) restore the buffer previously displayed in WINDOW,
or (4) make WINDOW display some other buffer than the present
-one. If non-nil, reset `quit-restore' parameter to nil."
+one. If non-nil, reset `quit-restore' parameter to nil.
+
+The functions in `quit-window-hook' will be run before doing
+anything else."
(interactive "P")
(quit-restore-window window (if kill 'kill 'bury)))