[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Desktop mode saves mark-ring too verbosely
From: |
Kelly Dean |
Subject: |
Re: [PATCH] Desktop mode saves mark-ring too verbosely |
Date: |
Wed, 21 Jan 2015 12:11:06 +0000 |
Stefan Monnier wrote on 23 Nov 2013:
>> You can (add-to-list 'desktop-locals-to-save 'mark-ring) and it works, so
>> long as you have the fix for bug 13951 applied. But it's very verbose; for
>> each element of mark-ring for each buffer, it writes an entry like
>> (let ((mk (make-marker))) (add-hook 'desktop-delay-hook (list 'lambda '()
>> (list 'set-marker mk 123 '(get-buffer "init.el")))) mk)
[snip]
> Having special-case code to print&read some variables is not in itself
> a bad idea, but I think we should do it via a table mapping variables to
> ad-hoc massaging functions.
Ok. Updated patch attached below.
This is more complex than my original patch, but it does what you want (IIUC
what you want).
--- emacs-24.4/lisp/desktop.el
+++ emacs-24.4/lisp/desktop.el
@@ -135,7 +135,7 @@
(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.")
@@ -628,6 +628,20 @@
"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 (bmr)
+ (mapcar (lambda (p)
+ (set-marker (make-marker) p))
+ bmr))))
+ "Table of serdes 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.
@@ -779,7 +793,12 @@
(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 +1355,9 @@
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 +1447,14 @@
(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.
- Re: [PATCH] Desktop mode saves mark-ring too verbosely,
Kelly Dean <=
- Re: [PATCH] Desktop mode saves mark-ring too verbosely, Stefan Monnier, 2015/01/21
- Re: [PATCH] Desktop mode saves mark-ring too verbosely, Kelly Dean, 2015/01/22
- Re: [PATCH] Desktop mode saves mark-ring too verbosely, Ivan Shmakov, 2015/01/22
- Re: [PATCH] Desktop mode saves mark-ring too verbosely, Kelly Dean, 2015/01/23
- Re: [PATCH] Desktop mode saves mark-ring too verbosely, Ivan Shmakov, 2015/01/23
- Re: [PATCH] Desktop mode saves mark-ring too verbosely, Stephen J. Turnbull, 2015/01/23
- Elisp terminology (was: Re: [PATCH] Desktop mode saves mark-ring too verbosely), Kelly Dean, 2015/01/24
- Re: Elisp terminology, David Kastrup, 2015/01/25