bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65719: [PATCH] Pass restart argument to 'kill-emacs-query-functions'


From: Stefan Kangas
Subject: bug#65719: [PATCH] Pass restart argument to 'kill-emacs-query-functions'
Date: Fri, 8 Sep 2023 04:37:53 -0700

me@elken.dev writes:

>> One idea would be to simply introduce a new variable that takes the
>> argument, while making the old one obsolete.  That would allow people
>> to slowly migrate over to the new one, without everything suddenly
>> breaking under their feet.
>
> How does this patch sound? I think it's the best of both worlds :)

LGTM, but let's see if anyone else has any comments.

> From 7d6f5c259cefe65b5e021dacee18966acc6bc120 Mon Sep 17 00:00:00 2001
> From: Ellis Kenyo <me@elken.dev>
> Date: Mon, 4 Sep 2023 06:20:33 +0100
> Subject: [PATCH] Introduce 'restart-emacs-query-functions'
>
> * etc/NEWS: Update NEWS file.
>
> * lisp/files.el (save-buffers-kill-emacs): Add new option
> 'restart-emacs-query-functions' for functions that should be called
> when 'restart' is passed.
> ---
>  etc/NEWS      |  7 +++++++
>  lisp/files.el | 13 +++++++++++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/etc/NEWS b/etc/NEWS
> index bbf4b67fe34..95e6248c08a 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
> +
> +*** New user option 'restart-emacs-query-functions'.
> +Equivalent to 'kill-emacs-query-functions', this hook is called when
> +'save-buffers-kill-emacs' is called with the 'restart' flag; if
> +invoked from say 'M-x restart-emacs'.
> +
>  
>  * Incompatible Lisp Changes in Emacs 30.1
>
> diff --git a/lisp/files.el b/lisp/files.el
> index 4188615e490..7849d6b7c81 100644
> --- a/lisp/files.el
> +++ b/lisp/files.el
> @@ -8142,6 +8142,15 @@ defcustom kill-emacs-query-functions
>    :version "26.1"
>    :group 'convenience)
>
> +(defcustom restart-emacs-query-functions nil
> +  "Functions to call with no arguments to query about restarting
> +Emacs. If any of these functions returns nil, restarting Emacs is
> +canceled. `save-buffers-kill-emacs' calls these functions when passed
> +`restart'.  See also `kill-emacs-hook'."
> +  :type 'hook
> +  :version "30.1"
> +  :group 'convenience)
> +
>  (defcustom confirm-kill-emacs nil
>    "How to ask for confirmation when leaving Emacs.
>  If nil, the default, don't ask at all.  If the value is non-nil, it should
> @@ -8227,6 +8236,10 @@ defun save-buffers-kill-emacs
>                              (yes-or-no-p "Active processes exist; kill them 
> and exit anyway? "))
>                          (when (window-live-p window)
>                            (quit-restore-window window 'kill)))))))))
> +     ;; Only call these when restarting
> +     (when restart
> +       (run-hook-with-args-until-failure 'restart-emacs-query-functions))
> +
>       ;; Query the user for other things, perhaps.
>       (run-hook-with-args-until-failure 'kill-emacs-query-functions)
>       (or (null confirm)
> --
> 2.41.0





reply via email to

[Prev in Thread] Current Thread [Next in Thread]