From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#65719: [PATCH] Pass restart argument to 'kill-emacs-query-functions' Date: Fri, 8 Sep 2023 04:37:53 -0700 Message-ID: References: <329566cab29d3bdd4cd7f2257ec9f92a@elken.dev> <0817cde8dd8dab055dafe2e8aa3d30d5@elken.dev> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16687"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65719@debbugs.gnu.org To: me@elken.dev Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 08 13:39:14 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qeZpS-00047O-6b for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 08 Sep 2023 13:39:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeZpH-00020e-QB; Fri, 08 Sep 2023 07:39:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeZpE-00020I-Jw for bug-gnu-emacs@gnu.org; Fri, 08 Sep 2023 07:39:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeZpE-00005d-4C for bug-gnu-emacs@gnu.org; Fri, 08 Sep 2023 07:39:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qeZpG-0007rE-AI for bug-gnu-emacs@gnu.org; Fri, 08 Sep 2023 07:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Sep 2023 11:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65719 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65719-submit@debbugs.gnu.org id=B65719.169417308530132 (code B ref 65719); Fri, 08 Sep 2023 11:39:02 +0000 Original-Received: (at 65719) by debbugs.gnu.org; 8 Sep 2023 11:38:05 +0000 Original-Received: from localhost ([127.0.0.1]:42381 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeZoL-0007ps-05 for submit@debbugs.gnu.org; Fri, 08 Sep 2023 07:38:05 -0400 Original-Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]:53361) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qeZoI-0007pG-1G for 65719@debbugs.gnu.org; Fri, 08 Sep 2023 07:38:03 -0400 Original-Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2bb9a063f26so34324671fa.2 for <65719@debbugs.gnu.org>; Fri, 08 Sep 2023 04:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694173074; x=1694777874; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=Spaj9moJ83N/lUuXJIU14mnjYzBvaEbc4XPTc4ZU2UI=; b=aHwTw/XCo9xvZ3MIeBZn0ksVaJ05RHZ9l9NWvDdiLQ4REb/lJOuvdnV3BXrq5RbHZ5 o080pcnAFm2Th4JIQ8v5khtlXxztuFLGKsm6T9uqGatq7Pb5Vh/5NTLyOLy7VT7xGEME s5GOm0htfq303qdQ5Hj82vuwooQcotM2fIZFSxHzmaGLI2UBWB8RmhHkDFeZ4P4k3F8f 3PKh6HBo1zTKbcng/t3B/HJhv6R2LctvTv86TH6Xhn1al5EzbqlnZ7f+Hn+BGYe6/5nC HbV+MTtwu2IT78MtlQQdE/jrTYm9Irc1ENPmgfZsmycieCWjEfq8yMau12UfkGr0UdT0 MN7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694173074; x=1694777874; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Spaj9moJ83N/lUuXJIU14mnjYzBvaEbc4XPTc4ZU2UI=; b=uwE7Mup52kiWqBcPjNqGx+FhBxAeXAqYiTB9GUlCtQqy4QoMxhls4GR5tnTV0UsdJL KIpJcyIEH0WQ5igLAQWvdcjZa4qWQLpOD/gWmUk/Z2+5bU+pHcJldZomJTCzKTo1KQ5x KQNVF13xF2SNqFhK3uBLqjJJOsJNZWTT0sVrBhkUptMDAB518Z4/Nnam0JIAtTb0q95D QjE5BPCrchWvB/SlpOHidu8ekBUxgjkiR8wouft5dmQmHlSgQyAynxg3ewpAyaG6b1Sy HMdmQo08cbDOEsGskDARjlvx0m5H8AQ+KoV5eQU7iAVdD4vIPgykd+YQJdvDRyNUF+NK HQVA== X-Gm-Message-State: AOJu0YxN4h7gr2l+6hjPY8F/7mhwyg1kdChWXaWejOGouhc0RTvOxktU Z7gPZ5dtwXegVUwcdVAUY61xAZns6JpiWM9twoc= X-Google-Smtp-Source: AGHT+IG4vb/tRKDD3WnSFNmv2zAYRO7/vX5TPm54a/legdAVbGM7Q64Wzy2wd8qWc0yQ6BL3fI+xSTzuOQDg5Yzc0No= X-Received: by 2002:a2e:7813:0:b0:2be:541c:d06b with SMTP id t19-20020a2e7813000000b002be541cd06bmr1498975ljc.53.1694173073494; Fri, 08 Sep 2023 04:37:53 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 8 Sep 2023 04:37:53 -0700 In-Reply-To: <0817cde8dd8dab055dafe2e8aa3d30d5@elken.dev> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:269758 Archived-At: 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 > 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'. > + > =0C > * 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 shou= ld > @@ -8227,6 +8236,10 @@ defun save-buffers-kill-emacs > (yes-or-no-p "Active processes exist; kill t= hem 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