emacs-devel
[Top][All Lists]
Advanced

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

Re: [RFC] Option to kill `emacs --daemon' when closing the last client f


From: Jim Porter
Subject: Re: [RFC] Option to kill `emacs --daemon' when closing the last client frame
Date: Mon, 25 Oct 2021 10:18:09 -0700

On 10/24/2021 11:11 PM, Jean Louis wrote:
Why in particular don't you use continuously the Emacs daemon if you
are already invoking many times emacsclient?

Beyond it just being what I'm used to, the main reason is that I prefer to close Emacs when I'm done working on whatever it is I was doing, so that when I reopen it later, I have a fresh session with nothing open. (I could use `desktop-clear' to do this, but since, in my usage, I'm already closing all the Emacs frames to get them out of my way, that would just be an extra step I need to remember to do.)

What you forgot to mention is that many buffers and files could be
open in the same time, some of them unsaved. It is not just a question
of emacsclient.

A browser may not have "open files", it is not equivalent to Emacs as
it has more static configuration.

In the age of web apps, that's less true than it was before. I may well be editing a file in a browser, composing an email, posting on a forum, etc. In "richer" web apps, these might auto-save for you if you leave the page, but many sites will just prompt you to save or discard your work in progress if you close the browser. This behavior is what I've customized my Emacs configuration to do.

I don't think clients are important there.

What is important are buffers and open files, some unfinished work.

`daemon-kill-when-no-clients' makes no sense to me. I would not like
not even by mistake to accidentally remove the last client and that my
buffers and open files are lost because I have set the option to quit
that way. I am using daemon option in the first place exactly to avoid
the situation you wish to create.

That's why, in my patch[1], I call `save-buffers-kill-emacs' to kill the daemon when the last client frame is closed. That way, I'm prompted before the daemon stops, and can either save my work or change my mind and leave some Emacs frames open.

This has the additional benefit for me that if I shut down my system, I generally close all the windows first (or the OS does this for me), which means that when the last Emacs frame is closed, I'm prompted to save my unfinished work. If I had my configuration set to leave the daemon alive and not bother prompting to save when closing the last frame, I could still lose my unfinished work when the system actually reboots.

That loss of work could probably be resolved via `desktop-mode', but as mentioned above, I much prefer having a "fresh" Emacs session when I start it up.

- Jim

[1] https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-10/msg02184.html and https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-10/msg02209.html



reply via email to

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