aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
authorErik Naggum1996-08-24 19:39:34 +0000
committerErik Naggum1996-08-24 19:39:34 +0000
commit2f100b5c7ad86397cd881ca51835e370efd8cc84 (patch)
tree6dc0af6d8c74df67821a13a24ede01a11d52cd80 /src/print.c
parent20c5a87d0b8a3fb8682a2d4ade4606daa030f66d (diff)
downloademacs-2f100b5c7ad86397cd881ca51835e370efd8cc84.tar.gz
emacs-2f100b5c7ad86397cd881ca51835e370efd8cc84.zip
(print-quoted): New variable.
(print): Print certain expressions more compactly when set. Also use XCAR and XCDR directly -- we know we have conses.
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/src/print.c b/src/print.c
index ebfb7715199..b6a12e7228d 100644
--- a/src/print.c
+++ b/src/print.c
@@ -39,6 +39,9 @@ Boston, MA 02111-1307, USA. */
39 39
40Lisp_Object Vstandard_output, Qstandard_output; 40Lisp_Object Vstandard_output, Qstandard_output;
41 41
42/* These are used to print like we read. */
43extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction;
44
42#ifdef LISP_FLOAT_TYPE 45#ifdef LISP_FLOAT_TYPE
43Lisp_Object Vfloat_output_format, Qfloat_output_format; 46Lisp_Object Vfloat_output_format, Qfloat_output_format;
44#endif /* LISP_FLOAT_TYPE */ 47#endif /* LISP_FLOAT_TYPE */
@@ -75,6 +78,12 @@ int print_escape_newlines;
75 78
76Lisp_Object Qprint_escape_newlines; 79Lisp_Object Qprint_escape_newlines;
77 80
81/* Nonzero means print (quote foo) forms as 'foo, etc. */
82
83int print_quoted;
84
85Lisp_Object Qprint_quoted;
86
78/* Nonzero means print newline to stdout before next minibuffer message. 87/* Nonzero means print newline to stdout before next minibuffer message.
79 Defined in xdisp.c */ 88 Defined in xdisp.c */
80 89
@@ -991,6 +1000,28 @@ print (obj, printcharfun, escapeflag)
991 if (INTEGERP (Vprint_level) 1000 if (INTEGERP (Vprint_level)
992 && print_depth > XINT (Vprint_level)) 1001 && print_depth > XINT (Vprint_level))
993 strout ("...", -1, printcharfun); 1002 strout ("...", -1, printcharfun);
1003 else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
1004 && (EQ (XCAR (obj), Qquote)))
1005 {
1006 PRINTCHAR ('\'');
1007 print (XCAR (XCDR (obj)), printcharfun, escapeflag);
1008 }
1009 else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
1010 && (EQ (XCAR (obj), Qfunction)))
1011 {
1012 PRINTCHAR ('#');
1013 PRINTCHAR ('\'');
1014 print (XCAR (XCDR (obj)), printcharfun, escapeflag);
1015 }
1016 else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj)))
1017 && ((EQ (XCAR (obj), Qbackquote)
1018 || EQ (XCAR (obj), Qcomma)
1019 || EQ (XCAR (obj), Qcomma_at)
1020 || EQ (XCAR (obj), Qcomma_dot))))
1021 {
1022 print (XCAR (obj), printcharfun, 0);
1023 print (XCAR (XCDR (obj)), printcharfun, escapeflag);
1024 }
994 else 1025 else
995 { 1026 {
996 PRINTCHAR ('('); 1027 PRINTCHAR ('(');
@@ -1012,11 +1043,11 @@ print (obj, printcharfun, escapeflag)
1012 strout ("...", 3, printcharfun); 1043 strout ("...", 3, printcharfun);
1013 break; 1044 break;
1014 } 1045 }
1015 print (Fcar (obj), printcharfun, escapeflag); 1046 print (XCAR (obj), printcharfun, escapeflag);
1016 obj = Fcdr (obj); 1047 obj = XCDR (obj);
1017 } 1048 }
1018 } 1049 }
1019 if (!NILP (obj) && !CONSP (obj)) 1050 if (!NILP (obj))
1020 { 1051 {
1021 strout (" . ", 3, printcharfun); 1052 strout (" . ", 3, printcharfun);
1022 print (obj, printcharfun, escapeflag); 1053 print (obj, printcharfun, escapeflag);
@@ -1317,9 +1348,6 @@ print_interval (interval, printcharfun)
1317void 1348void
1318syms_of_print () 1349syms_of_print ()
1319{ 1350{
1320 staticpro (&Qprint_escape_newlines);
1321 Qprint_escape_newlines = intern ("print-escape-newlines");
1322
1323 DEFVAR_LISP ("standard-output", &Vstandard_output, 1351 DEFVAR_LISP ("standard-output", &Vstandard_output,
1324 "Output stream `print' uses by default for outputting a character.\n\ 1352 "Output stream `print' uses by default for outputting a character.\n\
1325This may be any function of one argument.\n\ 1353This may be any function of one argument.\n\
@@ -1365,6 +1393,12 @@ A value of nil means no limit.");
1365Also print formfeeds as backslash-f."); 1393Also print formfeeds as backslash-f.");
1366 print_escape_newlines = 0; 1394 print_escape_newlines = 0;
1367 1395
1396 DEFVAR_BOOL ("print-quoted", &print_quoted,
1397 "Non-nil means print quoted forms with reader syntax.\n\
1398I.e., (quote foo) prints as 'foo, (function foo) as #'foo, and, backquoted\n\
1399forms print in the new syntax.");
1400 print_quoted = 0;
1401
1368 /* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */ 1402 /* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */
1369 staticpro (&Vprin1_to_string_buffer); 1403 staticpro (&Vprin1_to_string_buffer);
1370 1404
@@ -1380,6 +1414,12 @@ Also print formfeeds as backslash-f.");
1380 Qexternal_debugging_output = intern ("external-debugging-output"); 1414 Qexternal_debugging_output = intern ("external-debugging-output");
1381 staticpro (&Qexternal_debugging_output); 1415 staticpro (&Qexternal_debugging_output);
1382 1416
1417 Qprint_escape_newlines = intern ("print-escape-newlines");
1418 staticpro (&Qprint_escape_newlines);
1419
1420 Qprint_quoted = intern ("print-quoted");
1421 staticpro (&Qprint_quoted);
1422
1383#ifndef standalone 1423#ifndef standalone
1384 defsubr (&Swith_output_to_temp_buffer); 1424 defsubr (&Swith_output_to_temp_buffer);
1385#endif /* not standalone */ 1425#endif /* not standalone */