Add new function `flush-standard-output'.

* doc/lispref/streams.texi (Output Functions): Document it.
* src/print.c (Fflush_standard_output): New function (bug#15180).
This commit is contained in:
Lars Ingebrigtsen 2022-04-17 14:04:34 +02:00
parent 2a848209df
commit 2136db067f
3 changed files with 26 additions and 0 deletions

View file

@ -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}

View file

@ -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.

View file

@ -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);
}