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

Valeriy
  • 377
  • 4
  • 16
FunkyBaby
  • 767
  • 1
  • 4
  • 10
  • 2
    Maybe if you expand your question with what you're trying to achieve, you'll attract some more answers. – nega Apr 07 '19 at 21:13

1 Answers1

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.

nega
  • 3,091
  • 15
  • 21