> > 1) I think it should check whether there are other *clients*, not other > *frames*. > No, because nowait client frames are not recorded as clients. There's no way around it, it's necessary to use frames. > > 3) `handle-delete-frame' (used when clicking the X button in your window > manager) can also call `save-buffers-kill-emacs' if the user closed the > last frame. The logic here should exclude the daemon frame from counting > as another frame so that closing all frames via the window manager stops > the daemon too. > If it's now also necessary to kill the daemon when you close the last Emacs frame with the window manager close button (I did not see this requirement in your original post), then it's also necessary to kill the daemon when you close the last Emacs frame with C-x 5 0 (delete-frame), because it's what Emacs tells you to do when you call emacsclient without a file argument. Here's a combined patch, which implements the two desired behaviors, and which I believe handles all cases properly: delete-frame, handele-delete-frame, save-buffers-kill-terminal, wait and nowait clients.