diff options
| -rw-r--r-- | src/print.c | 52 |
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 | ||
| 40 | Lisp_Object Vstandard_output, Qstandard_output; | 40 | Lisp_Object Vstandard_output, Qstandard_output; |
| 41 | 41 | ||
| 42 | /* These are used to print like we read. */ | ||
| 43 | extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; | ||
| 44 | |||
| 42 | #ifdef LISP_FLOAT_TYPE | 45 | #ifdef LISP_FLOAT_TYPE |
| 43 | Lisp_Object Vfloat_output_format, Qfloat_output_format; | 46 | Lisp_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 | ||
| 76 | Lisp_Object Qprint_escape_newlines; | 79 | Lisp_Object Qprint_escape_newlines; |
| 77 | 80 | ||
| 81 | /* Nonzero means print (quote foo) forms as 'foo, etc. */ | ||
| 82 | |||
| 83 | int print_quoted; | ||
| 84 | |||
| 85 | Lisp_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) | |||
| 1317 | void | 1348 | void |
| 1318 | syms_of_print () | 1349 | syms_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\ |
| 1325 | This may be any function of one argument.\n\ | 1353 | This may be any function of one argument.\n\ |
| @@ -1365,6 +1393,12 @@ A value of nil means no limit."); | |||
| 1365 | Also print formfeeds as backslash-f."); | 1393 | Also 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\ | ||
| 1398 | I.e., (quote foo) prints as 'foo, (function foo) as #'foo, and, backquoted\n\ | ||
| 1399 | forms 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 */ |