GNU bug report logs -
#58404
29.0.50; [PATCH] When killing Emacs from the last client, don't warn about the session having clients
Previous Next
Reported by: Jim Porter <jporterbugs <at> gmail.com>
Date: Sun, 9 Oct 2022 23:33:01 UTC
Severity: normal
Tags: patch
Found in version 29.0.50
Done: Jim Porter <jporterbugs <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58404 in the body.
You can then email your comments to 58404 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58404
; Package
emacs
.
(Sun, 09 Oct 2022 23:33:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Jim Porter <jporterbugs <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 09 Oct 2022 23:33:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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.
[0001-Don-t-prompt-when-killing-an-Emacs-client-if-it-s-th.patch (text/plain, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58404
; Package
emacs
.
(Mon, 10 Oct 2022 06:12:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 58404 <at> debbugs.gnu.org (full text, mbox):
> Date: Sun, 9 Oct 2022 16:32:28 -0700
> From: Jim Porter <jporterbugs <at> gmail.com>
>
> 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.
IMO, this is an unnecessary annoyance. We don't by default ask the
user any questions today, when they want to kill an Emacs session.
Why should we change that in this case? What is the use case where
this command could be invoked by mistake and will risk losing edits or
other valuable work?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58404
; Package
emacs
.
(Mon, 10 Oct 2022 08:09:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 58404 <at> debbugs.gnu.org (full text, mbox):
On 10/9/2022 11:11 PM, Eli Zaretskii wrote:
> IMO, this is an unnecessary annoyance. We don't by default ask the
> user any questions today, when they want to kill an Emacs session.
But Emacs *does* prompt the user today. If you call
'save-buffers-kill-emacs' from an emacsclient frame, it will (almost)
always ask you, "This Emacs session has clients; exit anyway?" My patch
just gets rid of that annoyance when we can be sure it's unnecessary
(i.e. it won't ask if there are no other emacsclients and no other
frames not owned by a client).
The patch does also change the prompt to be more-precise when there is
an open frame not owned by a client[1]. However, it doesn't add any new
prompts where there were none before; it only removes a prompt in one case.
> What is the use case where this command could be invoked by mistake
> and will risk losing edits or other valuable work?
I didn't write this code initially, but here's my understanding of why
the prompt is useful.
If you use "emacs --daemon", 'C-x C-c' ('save-buffers-kill-terminal')
will only close the current emacsclient, not shut down the daemon
entirely. If you'd like to shut down the daemon too, you can call
'save-buffers-kill-emacs' instead. Maybe you'd even bind that to a key
combo or do it automatically in some cases.
So given the above, imagine you're at the office. You start the Emacs
daemon and connect a GUI emacsclient instance[2]. Then you do a bunch of
work until it's time to go home, but you leave your emacsclient running
to pick up where you left off the next day.
When you get home, you remember that you wanted to edit something
quickly, so you SSH into you work computer and start a second
emacsclient instance. By now, you forgot about your first emacsclient
instance you made while at work. If you call 'save-buffers-kill-emacs'
from your SSH emacsclient, it's nice that it can remind you that you
have another emacsclient instance still running: since you don't see the
GUI frames for the other client, it would be easy to forget about them
and kill the session entirely. Then when you go into work the next day,
the buffers you had open yesterday would be gone.
In this case, you likely haven't lost changes to any files, since you
saved before killing the session, but you'd lose non-file buffers,
window configuration, etc. (Of course, this assumes you're not using
desktop.el.)
As for the code I added to check for non-client frames, the story is
pretty much the same, although that code is there to handle situations
where users start Emacs normally (i.e. by running "emacs") and then
start the Emacs server via '(server-start)'. When connecting to that
Emacs session remotely, it would be useful to get a prompt for the same
reasons above. The only difference is that the GUI frames on your work
system are "non-client" frames, so the code checks for them in a
different way.
[1] Excluding the initial frame for "emacs --daemon", that is.
[2] This could be as simple as clicking the "Emacs (client)" icon on
your desktop.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58404
; Package
emacs
.
(Mon, 10 Oct 2022 08:54:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 58404 <at> debbugs.gnu.org (full text, mbox):
> Date: Mon, 10 Oct 2022 01:08:17 -0700
> Cc: 58404 <at> debbugs.gnu.org
> From: Jim Porter <jporterbugs <at> gmail.com>
>
> On 10/9/2022 11:11 PM, Eli Zaretskii wrote:
> > IMO, this is an unnecessary annoyance. We don't by default ask the
> > user any questions today, when they want to kill an Emacs session.
>
> But Emacs *does* prompt the user today. If you call
> 'save-buffers-kill-emacs' from an emacsclient frame, it will (almost)
> always ask you, "This Emacs session has clients; exit anyway?" My patch
> just gets rid of that annoyance when we can be sure it's unnecessary
> (i.e. it won't ask if there are no other emacsclients and no other
> frames not owned by a client).
It is okay not to prompt when there's no need. That wasn't the part
on which I commented, AFAIU.
You said:
> 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.
I'm saying that no, it will not be useful to prompt in that case: if
the only frames left are non-client frames, we should not prompt,
because we don't prompt when there are no client frames to begin with.
Apologies if I misunderstood the use case.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58404
; Package
emacs
.
(Mon, 10 Oct 2022 16:45:03 GMT)
Full text and
rfc822 format available.
Message #17 received at 58404 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 10/10/2022 1:53 AM, Eli Zaretskii wrote:
> It is okay not to prompt when there's no need. That wasn't the part
> on which I commented, AFAIU.
>
> You said:
>
>> 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.
>
> I'm saying that no, it will not be useful to prompt in that case: if
> the only frames left are non-client frames, we should not prompt,
> because we don't prompt when there are no client frames to begin with.
> Apologies if I misunderstood the use case.
Ah, I see. In that part of my original message, I wanted to say that
this was a case where I thought the old code made sense, since it
prompts the user then. However, I also thought that the prompt message
could be more informative.
Here's why I think prompting then makes sense: when you're in an
emacsclient frame and there are other non-client frames (i.e. ones
"owned" by the main Emacs process), that looks very similar to the user
as when you have a second emacsclient running. In other words, I think
it would be good for this function to prompt when doing this:
$ emacs -Q --daemon
$ emacsclient foo.txt
$ emacsclient -c bar.txt
;; From either frame:
M-x save-buffers-kill-emacs
Or this:
$ emacs -Q --daemon
$ emacsclient foo.txt
$ emacsclient --no-wait -c bar.txt
;; From either frame:
M-x save-buffers-kill-emacs
Or this:
$ emacs foo.txt
M-x server-start
$ emacsclient -c bar.txt
;; From either frame:
M-x save-buffers-kill-emacs
In all of those cases, the user would have 2 (visible) frames, possibly
on different displays/terminals. Since they're visually similar, I think
it makes sense to have similar prompts.
Next, if the user ran 'save-buffers-kill-emacs' a second time in any of
those examples, it *wouldn't* prompt, since then all the remaining
frames are associated with a single emacsclient (or no client at all).
Since the use case for this is non-obvious (it actually took me several
iterations to identify all the possible cases), I updated my patch with
clearer (to me) code, plus comments explaining the reasoning.
[0001-Don-t-prompt-when-killing-an-Emacs-client-if-it-s-th.patch (text/plain, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58404
; Package
emacs
.
(Mon, 10 Oct 2022 17:00:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 58404 <at> debbugs.gnu.org (full text, mbox):
> Date: Mon, 10 Oct 2022 09:43:55 -0700
> Cc: 58404 <at> debbugs.gnu.org
> From: Jim Porter <jporterbugs <at> gmail.com>
>
> Here's why I think prompting then makes sense: when you're in an
> emacsclient frame and there are other non-client frames (i.e. ones
> "owned" by the main Emacs process), that looks very similar to the user
> as when you have a second emacsclient running.
No, there's a very fundamental difference between the two. When there
are client frames showing buffers, for each client buffer there's a
process waiting, the process which requested the buffer to be edited.
That's why we prompt: we don't want to fail those waiting processes.
Non-client frames don't have this problem.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58404
; Package
emacs
.
(Mon, 10 Oct 2022 17:50:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 58404 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 10/10/2022 9:59 AM, Eli Zaretskii wrote:
>> Date: Mon, 10 Oct 2022 09:43:55 -0700
>> Cc: 58404 <at> debbugs.gnu.org
>> From: Jim Porter <jporterbugs <at> gmail.com>
>>
>> Here's why I think prompting then makes sense: when you're in an
>> emacsclient frame and there are other non-client frames (i.e. ones
>> "owned" by the main Emacs process), that looks very similar to the user
>> as when you have a second emacsclient running.
>
> No, there's a very fundamental difference between the two. When there
> are client frames showing buffers, for each client buffer there's a
> process waiting, the process which requested the buffer to be edited.
> That's why we prompt: we don't want to fail those waiting processes.
>
> Non-client frames don't have this problem.
Ok, I think that makes sense. I was hesitant about removing prompts too
aggressively, since I didn't want to open users up to losing some Emacs
state without prompting when they would have gotten a prompt before.
However, you've convinced me that we don't need to worry about
non-client frames since they don't have processes waiting on them.
(Maybe some users would want more prompts in case they accidentally kill
Emacs, but they can always add to 'kill-emacs-query-functions'.)
Attached is a new patch that removes the prompt when called from the
last remaining client. I also expanded the docstring to explain why the
prompt is there.
[0001-Don-t-prompt-when-killing-an-Emacs-client-if-it-s-th.patch (text/plain, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#58404
; Package
emacs
.
(Mon, 10 Oct 2022 17:58:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 58404 <at> debbugs.gnu.org (full text, mbox):
> Date: Mon, 10 Oct 2022 10:49:05 -0700
> Cc: 58404 <at> debbugs.gnu.org
> From: Jim Porter <jporterbugs <at> gmail.com>
>
> Attached is a new patch that removes the prompt when called from the
> last remaining client. I also expanded the docstring to explain why the
> prompt is there.
LGTM, thanks.
Reply sent
to
Jim Porter <jporterbugs <at> gmail.com>
:
You have taken responsibility.
(Mon, 10 Oct 2022 23:10:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Jim Porter <jporterbugs <at> gmail.com>
:
bug acknowledged by developer.
(Mon, 10 Oct 2022 23:10:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 58404-done <at> debbugs.gnu.org (full text, mbox):
On 10/10/2022 10:57 AM, Eli Zaretskii wrote:
>> Date: Mon, 10 Oct 2022 10:49:05 -0700
>> Cc: 58404 <at> debbugs.gnu.org
>> From: Jim Porter <jporterbugs <at> gmail.com>
>>
>> Attached is a new patch that removes the prompt when called from the
>> last remaining client. I also expanded the docstring to explain why the
>> prompt is there.
>
> LGTM, thanks.
Thanks, merged as ebc19f56aaeb98b834eea1ce8768ca13bed8578c. Closing this
bug.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 08 Nov 2022 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 218 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.