0

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

  • 2
    Maybe if you expand your question with what you're trying to achieve, you'll attract some more answers. – nega Apr 7 at 21:13
1

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.

  • any killing-the-client-only version? – FunkyBaby Apr 7 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.