GNU bug report logs -
#51377
Automatically exit server when it has no remaining clients
Previous Next
Reported by: Gregory Heytings <gregory <at> heytings.org>
Date: Sun, 24 Oct 2021 15:16:01 UTC
Severity: wishlist
Tags: patch
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #29 received at 51377 <at> debbugs.gnu.org (full text, mbox):
On 10/24/2021 1:42 PM, Gregory Heytings wrote:
>
>>
>> Yeah, that looks like it should avoid any data loss. However, it's not
>> the behavior I'd personally expect. As I understand it, this will just
>> keep the Emacs daemon alive if there are any unsaved files.
>>
>
> Indeed. And if there are any running processes. This is I think the
> least surprising behavior for users who use the Emacs daemon.
I'd find it quite surprising, since an errant edit to any open file
would prevent the server from exiting after the last client stops. While
leaving the server running isn't the worst thing ever (indeed, that's
how it works now), I'd want the logic for when the server exits to be as
simple as possible, i.e. "when there are no more clients, exit"
(provided the user has confirmed as necessary). Having the server stick
around because I forgot to save one file would surprise me, mainly
because it would typically happen after, well, I forgot something.
>> I'd find it easier to use if Emacs warned the user about unsaved files
>> before killing the last client. Then, Emacs can safely kill the daemon
>> once I've confirmed that that's what I want.
>>
>
> I'm not sure I understand why this would be better.
Coming from a non-daemon configuration, my expectation is that
`save-buffers-kill-terminal' typically kills Emacs entirely. The
behavior I'm looking for is: I can have multiple clients (or
"terminals", as the function calls them) connected to the Emacs daemon,
but once I'm down to just one client, `save-buffers-kill-terminal' works
like it does in a non-daemon/server configuration. Then, in terms of my
use pattern, the extra clients work like an addition on top of the
behavior I'm used to (i.e. running `emacs' directly).
> If want you want is to save unsaved buffers and stop the daemon when you
> close the last frame, you can simply use:
>
> (defun save-buffers-kill-terminal (&optional arg)
> (interactive "P")
> (if (and (frame-parameter nil 'client)
> (cddr (frame-list)))
> (server-save-buffers-kill-terminal arg)
> (save-buffers-kill-emacs arg)))
That's pretty much what I started with, actually. I've added more to
that as I find corner cases, and as I try to make my code work well
under different configurations so that it could merge into Emacs if
there's interest.
This bug report was last modified 3 years and 271 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.