diff options
| author | Lars Ingebrigtsen | 2022-04-17 14:04:34 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-04-17 14:06:25 +0200 |
| commit | 2136db067f4292d84553ebfddab30d88b862262e (patch) | |
| tree | 93e1ae6dd32f1e35729858ee4ad4cab8e54c836f | |
| parent | 2a848209df79b717b4a309ec6e1b21d021519b16 (diff) | |
| download | emacs-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.texi | 9 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | src/print.c | 12 |
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 | ||
| 689 | If you have Emacs-based batch scripts that send output to the | ||
| 690 | terminal, Emacs will automatically display the output whenever you | ||
| 691 | write a newline characters to @code{standard-output}. This function | ||
| 692 | allows you to flush to @code{standard-output} without sending a | ||
| 693 | newline character first, which enables you to display incomplete | ||
| 694 | lines. | ||
| 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 |
| 690 | This function returns a string containing the text that @code{prin1} | 699 | This function returns a string containing the text that @code{prin1} |
| @@ -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'. | ||
| 1428 | This enables you do display incomplete lines from batch-based Emacs | ||
| 1429 | scripts. | ||
| 1430 | |||
| 1431 | +++ | ||
| 1427 | ** New convenience function 'buttonize-region'. | 1432 | ** New convenience function 'buttonize-region'. |
| 1428 | This works like 'buttonize', but for a region instead of a string. | 1433 | This 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 | ||
| 771 | DEFUN ("flush-standard-output", Fflush_standard_output, Sflush_standard_output, | ||
| 772 | 0, 0, 0, | ||
| 773 | doc: /* Flush standard-output. | ||
| 774 | This can be useful after using `princ' and the like in scripts. */) | ||
| 775 | (void) | ||
| 776 | { | ||
| 777 | fflush (stdout); | ||
| 778 | return Qnil; | ||
| 779 | } | ||
| 780 | |||
| 771 | DEFUN ("external-debugging-output", Fexternal_debugging_output, Sexternal_debugging_output, 1, 1, 0, | 781 | DEFUN ("external-debugging-output", Fexternal_debugging_output, Sexternal_debugging_output, 1, 1, 0, |
| 772 | doc: /* Write CHARACTER to stderr. | 782 | doc: /* Write CHARACTER to stderr. |
| 773 | You can call `print' while debugging emacs, and pass it this function | 783 | 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 | |||
| 2549 | be printed. */); | 2559 | be 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 | } |