all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#65719: [PATCH] Pass restart argument to 'kill-emacs-query-functions'
@ 2023-09-03 19:28 me--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-09-04  1:01 ` Stefan Kangas
  0 siblings, 1 reply; 11+ messages in thread
From: me--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-03 19:28 UTC (permalink / raw)
  To: 65719

[-- Attachment #1: Type: text/plain, Size: 538 bytes --]

Hi all,

Small change here to pass the restart status to 
'kill-emacs-query-functions' in 'save-buffers-kill-emacs' so any 
functions there can react to being restarted, sample use-case this may 
be useful is if one is using a package like perspective.el to handle 
buffer/window management and when calling `M-x restart-emacs` you WANT 
your last session to be persisted, but just starting Emacs normally you 
don't.

There are other potential use-cases for this too, so hopefully this 
patch is well-received.

Thanks all,

Ellis (@lkn)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-restart-argument-to-kill-emacs-query-functions.patch --]
[-- Type: text/x-diff; name=0001-Add-restart-argument-to-kill-emacs-query-functions.patch, Size: 2423 bytes --]

From 250c0c4f88f1d169415d4f6c6634e17829064746 Mon Sep 17 00:00:00 2001
From: Ellis Kenyo <me@elken.dev>
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'.
+
 \f
 * 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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-02-12 17:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-03 19:28 bug#65719: [PATCH] Pass restart argument to 'kill-emacs-query-functions' me--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-04  1:01 ` Stefan Kangas
2023-09-04  5:04   ` Elken via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-04  5:26   ` me--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-08 11:37     ` Stefan Kangas
2023-10-15 14:32     ` Stefan Kangas
2024-02-12 14:54       ` Ellis Kenyo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-12 15:29         ` Ellis Kenyo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-12 16:53           ` Eli Zaretskii
     [not found]             ` <E50F6DD3-D4AA-4A51-B470-ABB496F6B113@elken.dev>
2024-02-12 17:35               ` Eli Zaretskii
2024-02-12 17:52                 ` Elken via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.