From: Jim Porter <jporterbugs@gmail.com>
To: 58404@debbugs.gnu.org
Subject: bug#58404: 29.0.50; [PATCH] When killing Emacs from the last client, don't warn about the session having clients
Date: Sun, 9 Oct 2022 16:32:28 -0700 [thread overview]
Message-ID: <20194da7-2318-46db-7536-bbd9e3ddf945@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 988 bytes --]
To reproduce:
$ emacs -Q --daemon
$ emacsclient foo.txt
M-x save-buffers-kill-emacs
=> This Emacs session has clients; exit anyway?
I think that's unnecessary. Since we're in the last (only) client, we
can't accidentally kill other clients that we don't see right now (e.g.
ones in an SSH connection); they don't exist! Couldn't we just proceed
ahead without the prompt?
On the other hand, I think it *would* be useful to prompt if you're in
the last client, but there are other non-client frames. This can happen
if you start the main Emacs process without --daemon or if you use
--no-wait. For example:
$ emacs -Q --daemon
$ emacsclient foo.txt
$ emacsclient --no-wait -c bar.txt
;; From the first client:
M-x save-buffers-kill-emacs
=> This Emacs session has clients; exit anyway?
This is ok, except the prompt could be clearer. The real issue is that
the session has non-client frames that would get killed.
Attached is a patch to do this.
[-- Attachment #2: 0001-Don-t-prompt-when-killing-an-Emacs-client-if-it-s-th.patch --]
[-- Type: text/plain, Size: 2215 bytes --]
From 2fb6c6da99b84c250e59409d4dc0adbdbe704fed Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 9 Oct 2022 15:53:27 -0700
Subject: [PATCH] Don't prompt when killing an Emacs client if it's the last
client
* lisp/server.el (server-kill-emacs-query-function): Ignore the
current client, if any. Prompt if there are non-client frames.
---
lisp/server.el | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/lisp/server.el b/lisp/server.el
index 3caa335c4e..9ebdabbf87 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1589,14 +1589,28 @@ server-done
(server-buffer-done (current-buffer))))
(defun server-kill-emacs-query-function ()
- "Ask before exiting Emacs if it has live clients.
+ "Ask before exiting Emacs if it has other live clients or non-client frames.
A \"live client\" is a client with at least one live buffer
associated with it."
- (or (not (seq-some (lambda (proc)
- (seq-some #'buffer-live-p
- (process-get proc 'buffers)))
- server-clients))
- (yes-or-no-p "This Emacs session has clients; exit anyway? ")))
+ (let ((this-client (frame-parameter nil 'client)))
+ (if (seq-some (lambda (proc)
+ ;; Ignore the current client when checking for
+ ;; live clients.
+ (unless (eq proc this-client)
+ (seq-some #'buffer-live-p
+ (process-get proc 'buffers))))
+ server-clients)
+ (yes-or-no-p "This Emacs session has other clients; exit anyway? ")
+ (or (not (processp this-client))
+ ;; Check if there are any non-client frames, ignoring the
+ ;; initial frame when in daemon mode.
+ (>= (if (daemonp) 1 0)
+ (seq-count
+ (lambda (frame)
+ (not (processp (frame-parameter frame 'client))))
+ (frame-list)))
+ (yes-or-no-p
+ "This Emacs session has non-client frames; exit anyway? ")))))
(defun server-kill-buffer ()
"Remove the current buffer from its clients' buffer list.
--
2.25.1
next reply other threads:[~2022-10-09 23:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-09 23:32 Jim Porter [this message]
2022-10-10 6:11 ` bug#58404: 29.0.50; [PATCH] When killing Emacs from the last client, don't warn about the session having clients Eli Zaretskii
2022-10-10 8:08 ` Jim Porter
2022-10-10 8:53 ` Eli Zaretskii
2022-10-10 16:43 ` Jim Porter
2022-10-10 16:59 ` Eli Zaretskii
2022-10-10 17:49 ` Jim Porter
2022-10-10 17:57 ` Eli Zaretskii
2022-10-10 23:09 ` Jim Porter
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=20194da7-2318-46db-7536-bbd9e3ddf945@gmail.com \
--to=jporterbugs@gmail.com \
--cc=58404@debbugs.gnu.org \
/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.