diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-04-17 13:37:51 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-04-17 13:37:51 +0200 |
commit | 5be9a9cacfaae1959c4b95c45c146044a181ad20 (patch) | |
tree | 23e138d4719a46cf36538c89ca7cc694a387bc6a /src/emacs.c | |
parent | 0829c6836eff14dda0cf8b3047376967f7b000f4 (diff) | |
download | emacs-5be9a9cacfaae1959c4b95c45c146044a181ad20.tar.gz emacs-5be9a9cacfaae1959c4b95c45c146044a181ad20.tar.bz2 emacs-5be9a9cacfaae1959c4b95c45c146044a181ad20.zip |
Add a new command `restart-emacs'
* doc/lispref/os.texi (Killing Emacs): Document it.
* lisp/files.el (save-buffers-kill-emacs): Add new RESTART parameter.
(restart-emacs): New function.
* src/emacs.c (terminate_due_to_signal, Fkill_emacs): Take an
optional RESTART parameter.
* test/lisp/files-tests.el
(files-tests-save-buffers-kill-emacs--confirm-kill-processes):
* src/xterm.c (x_connection_closed):
* src/xsmfns.c (Fhandle_save_session):
* src/keyboard.c (Fcommand_error_default_function, command_loop)
(command_loop_1, read_menu_command, read_event_from_main_queue)
(read_key_sequence, quit_throw_to_read_char):
* src/eval.c (process_quit_flag): Adjust Fkill_emacs callers.
Diffstat (limited to 'src/emacs.c')
-rw-r--r-- | src/emacs.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/emacs.c b/src/emacs.c index a35996c07aa..50b1628d207 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -427,7 +427,7 @@ terminate_due_to_signal (int sig, int backtrace_limit) don't care about the message stack. */ if (sig == SIGINT && noninteractive) clear_message_stack (); - Fkill_emacs (make_fixnum (sig)); + Fkill_emacs (make_fixnum (sig), Qnil); } shut_down_emacs (sig, Qnil); @@ -2740,21 +2740,25 @@ sort_args (int argc, char **argv) xfree (priority); } -DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P", +DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 2, "P", doc: /* 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. Any other value of ARG, or ARG omitted, means return an exit code that indicates successful program termination. +If RESTART is non-nil, instead of just exiting at the end, start a new +Emacs process, using the same command line arguments as the currently +running Emacs process. + This function is called upon receipt of the signals SIGTERM or SIGHUP, and upon SIGINT in batch mode. -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. */ +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. */ attributes: noreturn) - (Lisp_Object arg) + (Lisp_Object arg, Lisp_Object restart) { int exit_code; @@ -2801,6 +2805,11 @@ all of which are called before Emacs is actually killed. */ eln_load_path_final_clean_up (); #endif + if (!NILP (restart)) + { + execvp (*initial_argv, initial_argv); + } + if (FIXNUMP (arg)) exit_code = (XFIXNUM (arg) < 0 ? XFIXNUM (arg) | INT_MIN |