aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-04-17 14:04:34 +0200
committerLars Ingebrigtsen2022-04-17 14:06:25 +0200
commit2136db067f4292d84553ebfddab30d88b862262e (patch)
tree93e1ae6dd32f1e35729858ee4ad4cab8e54c836f
parent2a848209df79b717b4a309ec6e1b21d021519b16 (diff)
downloademacs-2136db067f4292d84553ebfddab30d88b862262e.tar.gz
emacs-2136db067f4292d84553ebfddab30d88b862262e.zip
Add new function `flush-standard-output'.
* doc/lispref/streams.texi (Output Functions): Document it. * src/print.c (Fflush_standard_output): New function (bug#15180).
-rw-r--r--doc/lispref/streams.texi9
-rw-r--r--etc/NEWS5
-rw-r--r--src/print.c12
3 files changed, 26 insertions, 0 deletions
diff --git a/doc/lispref/streams.texi b/doc/lispref/streams.texi
index 8f8562cadc8..781a50f5c49 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
685@var{character}. 685@var{character}.
686@end defun 686@end defun
687 687
688@defun flush-standard-output
689If you have Emacs-based batch scripts that send output to the
690terminal, Emacs will automatically display the output whenever you
691write a newline characters to @code{standard-output}. This function
692allows you to flush to @code{standard-output} without sending a
693newline character first, which enables you to display incomplete
694lines.
695@end defun
696
688@defun prin1-to-string object &optional noescape 697@defun prin1-to-string object &optional noescape
689@cindex object to string 698@cindex object to string
690This function returns a string containing the text that @code{prin1} 699This function returns a string containing the text that @code{prin1}
diff --git a/etc/NEWS b/etc/NEWS
index 071fdd7aee9..3821dac1798 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1424,6 +1424,11 @@ functions.
1424* Lisp Changes in Emacs 29.1 1424* Lisp Changes in Emacs 29.1
1425 1425
1426+++ 1426+++
1427** New function 'flush-standard-output'.
1428This enables you do display incomplete lines from batch-based Emacs
1429scripts.
1430
1431+++
1427** New convenience function 'buttonize-region'. 1432** New convenience function 'buttonize-region'.
1428This works like 'buttonize', but for a region instead of a string. 1433This works like 'buttonize', but for a region instead of a string.
1429 1434
diff --git a/src/print.c b/src/print.c
index 4a68d15fe02..baf515047b4 100644
--- a/src/print.c
+++ b/src/print.c
@@ -768,6 +768,16 @@ is used instead. */)
768 return object; 768 return object;
769} 769}
770 770
771DEFUN ("flush-standard-output", Fflush_standard_output, Sflush_standard_output,
772 0, 0, 0,
773 doc: /* Flush standard-output.
774This can be useful after using `princ' and the like in scripts. */)
775 (void)
776{
777 fflush (stdout);
778 return Qnil;
779}
780
771DEFUN ("external-debugging-output", Fexternal_debugging_output, Sexternal_debugging_output, 1, 1, 0, 781DEFUN ("external-debugging-output", Fexternal_debugging_output, Sexternal_debugging_output, 1, 1, 0,
772 doc: /* Write CHARACTER to stderr. 782 doc: /* Write CHARACTER to stderr.
773You can call `print' while debugging emacs, and pass it this function 783You 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
2549be printed. */); 2559be printed. */);
2550 Vprint_unreadable_function = Qnil; 2560 Vprint_unreadable_function = Qnil;
2551 DEFSYM (Qprint_unreadable_function, "print-unreadable-function"); 2561 DEFSYM (Qprint_unreadable_function, "print-unreadable-function");
2562
2563 defsubr (&Sflush_standard_output);
2552} 2564}