Emacs Asked by ianinini on September 2, 2021
I would like a way to make emacs to return a non-zero exit code when exiting.
This page https://www.gnu.org/software/emacs/manual/html_node/elisp/Killing-Emacs.html lists the command
kill-emacs &optional exit-data
as a mechanism for making emacs return with non-zero return code, stating "If exit-data is an integer, that is used as the exit status of the Emacs process".
How do I add this optional exit-data?
I have tried:
(global-set-key (kbd "C-x C-M-c") 'kill-emacs)
, but do not know the syntax well enough to pass an argument.I see this is related to How to set the exit status for emacsclient and How to make emacs or emacsclient exit with nonzero return code? , but I cannot get the answer I want from those questions/answers.
Please can someone explain how to quit emacs with a non-zero return code and/or provide the syntax to setup a keyboard binding.
Interactively, you can use a prefix argument.
E.g.:
emacs -Q
kill-emacs
RETecho $?
7
A command to do this, which you could bind to a key sequence, would be:
(defun my-kill-emacs ()
(interactive)
"Exit emacs with status 7."
(kill-emacs 7))
Correct answer by phils on September 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP