How to exit emacs with nonzero return code?
And how to achieve that also with emacsclient?
Duplicate of https://superuser.com/questions/295156/how-to-set-the-exit-status-for-emacsclient/542916
How to exit emacs with nonzero return code?
And how to achieve that also with emacsclient?
Duplicate of https://superuser.com/questions/295156/how-to-set-the-exit-status-for-emacsclient/542916
Use the function kill-emacs. From its help:
kill-emacs is an interactive built-in function in `C source code'. (kill-emacs &optional ARG)
Exit the Emacs job and kill it. If ARG is an integer, return ARG as the exit program code. If ARG is a string, stuff it as keyboard input.
The value of `kill-emacs-hook', if not void, is a list of functions (of no args), all of which are called before Emacs is actually killed.
[back]
Note that kill-emacs is not the normal exit function bound to C-x C-c. That is save-buffers-kill-emacs.
Additionally kill-emacs called from an emacsclient will kill the client and the server.
server-edit, bound to C-x C-# is how you close buffers and the emacsclient. From the manual:
But C-x # is the way to tell emacsclient that you are finished.
Maybe if you explore what server-edit is doing, (and server.el in general) you'll find some clues.