From: me--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 65719@debbugs.gnu.org
Subject: bug#65719: [PATCH] Pass restart argument to 'kill-emacs-query-functions'
Date: Sun, 03 Sep 2023 20:28:34 +0100 [thread overview]
Message-ID: <329566cab29d3bdd4cd7f2257ec9f92a@elken.dev> (raw)
[-- 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
next reply other threads:[~2023-09-03 19:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-03 19:28 me--- via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-09-04 1:01 ` bug#65719: [PATCH] Pass restart argument to 'kill-emacs-query-functions' 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=329566cab29d3bdd4cd7f2257ec9f92a@elken.dev \
--to=bug-gnu-emacs@gnu.org \
--cc=65719@debbugs.gnu.org \
--cc=me@elken.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.