[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/raeburn-startup f01e8b5: Better fix for printing c
From: |
Ken Raeburn |
Subject: |
[Emacs-diffs] scratch/raeburn-startup f01e8b5: Better fix for printing comma expressions. |
Date: |
Fri, 13 Jan 2017 17:22:41 +0000 (UTC) |
branch: scratch/raeburn-startup
commit f01e8b539bccd3a8404c4b7f8d058d1db82260a1
Author: Ken Raeburn <address@hidden>
Commit: Ken Raeburn <address@hidden>
Better fix for printing comma expressions.
The print-symbols-as-references processing for comma and related
symbols works fine if they're being printed out as normal symbols.
It's only in the special ",foo" style syntax where using "#N=" is
likely to break things, because "#1=,foo" reads back as setting #1# to
,foo rather than to just the comma symbol.
* src/print.c (print_object): When printing "," or related symbols
with special syntax, don't use print_object on the special symbol
itself.
(PRINT_CIRCLE_CANDIDATE_P): Revert previous change.
---
src/print.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/print.c b/src/print.c
index ff2e1be..38d9ac5 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1151,10 +1151,7 @@ print (Lisp_Object obj, Lisp_Object printcharfun, bool
escapeflag)
&& ! NILP (Vprint_gensym)) \
|| (SYMBOLP (obj) \
&& SYMBOL_INTERNED_P (obj) \
- && ! NILP (Vprint_symbols_as_references)
\
- && ! EQ (Qcomma, obj) \
- && ! EQ (Qcomma_at, obj)
\
- && ! EQ (Qcomma_dot, obj)))
+ && ! NILP (Vprint_symbols_as_references)))
/* Construct Vprint_number_table according to the structure of OBJ.
OBJ itself and all its elements will be added to Vprint_number_table
@@ -1607,7 +1604,20 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun,
bool escapeflag)
|| EQ (XCAR (obj), Qcomma_at)
|| EQ (XCAR (obj), Qcomma_dot)))
{
- print_object (XCAR (obj), printcharfun, false);
+ /* If print-symbols-as-references is enabled, symbols may
+ print with "#N=" or "#N#" form. When we print a cons
+ cell with parens and separated elements, that's fine, but
+ for comma symbols we depend on the reader to generate the
+ cons cell from the special syntax. The Lisp reader will
+ treat "#1=,#2=foo" as setting reference 1 to ",foo", not
+ to ",", so we can't use print_object to print out the
+ comma symbols without breaking the ability to read the
+ result back properly. */
+ printchar (',', printcharfun);
+ if (EQ (XCAR (obj), Qcomma_at))
+ printchar ('@', printcharfun);
+ else if (EQ (XCAR (obj), Qcomma_dot))
+ printchar ('.', printcharfun);
new_backquote_output--;
print_object (XCAR (XCDR (obj)), printcharfun, escapeflag);
new_backquote_output++;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] scratch/raeburn-startup f01e8b5: Better fix for printing comma expressions.,
Ken Raeburn <=