all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kelly Dean <kellydeanch@yahoo.com>
To: emacs-devel@gnu.org
Subject: [PATCH] Desktop mode saves mark-ring too verbosely
Date: Tue, 21 May 2013 20:44:15 -0700 (PDT)	[thread overview]
Message-ID: <1369194255.41567.YahooMailClassic@web141101.mail.bf1.yahoo.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1400 bytes --]

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)

The result is about 2kB of text to record a standard 16-element mark-ring. The file name is redundant, since it's already written as the first argument for desktop-create-buffer, and the rest of the line could be eliminated by special-casing saving of mark-ring, leaving just a list of marker positions to write into the desktop file, which will typically be less than 100 bytes of text. If you have dozens of file-visiting buffers, this can make the difference between a desktop file that's over 100kB and one that's just a few kB.

The attached patch does this. Surely this qualifies as a tiny change, since it only changes about 5 significant lines.

The "&rest _unsupported" is unnecessary; it just enables forward compatibility with files of version greater than 207. If it were already there, then version 206 code would be able to read version 207 files, and just ignore the mark ring.

Returning result from desktop-create-buffer is unnecessary for desktop mode, but it does no harm, and I need it in some of my other code, so please allow it.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: desktop-mark-ring.patch --]
[-- Type: text/x-diff; name="desktop-mark-ring.patch", Size: 1484 bytes --]

--- emacs-24.3/lisp/desktop.el
+++ emacs-24.3/lisp/desktop.el
@@ -133,7 +133,7 @@
 
 ;;; Code:
 
-(defvar desktop-file-version "206"
+(defvar desktop-file-version "207"
   "Version number of desktop file format.
 Written into the desktop file and used at desktop read to provide
 backward compatibility.")
@@ -694,7 +694,8 @@
 	   (when (member (car locals) loclist)
 	     (setq ll (cons (car locals) ll)))))
        (setq locals (cdr locals)))
-     ll)))
+     ll)
+   (mapcar 'marker-position mark-ring)))
 
 ;; ----------------------------------------------------------------------------
 (defun desktop-internal-v2s (value)
@@ -1145,7 +1146,9 @@
      buffer-readonly
      buffer-misc
      &optional
-     buffer-locals)
+     buffer-locals
+     buffer-mark-ring
+     &rest _unsupported)
 
   (let ((desktop-file-version	    file-version)
 	(desktop-buffer-file-name   buffer-filename)
@@ -1233,7 +1236,11 @@
 		;; an entry of the form `symbol'
 		(make-local-variable this)
 		(makunbound this)))
-	    (setq desktop-buffer-locals (cdr desktop-buffer-locals))))))))
+	    (setq desktop-buffer-locals (cdr desktop-buffer-locals)))
+	  (unless (< desktop-file-version 207) ;; Don't misinterpret any old custom args
+	    (setq mark-ring
+		  (mapcar (lambda (p) (set-marker (make-marker) p)) buffer-mark-ring))))
+	result))))
 
 ;; ----------------------------------------------------------------------------
 ;; Backward compatibility -- update parameters to 205 standards.

             reply	other threads:[~2013-05-22  3:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-22  3:44 Kelly Dean [this message]
2013-11-23 13:40 ` [PATCH] Desktop mode saves mark-ring too verbosely Stefan Monnier
2015-01-21 12:11   ` Kelly Dean
2015-01-21 15:04     ` Stefan Monnier
2015-01-22  5:43       ` Kelly Dean
2015-01-22  8:20         ` Ivan Shmakov
2015-01-23 13:20           ` Kelly Dean
2015-01-23 14:09             ` Ivan Shmakov
2015-01-24  3:08             ` Stephen J. Turnbull
2015-01-24 23:30               ` Elisp terminology (was: Re: [PATCH] Desktop mode saves mark-ring too verbosely) Kelly Dean
2015-01-25  9:49                 ` Elisp terminology David Kastrup
  -- strict thread matches above, loose matches on Subject: below --
2015-01-23  2:59 Rant - Elisp terminology is deceptive Kelly Dean
2015-01-23 20:15 ` Stefan Monnier
2015-01-24  0:41   ` Kelly Dean
2015-01-24  0:48     ` Óscar Fuentes
2015-01-24  3:28     ` Stephen J. Turnbull
2015-01-24  8:51       ` Eli Zaretskii
2015-01-24 10:32         ` Kelly Dean
2015-01-24 11:26           ` Eli Zaretskii
2015-01-24 10:30       ` Kelly Dean
2015-01-24 11:03         ` David Kastrup
2015-01-24 23:24           ` Kelly Dean
2015-01-25  9:16             ` David Kastrup
2015-01-26  3:52               ` Kelly Dean
2015-01-26  8:28                 ` Thien-Thi Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369194255.41567.YahooMailClassic@web141101.mail.bf1.yahoo.com \
    --to=kellydeanch@yahoo.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.