help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash/readline emacs mode help


From: Thien-Thi Nguyen
Subject: Re: bash/readline emacs mode help
Date: Fri, 28 Jun 2013 12:30:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Tangentially, i find using Emacs for scripting (i.e., invoked with
‘--script’) is nicer if it has the ability to display stuff to stdout.
FWIW, here is a patch that adds ‘emacs-exit-messages’:

commit da997204ccac1513452e801e974cf56895f15486
Author: Thien-Thi Nguyen <ttn@gnuvola.org>
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 file changed, 32 insertions(+)

diff --git a/src/emacs.c b/src/emacs.c
index 13f6d11..6df4f12 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1920,6 +1920,30 @@ shut_down_emacs (int sig, 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;
@@ -2314,6 +2338,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.  */);
It was written a while back, so i'd love to learn that is is obsoleted
since then by some workalike feature.  But if not...

-- 
Thien-Thi Nguyen
GPG key: 4C807502

Attachment: pgpT2ftiDRHwH.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]