From 250c0c4f88f1d169415d4f6c6634e17829064746 Mon Sep 17 00:00:00 2001 From: Ellis Kenyo Date: Sun, 3 Sep 2023 20:17:21 +0100 Subject: [PATCH] Add restart argument to 'kill-emacs-query-functions' * etc/NEWS: Update NEWS file. * lisp/files.el (save-buffers-kill-emacs): Pass in the RESTART argument to subsequent hook calls. --- etc/NEWS | 7 +++++++ lisp/files.el | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index bbf4b67fe34..7273ebd2183 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -776,6 +776,13 @@ the current project. The look of the key prompt in the project switcher has been changed slightly. To get the previous one, set this option to 'brackets'. +** Files + +*** 'kill-emacs-query-functions' now takes RESTART as an argument. +Functions added to this hook can now accept an argument denoting +whether or not the call is due to call restart Emacs; if called from +say 'restart-emacs'. + * Incompatible Lisp Changes in Emacs 30.1 diff --git a/lisp/files.el b/lisp/files.el index 4188615e490..095cba693d0 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -8134,10 +8134,11 @@ defun insert-directory-safely (insert (format "%s: No such file or directory\n" file)))) (defcustom kill-emacs-query-functions nil - "Functions to call with no arguments to query about killing Emacs. -If any of these functions returns nil, killing Emacs is canceled. -`save-buffers-kill-emacs' calls these functions, but `kill-emacs', -the low level primitive, does not. See also `kill-emacs-hook'." + "Functions to call with restart status as an argument to query about +killing Emacs. If any of these functions returns nil, killing Emacs is +canceled. `save-buffers-kill-emacs' calls these functions, but +`kill-emacs',the low level primitive, does not. See also +`kill-emacs-hook'." :type 'hook :version "26.1" :group 'convenience) @@ -8228,7 +8229,7 @@ defun save-buffers-kill-emacs (when (window-live-p window) (quit-restore-window window 'kill))))))))) ;; Query the user for other things, perhaps. - (run-hook-with-args-until-failure 'kill-emacs-query-functions) + (run-hook-with-args-until-failure 'kill-emacs-query-functions restart) (or (null confirm) (funcall confirm "Really exit Emacs? ")) (kill-emacs nil restart)))) -- 2.41.0