diff options
| author | Lars Ingebrigtsen | 2019-08-19 19:21:53 -0700 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-08-19 19:21:53 -0700 |
| commit | afdf679841ad31664d41e7debca7083632add0f8 (patch) | |
| tree | b48578fd132805405977b812c0b17fd09044c1ac /lisp/window.el | |
| parent | 221a3272ad4a1befb41dda2990d672782bc0257f (diff) | |
| download | emacs-afdf679841ad31664d41e7debca7083632add0f8.tar.gz emacs-afdf679841ad31664d41e7debca7083632add0f8.zip | |
Add a new hook: `quit-window-hook'
* doc/lispref/windows.texi (Quitting Windows): Mention in.
* lisp/window.el (quit-restore-window): Run the new
`quit-window-hook' before doing anything else (bug#9867).
(quit-window): Note that the hook will be run in the doc string.
* lisp/window.el (quit-window-hook): New variable.
Diffstat (limited to 'lisp/window.el')
| -rw-r--r-- | lisp/window.el | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lisp/window.el b/lisp/window.el index 723671efa57..80dbd64f18a 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -4848,6 +4848,12 @@ all window-local buffer lists." | |||
| 4848 | ;; Unrecord BUFFER in WINDOW. | 4848 | ;; Unrecord BUFFER in WINDOW. |
| 4849 | (unrecord-window-buffer window buffer))))) | 4849 | (unrecord-window-buffer window buffer))))) |
| 4850 | 4850 | ||
| 4851 | (defcustom quit-window-hook nil | ||
| 4852 | "Hook run before performing any other actions in the `quit-buffer' command." | ||
| 4853 | :type 'hook | ||
| 4854 | :version "27.1" | ||
| 4855 | :group 'windows) | ||
| 4856 | |||
| 4851 | (defun quit-restore-window (&optional window bury-or-kill) | 4857 | (defun quit-restore-window (&optional window bury-or-kill) |
| 4852 | "Quit WINDOW and deal with its buffer. | 4858 | "Quit WINDOW and deal with its buffer. |
| 4853 | WINDOW must be a live window and defaults to the selected one. | 4859 | WINDOW must be a live window and defaults to the selected one. |
| @@ -4876,7 +4882,11 @@ nil means to not handle the buffer in a particular way. This | |||
| 4876 | most reliable remedy to not have `switch-to-prev-buffer' switch | 4882 | most reliable remedy to not have `switch-to-prev-buffer' switch |
| 4877 | to this buffer again without killing the buffer. | 4883 | to this buffer again without killing the buffer. |
| 4878 | 4884 | ||
| 4879 | `kill' means to kill WINDOW's buffer." | 4885 | `kill' means to kill WINDOW's buffer. |
| 4886 | |||
| 4887 | The functions in `quit-window-hook' will be run before doing | ||
| 4888 | anything else." | ||
| 4889 | (run-hooks 'quit-window-hook) | ||
| 4880 | (setq window (window-normalize-window window t)) | 4890 | (setq window (window-normalize-window window t)) |
| 4881 | (let* ((buffer (window-buffer window)) | 4891 | (let* ((buffer (window-buffer window)) |
| 4882 | (quit-restore (window-parameter window 'quit-restore)) | 4892 | (quit-restore (window-parameter window 'quit-restore)) |
| @@ -4971,7 +4981,10 @@ According to information stored in WINDOW's `quit-restore' window | |||
| 4971 | parameter either (1) delete WINDOW and its frame, (2) delete | 4981 | parameter either (1) delete WINDOW and its frame, (2) delete |
| 4972 | WINDOW, (3) restore the buffer previously displayed in WINDOW, | 4982 | WINDOW, (3) restore the buffer previously displayed in WINDOW, |
| 4973 | or (4) make WINDOW display some other buffer than the present | 4983 | or (4) make WINDOW display some other buffer than the present |
| 4974 | one. If non-nil, reset `quit-restore' parameter to nil." | 4984 | one. If non-nil, reset `quit-restore' parameter to nil. |
| 4985 | |||
| 4986 | The functions in `quit-window-hook' will be run before doing | ||
| 4987 | anything else." | ||
| 4975 | (interactive "P") | 4988 | (interactive "P") |
| 4976 | (quit-restore-window window (if kill 'kill 'bury))) | 4989 | (quit-restore-window window (if kill 'kill 'bury))) |
| 4977 | 4990 | ||