emacs-diffs
[Top][All Lists]
Advanced

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

master 2136db067f: Add new function `flush-standard-output'.


From: Lars Ingebrigtsen
Subject: master 2136db067f: Add new function `flush-standard-output'.
Date: Sun, 17 Apr 2022 08:06:31 -0400 (EDT)

branch: master
commit 2136db067f4292d84553ebfddab30d88b862262e
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add new function `flush-standard-output'.
    
    * doc/lispref/streams.texi (Output Functions): Document it.
    * src/print.c (Fflush_standard_output): New function (bug#15180).
---
 doc/lispref/streams.texi |  9 +++++++++
 etc/NEWS                 |  5 +++++
 src/print.c              | 12 ++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/doc/lispref/streams.texi b/doc/lispref/streams.texi
index 8f8562cadc..781a50f5c4 100644
--- a/doc/lispref/streams.texi
+++ b/doc/lispref/streams.texi
@@ -685,6 +685,15 @@ This function outputs @var{character} to @var{stream}.  It 
returns
 @var{character}.
 @end defun
 
+@defun flush-standard-output
+If you have Emacs-based batch scripts that send output to the
+terminal, Emacs will automatically display the output whenever you
+write a newline characters to @code{standard-output}.  This function
+allows you to flush to @code{standard-output} without sending a
+newline character first, which enables you to display incomplete
+lines.
+@end defun
+
 @defun prin1-to-string object &optional noescape
 @cindex object to string
 This function returns a string containing the text that @code{prin1}
diff --git a/etc/NEWS b/etc/NEWS
index 071fdd7aee..3821dac179 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1423,6 +1423,11 @@ functions.
 
 * Lisp Changes in Emacs 29.1
 
++++
+** New function 'flush-standard-output'.
+This enables you do display incomplete lines from batch-based Emacs
+scripts.
+
 +++
 ** New convenience function 'buttonize-region'.
 This works like 'buttonize', but for a region instead of a string.
diff --git a/src/print.c b/src/print.c
index 4a68d15fe0..baf515047b 100644
--- a/src/print.c
+++ b/src/print.c
@@ -768,6 +768,16 @@ is used instead.  */)
   return object;
 }
 
+DEFUN ("flush-standard-output", Fflush_standard_output, Sflush_standard_output,
+       0, 0, 0,
+       doc: /* Flush standard-output.
+This can be useful after using `princ' and the like in scripts.  */)
+  (void)
+{
+  fflush (stdout);
+  return Qnil;
+}
+
 DEFUN ("external-debugging-output", Fexternal_debugging_output, 
Sexternal_debugging_output, 1, 1, 0,
        doc: /* Write CHARACTER to stderr.
 You can call `print' while debugging emacs, and pass it this function
@@ -2549,4 +2559,6 @@ printed.  If the function returns anything else, the 
object will not
 be printed.  */);
   Vprint_unreadable_function = Qnil;
   DEFSYM (Qprint_unreadable_function, "print-unreadable-function");
+
+  defsubr (&Sflush_standard_output);
 }



reply via email to

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