C-x C-c will not prompt to ask for saving desktop, it will exit Emacs immediately.
save-buffers-kill-terminal) does not actually kill the server by default, unless the client invoking it was started with the
--no-wait switch and there are no other remaining Emacs frames.
Is there anything I can do to prompt for confirmation when
C-x C-c in
emacsclient? I doesn't have to be prompting for saving desktop, any confirmation will be OK to me.
As Sam mentions, there is the user option
confirm-kill-emacs you can configure. This is the best place to hook into, as it is the final thing done before calling
kill-emacs. This means the standard checks for modified buffers, active processes, and the hook
kill-emacs-query-functions all get a chance to run first. Alternatively, you could add a function to
kill-emacs-query-functions, but note that its ordering can be important.
save-buffers-kill-terminal does not usually kill a daemon Emacs, though, you must somehow ensure
save-buffers-kill-emacs gets called instead, if you truly want to kill the server. FWIW, I achieve this in my own configuration by globally remapping
save-buffers-kill-emacs. YMMV. Here are the relevant incantations:
(global-set-key [remap save-buffers-kill-terminal] #'save-buffers-kill-emacs)
(setq confirm-kill-emacs #'yes-or-no-p)
If you want to get prompted only when you're running
emacsclient, however, just modify the
(defun my-confirm-kill-daemon (prompt)
"Ask whether to kill daemon Emacs with PROMPT.
Intended as a predicate for `confirm-kill-emacs'."
(or (not (daemonp))
(setq confirm-kill-emacs #'my-confirm-kill-daemon)