emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/raeburn-startup 76a4f45: Use #N# syntax for repeat


From: Ken Raeburn
Subject: [Emacs-diffs] scratch/raeburn-startup 76a4f45: Use #N# syntax for repeated symbols in dumped.elc.
Date: Sat, 31 Dec 2016 02:25:51 +0000 (UTC)

branch: scratch/raeburn-startup
commit 76a4f45c9e9a87b4649a499264ea8a985efcfba7
Author: Ken Raeburn <address@hidden>
Commit: Ken Raeburn <address@hidden>

    Use #N# syntax for repeated symbols in dumped.elc.
    
    Parsing symbol names involves processing for possible multibyte
    characters and comparisons against other symbol-name strings in the
    obarray.  The #N# syntax is simpler, uses an automatically resized
    hash table keyed by integers, and is in most cases shorter, so reading
    can be a little faster.
    
    * src/print.c (syms_of_print): Define new Lisp variable
    print-symbols-as-references.
    (PRINT_CIRCLE_CANDIDATE_P): If it's set, accept interned symbols.
    (print_preprocess): Update comment.
    * lisp/loadup.el: Bind print-symbols-as-references to t while creating
    the dumped.elc file.
---
 lisp/loadup.el |    1 +
 src/print.c    |   23 ++++++++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/lisp/loadup.el b/lisp/loadup.el
index 4229998..54d19c1 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -563,6 +563,7 @@ lost after dumping")))
                 (print-level nil)
                 (print-length nil)
                 (print-escape-newlines t)
+                (print-symbols-as-references t)
                 (standard-output (current-buffer)))
             (print '(setq purify-flag nil))
             (print '(get-buffer-create "*Messages*"))
diff --git a/src/print.c b/src/print.c
index f3db674..9e87b25 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1146,9 +1146,12 @@ print (Lisp_Object obj, Lisp_Object printcharfun, bool 
escapeflag)
       && (VECTORP (obj) || COMPILEDP (obj)                             \
          || CHAR_TABLE_P (obj) || SUB_CHAR_TABLE_P (obj)               \
          || HASH_TABLE_P (obj) || FONTP (obj)))                        \
-   || (! NILP (Vprint_gensym)                                          \
-       && SYMBOLP (obj)                                                        
\
-       && !SYMBOL_INTERNED_P (obj)))
+   || (SYMBOLP (obj)                                                   \
+       && !SYMBOL_INTERNED_P (obj)                                     \
+       && ! NILP (Vprint_gensym))                                      \
+   || (SYMBOLP (obj)                                                   \
+       && SYMBOL_INTERNED_P (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
@@ -1189,8 +1192,9 @@ print_preprocess (Lisp_Object obj)
       if (!HASH_TABLE_P (Vprint_number_table))
        Vprint_number_table = CALLN (Fmake_hash_table, QCtest, Qeq);
 
-      /* In case print-circle is nil and print-gensym is t,
-        add OBJ to Vprint_number_table only when OBJ is a symbol.  */
+      /* In case print-circle is nil and print-gensym or
+        print-symbols-as-references is t, add OBJ to Vprint_number_table only
+        when OBJ is a symbol.  */
       if (! NILP (Vprint_circle) || SYMBOLP (obj))
        {
          Lisp_Object num = Fgethash (obj, Vprint_number_table, Qnil);
@@ -2295,6 +2299,15 @@ the value is different from what is guessed in the 
current charset
 priorities.  */);
   Vprint_charset_text_property = Qdefault;
 
+  DEFVAR_LISP ("print-symbols-as-references", Vprint_symbols_as_references,
+              doc: /* Non-nil means print interned symbols using #N= and #N# 
syntax.
+If nil, symbols are printed normally.
+
+Setting this true makes the output harder for a human to read, but may
+parse more efficiently as input to the Lisp reader if some symbols appear
+in the output many times.  */);
+  Vprint_symbols_as_references = Qnil;
+
   /* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */
   staticpro (&Vprin1_to_string_buffer);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]