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: Gregory Heytings
Subject: Re: [RFC] Option to kill `emacs --daemon' when closing the last client frame
Date: Sun, 24 Oct 2021 11:54:50 +0000


I've been experimenting with using `emacs --daemon' and found one part of it to be somewhat surprising. If I set `ALTERNATE_EDITOR' to the empty string and run emacsclient, it runs `emacs --daemon' and connects to it; so far so good. But when I close the Emacs client, the Emacs daemon sticks around; I'd prefer the daemon to stop as well.

Just add

(when (daemonp) (run-with-timer 2 2 (lambda () (unless server-clients (save-buffers-kill-emacs)))))

to your init file.


Even better (because it also works with emacsclient -n):

(when (daemonp) (run-with-timer 2 2 (lambda () (when (<= (length (frame-list)) 
1) (save-buffers-kill-emacs)))))



reply via email to

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