unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Desktop mode saves mark-ring too verbosely
@ 2013-05-22  3:44 Kelly Dean
  2013-11-23 13:40 ` Stefan Monnier
  0 siblings, 1 reply; 25+ messages in thread
From: Kelly Dean @ 2013-05-22  3:44 UTC (permalink / raw)
  To: emacs-devel

[-- 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.

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Rant - Elisp terminology is deceptive
@ 2015-01-23  2:59 Kelly Dean
  2015-01-23 20:15 ` Stefan Monnier
  0 siblings, 1 reply; 25+ messages in thread
From: Kelly Dean @ 2015-01-23  2:59 UTC (permalink / raw)
  To: emacs-devel

I wasted an hour today re-discovering the fact that (eval (car (get 'foo 'standard-value))), not (default-value 'foo), returns the default value of 'foo. I learned this lesson before, but the word ‟default” is so suggestive of meaning «default» that I forgot that it doesn't actually mean «default» in Emacs. I even remembered setq-default, but cognitive dissonance from the absurdity of its name prevented me from remembering that default-value has the same problem.

For the value of a symbol in the global context, how about using the word ‟global”?

Ask any normal English-speaker for an antonym of ‟local”. He won't say ‟default”. He'll say ‟remote” or ‟global” or some such.

Ask him for an antonym of ‟default”. He won't say ‟local”. He'll say ‟non-standard” or ‟customized” or some such.

Inflict Emacs upon him for a few months, then ask him what's the difference between a ‟standard value” and a ‟default value”. He won't know. Even after writing a thousand lines of Elisp.

Tell him that the default value of shift-select-mode is t. Then do (setq shift-select-mode nil), and ask him what the default value is. He'll say ‟t”, not ‟nil”. Ask him what changed, and he'll say shift-select-mode is no longer set to the default value. Then show him what (default-value shift-select-mode) returns, and he'll tell you it must be a bug.

Since ‟default” is already misused to mean «global», it can't be changed to mean «standard», since that would cause even more confusion. ‟Standard” can stay the way it is. ‟Buffer-local” can too. But please stop using the word ‟default” for «global»; use ‟global”. There's already precedence in Emacs: describe-variable calls it ‟global”.



^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-01-26  8:28 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-22  3:44 [PATCH] Desktop mode saves mark-ring too verbosely Kelly Dean
2013-11-23 13:40 ` 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).