emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/raeburn-startup 2ccfbba 3/5: Dump and restore empt


From: Ken Raeburn
Subject: [Emacs-diffs] scratch/raeburn-startup 2ccfbba 3/5: Dump and restore empty abbrev tables.
Date: Mon, 10 Apr 2017 11:59:12 -0400 (EDT)

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

    Dump and restore empty abbrev tables.
    
    Abbrev tables are obarrays and thus don't print out in a useful form.
    They need to be assembled at load time.  Fortunately, loadup.el only
    gives us empty abbrev tables, so we don't have to actually restore any
    abbrevs, only the tables.
    
    * lisp/loadup.el: When variable values are abbrev tables, emit a
    "make-abbrev-table" initialization with the appropriate property
    lists.  Check abbrev tables and their parents for instances of
    sharing.  Reject any abbrev tables that are not empty.
---
 lisp/loadup.el | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/lisp/loadup.el b/lisp/loadup.el
index e724d0c..1d9102a 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -489,6 +489,10 @@ lost after dumping")))
             (coding-systems '()) (coding-system-aliases '())
             (charsets '()) (charset-aliases '())
             (unified-charsets '())
+            (abbrev-tables (make-hash-table :test 'eq))
+            (abbrev-assign-cmds '())
+            (abbrev-make-cmds '())
+            (abbrev-counter 0)
             (cmds '()))
         (setcdr global-buffers-menu-map nil) ;; Get rid of buffer objects!
         (push `(internal--set-standard-syntax-table
@@ -544,6 +548,45 @@ lost after dumping")))
                           '(let ((ol (make-overlay (point-min) (point-min))))
                              (delete-overlay ol)
                              ol))
+                         ;; abbrev-table-p isn't very robust
+                         ((condition-case nil
+                              (abbrev-table-p v)
+                            (error nil))
+                          (cl-labels ((replace-abbrevs-for-dump
+                                       (table)
+                                       (or (abbrev-table-empty-p table)
+                                           (error "Non-empty abbrev tables not 
handled"))
+                                       (let ((newval (gethash table 
abbrev-tables)))
+                                         (if newval
+                                             `(aref scratch-abbrev-tables 
,newval)
+                                           (let* ((props (symbol-plist 
(obarray-get table ""))))
+                                             (cond ((plist-get props :parents)
+                                                    (setq props (copy-sequence 
props))
+                                                    (plist-put props
+                                                               :parents
+                                                               (mapcar (lambda 
(value)
+                                                                         (list 
'\, (replace-abbrevs-for-dump value)))
+                                                                       
(plist-get props :parents)))
+                                                    (setq props (list '\` 
props)))
+                                                   ((eq (length props) 2)
+                                                    ;; Only 
:abbrev-table-modiff, which gets added at creation anyway.
+                                                    (setq props nil)))
+                                             (push `(aset scratch-abbrev-tables
+                                                          ,abbrev-counter
+                                                          ,(if props
+                                                               
`(make-abbrev-table ,props)
+                                                             
'(make-abbrev-table)))
+                                                   abbrev-make-cmds)
+                                             (puthash table abbrev-counter 
abbrev-tables)
+                                             (prog1
+                                                 `(aref scratch-abbrev-tables 
,abbrev-counter)
+                                               (setq abbrev-counter (1+ 
abbrev-counter))))))))
+                            (push `(set-default ',s
+                                                ,(replace-abbrevs-for-dump v))
+                                  abbrev-assign-cmds))
+                          ;; Placeholder to be used before we know
+                          ;; we've defined make-abbrev-table.
+                          0)
                          (v (macroexp-quote v))))
                      cmds)
                ;; Local variables: make-variable-buffer-local,
@@ -596,6 +639,10 @@ lost after dumping")))
             (print '(get-buffer-create "*Messages*"))
             (print `(progn . ,cmds))
             (terpri)
+            ;; Now that make-abbrev-table is defined, use it.
+            (print `(let ((scratch-abbrev-tables (make-vector ,abbrev-counter 
0)))
+                      ,@(nreverse abbrev-make-cmds)
+                      ,@abbrev-assign-cmds))
             (print `(let ((css ',charsets))
                       (dotimes (i 3)
                         (dolist (cs (prog1 css (setq css nil)))



reply via email to

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