commit bb69d9879f9ff7ed0659a8e7505479275affd9b9 Author: Thien-Thi Nguyen Date: 2012-07-31 22:18:28 +0200 Add var ‘emacs-exit-messages’ and handle it during shutdown. * emacs.c (shut_down_emacs): After resetting the tty, display any strings specified by ‘emacs-exit-messages’ to stderr/stdout. (syms_of_emacs Vemacs_exit_messages): New DEFVAR_LISP. --- src/emacs.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/src/emacs.c b/src/emacs.c index 2194cfe..210c5a5 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2051,6 +2051,30 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff) reset_all_sys_modes (); #endif + /* If there are any messages, display them now. + Silently ignore ill-formed data, which is a latent bug. */ + while (CONSP (Vemacs_exit_messages)) + { + Lisp_Object msg = Fcar (Vemacs_exit_messages); + FILE *to = stderr; + + if (CONSP (msg) && INTEGERP (Fcar (msg))) + { + if (1 == XINT (Fcar (msg))) + to = stdout; + msg = Fcdr (msg); + } + if (STRINGP (msg)) + { + size_t expected = SBYTES (msg); + size_t actually = fwrite (SDATA (msg), 1, expected, to); + + if (expected > actually) + abort (); + } + Vemacs_exit_messages = Fcdr (Vemacs_exit_messages); + } + stuff_buffered_input (stuff); inhibit_sentinels = 1; @@ -2438,6 +2462,14 @@ Before Emacs 24.1, the hook was not run in batch mode, i.e., if `noninteractive' was non-nil. */); Vkill_emacs_hook = Qnil; + DEFVAR_LISP ("emacs-exit-messages", Vemacs_exit_messages, + doc: /* List of strings to display to stderr at exit. +These are output as-is, so you need to include a newline. +Each element may also have form (FD . STRING), where FD is +a small integer: 1 for standard output, 2 for standard error. +All other FD values are taken as 2. */); + Vemacs_exit_messages = Qnil; + DEFVAR_LISP ("path-separator", Vpath_separator, doc: /* String containing the character that separates directories in search paths, such as PATH and other similar environment variables. */);