]> code.delx.au - gnu-emacs/commitdiff
desktop.el: Save mark-ring less verbosely.
authorKelly Dean <kelly@prtime.org>
Mon, 9 Feb 2015 13:25:53 +0000 (13:25 +0000)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Mon, 9 Feb 2015 13:26:19 +0000 (13:26 +0000)
For the discussion, see
https://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00582.html

lisp/ChangeLog
lisp/desktop.el

index cd40ac7a259756436e384aacc5ccdf2ffe6858b9..d4b1fff4373778ec9dacf4a3b8334a5fa1323135 100644 (file)
@@ -1,3 +1,10 @@
+2015-02-09  Kelly Dean  <kelly@prtime.org>
+
+       * desktop.el: Save mark-ring less verbosely.
+       (desktop-var-serdes-funs): New var.
+       (desktop-buffer-info, desktop-create-buffer): Use it.
+       (desktop-file-version): Update to 208.
+
 2015-02-09  Leo Liu  <sdl.web@gmail.com>
 
        * emacs-lisp/pcase.el (pcase-lambda): New Macro.  (Bug#19814)
index c355d7f080fb5698c43a5f07a727bfda285883fe..c2724904b5837d21fcb73825968cace787ff7132 100644 (file)
 (require 'cl-lib)
 (require 'frameset)
 
-(defvar desktop-file-version "206"
+(defvar desktop-file-version "208"
   "Version number of desktop file format.
 Written into the desktop file and used at desktop read to provide
 backward compatibility.")
@@ -629,6 +629,18 @@ Only valid during frame saving & restoring; intended for internal use.")
   "When the desktop file was last modified to the knowledge of this Emacs.
 Used to detect desktop file conflicts.")
 
+(defvar desktop-var-serdes-funs
+  (list (list
+        'mark-ring
+        (lambda (mr)
+          (mapcar #'marker-position mr))
+        (lambda (mr)
+          (mapcar #'copy-marker mr))))
+  "Table of serialization/deserialization functions for variables.
+Each record is a list of form: (var serializer deserializer).
+These records can be freely reordered, deleted, or new ones added.
+However, for compatibility, don't modify the functions for existing records.")
+
 (defun desktop-owner (&optional dirname)
   "Return the PID of the Emacs process that owns the desktop file in DIRNAME.
 Return nil if no desktop file found or no Emacs process is using it.
@@ -780,7 +792,12 @@ is nil, ask the user where to save the desktop."
                (push here ll))
               ((member local loclist)
                (push local ll)))))
-     ll)))
+     ll)
+   (mapcar (lambda (record)
+            (let ((var (car record)))
+              (list var
+                    (funcall (cadr record) (symbol-value var)))))
+          desktop-var-serdes-funs)))
 
 ;; ----------------------------------------------------------------------------
 (defun desktop--v2s (value)
@@ -1336,7 +1353,9 @@ after that many seconds of idle time."
      buffer-readonly
      buffer-misc
      &optional
-     buffer-locals)
+     buffer-locals
+     compacted-vars
+     &rest _unsupported)
 
   (let ((desktop-file-version      file-version)
        (desktop-buffer-file-name   buffer-filename)
@@ -1426,7 +1445,14 @@ after that many seconds of idle time."
                  (set (car this) (cdr this)))
              ;; An entry of the form `symbol'.
              (make-local-variable this)
-             (makunbound this))))))))
+             (makunbound this)))
+         (unless (< desktop-file-version 208) ; Don't misinterpret any old custom args
+           (dolist (record compacted-vars)
+             (let*
+                 ((var (car record))
+                  (deser-fun (cl-caddr (assq var desktop-var-serdes-funs))))
+               (if deser-fun (set var (funcall deser-fun (cadr record))))))))
+       result))))
 
 ;; ----------------------------------------------------------------------------
 ;; Backward compatibility -- update parameters to 205 standards.