aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/print.c b/src/print.c
index 7381db61211..49331ef0984 100644
--- a/src/print.c
+++ b/src/print.c
@@ -58,6 +58,9 @@ static ptrdiff_t new_backquote_output;
58#define PRINT_CIRCLE 200 58#define PRINT_CIRCLE 200
59static Lisp_Object being_printed[PRINT_CIRCLE]; 59static Lisp_Object being_printed[PRINT_CIRCLE];
60 60
61/* Last char printed to stdout by printchar. */
62static unsigned int printchar_stdout_last;
63
61/* When printing into a buffer, first we put the text in this 64/* When printing into a buffer, first we put the text in this
62 block, then insert it all at once. */ 65 block, then insert it all at once. */
63static char *print_buffer; 66static char *print_buffer;
@@ -238,6 +241,7 @@ printchar (unsigned int ch, Lisp_Object fun)
238 } 241 }
239 else if (noninteractive) 242 else if (noninteractive)
240 { 243 {
244 printchar_stdout_last = ch;
241 fwrite (str, 1, len, stdout); 245 fwrite (str, 1, len, stdout);
242 noninteractive_need_newline = 1; 246 noninteractive_need_newline = 1;
243 } 247 }
@@ -515,19 +519,33 @@ static void print_preprocess (Lisp_Object);
515static void print_preprocess_string (INTERVAL, Lisp_Object); 519static void print_preprocess_string (INTERVAL, Lisp_Object);
516static void print_object (Lisp_Object, Lisp_Object, bool); 520static void print_object (Lisp_Object, Lisp_Object, bool);
517 521
518DEFUN ("terpri", Fterpri, Sterpri, 0, 1, 0, 522DEFUN ("terpri", Fterpri, Sterpri, 0, 2, 0,
519 doc: /* Output a newline to stream PRINTCHARFUN. 523 doc: /* Output a newline to stream PRINTCHARFUN.
524If ENSURE is non-nil only output a newline if not already at the
525beginning of a line. Value is non-nil if a newline is printed.
520If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */) 526If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */)
521 (Lisp_Object printcharfun) 527 (Lisp_Object printcharfun, Lisp_Object ensure)
522{ 528{
523 PRINTDECLARE; 529 Lisp_Object val = Qnil;
524 530
531 PRINTDECLARE;
525 if (NILP (printcharfun)) 532 if (NILP (printcharfun))
526 printcharfun = Vstandard_output; 533 printcharfun = Vstandard_output;
527 PRINTPREPARE; 534 PRINTPREPARE;
528 PRINTCHAR ('\n'); 535
536 if (NILP (ensure))
537 val = Qt;
538 /* Difficult to check if at line beginning so abort. */
539 else if (FUNCTIONP (printcharfun))
540 signal_error ("Unsupported function argument", printcharfun);
541 else if (noninteractive && !NILP (printcharfun))
542 val = printchar_stdout_last == 10 ? Qnil : Qt;
543 else if (NILP (Fbolp ()))
544 val = Qt;
545
546 if (!NILP (val)) PRINTCHAR ('\n');
529 PRINTFINISH; 547 PRINTFINISH;
530 return Qt; 548 return val;
531} 549}
532 550
533DEFUN ("prin1", Fprin1, Sprin1, 1, 2, 0, 551DEFUN ("prin1", Fprin1, Sprin1, 1, 2, 0,