diff options
| author | Richard M. Stallman | 1997-07-25 03:04:19 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-07-25 03:04:19 +0000 |
| commit | e0f694317d590dadafb6b3830f8b577f8a716c45 (patch) | |
| tree | a254c01c9d6b52786e244aaf972719c3b8bda61a /src | |
| parent | b077f0456897cdff4a7db924b081e628d6fbf572 (diff) | |
| download | emacs-e0f694317d590dadafb6b3830f8b577f8a716c45.tar.gz emacs-e0f694317d590dadafb6b3830f8b577f8a716c45.zip | |
(Vprint_gensym_alist): Renamed from printed_gensyms.
(Vprint_gensym): Now a Lisp_Object; Renamed from print_gensym.
(syms_of_print): Set up both as Lisp vars.
(PRINTPREPARE, PRINTFINISH): Don't clear Vprint_gensym_alist
if Vprint_gensym is a cons cell.
Diffstat (limited to 'src')
| -rw-r--r-- | src/print.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/print.c b/src/print.c index b399d63c091..41159ae69da 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -83,15 +83,17 @@ Lisp_Object Qprint_escape_newlines; | |||
| 83 | 83 | ||
| 84 | int print_quoted; | 84 | int print_quoted; |
| 85 | 85 | ||
| 86 | /* Nonzero means print #: before uninterned symbols. */ | 86 | /* Non-nil means print #: before uninterned symbols. |
| 87 | Neither t nor nil means so that and don't clear Vprint_gensym_alist | ||
| 88 | on entry to and exit from print functions. */ | ||
| 87 | 89 | ||
| 88 | int print_gensym; | 90 | Lisp_Object Vprint_gensym; |
| 89 | 91 | ||
| 90 | /* Association list of certain objects that are `eq' in the form being | 92 | /* Association list of certain objects that are `eq' in the form being |
| 91 | printed and which should be `eq' when read back in, using the #n=object | 93 | printed and which should be `eq' when read back in, using the #n=object |
| 92 | and #n# reader forms. Each element has the form (object . n). */ | 94 | and #n# reader forms. Each element has the form (object . n). */ |
| 93 | 95 | ||
| 94 | Lisp_Object printed_gensyms; | 96 | Lisp_Object Vprint_gensym_alist; |
| 95 | 97 | ||
| 96 | /* Nonzero means print newline to stdout before next minibuffer message. | 98 | /* Nonzero means print newline to stdout before next minibuffer message. |
| 97 | Defined in xdisp.c */ | 99 | Defined in xdisp.c */ |
| @@ -208,7 +210,8 @@ glyph_to_str_cpy (glyphs, str) | |||
| 208 | } \ | 210 | } \ |
| 209 | print_buffer_pos = 0; \ | 211 | print_buffer_pos = 0; \ |
| 210 | } \ | 212 | } \ |
| 211 | printed_gensyms = Qnil | 213 | if (!CONSP (Vprint_gensym)) \ |
| 214 | Vprint_gensym_alist = Qnil | ||
| 212 | 215 | ||
| 213 | #define PRINTFINISH \ | 216 | #define PRINTFINISH \ |
| 214 | if (NILP (printcharfun)) \ | 217 | if (NILP (printcharfun)) \ |
| @@ -226,7 +229,8 @@ glyph_to_str_cpy (glyphs, str) | |||
| 226 | ? PT - start_point : 0)); \ | 229 | ? PT - start_point : 0)); \ |
| 227 | if (old != current_buffer) \ | 230 | if (old != current_buffer) \ |
| 228 | set_buffer_internal (old); \ | 231 | set_buffer_internal (old); \ |
| 229 | printed_gensyms = Qnil | 232 | if (!CONSP (Vprint_gensym)) \ |
| 233 | Vprint_gensym_alist = Qnil | ||
| 230 | 234 | ||
| 231 | #define PRINTCHAR(ch) printchar (ch, printcharfun) | 235 | #define PRINTCHAR(ch) printchar (ch, printcharfun) |
| 232 | 236 | ||
| @@ -1047,12 +1051,12 @@ print (obj, printcharfun, escapeflag) | |||
| 1047 | /* If we print an uninterned symbol as part of a complex object and | 1051 | /* If we print an uninterned symbol as part of a complex object and |
| 1048 | the flag print-gensym is non-nil, prefix it with #n= to read the | 1052 | the flag print-gensym is non-nil, prefix it with #n= to read the |
| 1049 | object back with the #n# reader syntax later if needed. */ | 1053 | object back with the #n# reader syntax later if needed. */ |
| 1050 | if (print_gensym && NILP (XSYMBOL (obj)->obarray)) | 1054 | if (! NILP (Vprint_gensym) && NILP (XSYMBOL (obj)->obarray)) |
| 1051 | { | 1055 | { |
| 1052 | if (print_depth > 1) | 1056 | if (print_depth > 1) |
| 1053 | { | 1057 | { |
| 1054 | Lisp_Object tem; | 1058 | Lisp_Object tem; |
| 1055 | tem = Fassq (obj, printed_gensyms); | 1059 | tem = Fassq (obj, Vprint_gensym_alist); |
| 1056 | if (CONSP (tem)) | 1060 | if (CONSP (tem)) |
| 1057 | { | 1061 | { |
| 1058 | PRINTCHAR ('#'); | 1062 | PRINTCHAR ('#'); |
| @@ -1062,11 +1066,11 @@ print (obj, printcharfun, escapeflag) | |||
| 1062 | } | 1066 | } |
| 1063 | else | 1067 | else |
| 1064 | { | 1068 | { |
| 1065 | if (CONSP (printed_gensyms)) | 1069 | if (CONSP (Vprint_gensym_alist)) |
| 1066 | XSETFASTINT (tem, XFASTINT (XCDR (XCAR (printed_gensyms))) + 1); | 1070 | XSETFASTINT (tem, XFASTINT (XCDR (XCAR (Vprint_gensym_alist))) + 1); |
| 1067 | else | 1071 | else |
| 1068 | XSETFASTINT (tem, 1); | 1072 | XSETFASTINT (tem, 1); |
| 1069 | printed_gensyms = Fcons (Fcons (obj, tem), printed_gensyms); | 1073 | Vprint_gensym_alist = Fcons (Fcons (obj, tem), Vprint_gensym_alist); |
| 1070 | 1074 | ||
| 1071 | PRINTCHAR ('#'); | 1075 | PRINTCHAR ('#'); |
| 1072 | print (tem, printcharfun, escapeflag); | 1076 | print (tem, printcharfun, escapeflag); |
| @@ -1505,10 +1509,25 @@ I.e., (quote foo) prints as 'foo, (function foo) as #'foo, and, backquoted\n\ | |||
| 1505 | forms print in the new syntax."); | 1509 | forms print in the new syntax."); |
| 1506 | print_quoted = 0; | 1510 | print_quoted = 0; |
| 1507 | 1511 | ||
| 1508 | DEFVAR_BOOL ("print-gensym", &print_gensym, | 1512 | DEFVAR_LISP ("print-gensym", &Vprint_gensym, |
| 1509 | "Non-nil means print uninterned symbols so they will read as uninterned.\n\ | 1513 | "Non-nil means print uninterned symbols so they will read as uninterned.\n\ |
| 1510 | I.e., the value of (make-symbol "foobar") prints as #:foobar."); | 1514 | I.e., the value of (make-symbol "foobar") prints as #:foobar.\n\ |
| 1511 | print_gensym = 0; | 1515 | When the uninterned symbol appears within a larger data structure,\n\ |
| 1516 | in addition use the #...# and #...= constructs as needed,\n\ | ||
| 1517 | so that multiple references to the same symbol are shared once again\n\ | ||
| 1518 | when the text is read back.\n\ | ||
| 1519 | \n\ | ||
| 1520 | If the value of `print-gensym' is a cons cell, then in addition refrain from\n\ | ||
| 1521 | clearing `print-gensym-alist' on entry to and exit from printing functions,\n\ | ||
| 1522 | so that the use of #...# and #...= can carry over for several separately\n\ | ||
| 1523 | printed objects."); | ||
| 1524 | Vprint_gensym = Qnil; | ||
| 1525 | |||
| 1526 | DEFVAR_LISP ("print-gensym-alist", &Vprint_gensym_alist, | ||
| 1527 | "Association list of elements (GENSYM . N) to guide use of #N# and #N=.\n\ | ||
| 1528 | In each element, GENSYM is an uninterned symbol that has been associated\n\ | ||
| 1529 | with #N= for the specified value of N."); | ||
| 1530 | Vprint_gensym_alist = Qnil; | ||
| 1512 | 1531 | ||
| 1513 | /* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */ | 1532 | /* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */ |
| 1514 | staticpro (&Vprin1_to_string_buffer); | 1533 | staticpro (&Vprin1_to_string_buffer); |
| @@ -1528,9 +1547,6 @@ I.e., the value of (make-symbol "foobar") prints as #:foobar."); | |||
| 1528 | Qprint_escape_newlines = intern ("print-escape-newlines"); | 1547 | Qprint_escape_newlines = intern ("print-escape-newlines"); |
| 1529 | staticpro (&Qprint_escape_newlines); | 1548 | staticpro (&Qprint_escape_newlines); |
| 1530 | 1549 | ||
| 1531 | staticpro (&printed_gensyms); | ||
| 1532 | printed_gensyms = Qnil; | ||
| 1533 | |||
| 1534 | #ifndef standalone | 1550 | #ifndef standalone |
| 1535 | defsubr (&Swith_output_to_temp_buffer); | 1551 | defsubr (&Swith_output_to_temp_buffer); |
| 1536 | #endif /* not standalone */ | 1552 | #endif /* not standalone */ |