From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kelly Dean Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Desktop mode saves mark-ring too verbosely Date: Wed, 21 Jan 2015 12:11:06 +0000 Message-ID: <7u4cFqR6MtWJNaf1Qlsmgi0Zp2qOm9JYyHWs545AC81@local> References: <1369194255.41567.YahooMailClassic@web141101.mail.bf1.yahoo.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1421842342 6673 80.91.229.3 (21 Jan 2015 12:12:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Jan 2015 12:12:22 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 21 13:12:22 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YDu90-0004dR-0Q for ged-emacs-devel@m.gmane.org; Wed, 21 Jan 2015 13:12:22 +0100 Original-Received: from localhost ([::1]:47691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDu8y-0004xz-I5 for ged-emacs-devel@m.gmane.org; Wed, 21 Jan 2015 07:12:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDu8u-0004xs-W3 for emacs-devel@gnu.org; Wed, 21 Jan 2015 07:12:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDu8o-0007BE-RB for emacs-devel@gnu.org; Wed, 21 Jan 2015 07:12:16 -0500 Original-Received: from relay6-d.mail.gandi.net ([2001:4b98:c:538::198]:43865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDu8o-0007B8-I7 for emacs-devel@gnu.org; Wed, 21 Jan 2015 07:12:10 -0500 Original-Received: from mfilter13-d.gandi.net (mfilter13-d.gandi.net [217.70.178.141]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id A44C2FB8A0; Wed, 21 Jan 2015 13:12:09 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter13-d.gandi.net Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by mfilter13-d.gandi.net (mfilter13-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id T74swSuT2ijX; Wed, 21 Jan 2015 13:12:08 +0100 (CET) X-Originating-IP: 66.220.3.179 Original-Received: from localhost (gm179.geneticmail.com [66.220.3.179]) (Authenticated sender: kelly@prtime.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 8D1E4FB8E9; Wed, 21 Jan 2015 13:12:05 +0100 (CET) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4b98:c:538::198 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:181498 Archived-At: --=-=-= Content-Type: text/plain 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). --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=desktop-mark-ring-tablized.patch --- 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. --=-=-=--