changeset 48143:8c7919f99581

(desktop-relative-file-names): New variable. (desktop-save): Use it.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 04 Nov 2002 08:19:59 +0000
parents 9f0d9f099b64
children a4a0068ad95b
files lisp/desktop.el
diffstat 1 files changed, 54 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/desktop.el	Sun Nov 03 15:08:29 2002 +0000
+++ b/lisp/desktop.el	Mon Nov 04 08:19:59 2002 +0000
@@ -471,6 +471,11 @@
 	     (and (null filename)
 		  (memq mode desktop-buffer-modes-to-save))))))
 ;; ----------------------------------------------------------------------------
+(defcustom desktop-relative-file-names nil
+  "*Store relative file names in the desktop file."
+  :type 'boolean
+  :group 'desktop)
+
 (defun desktop-save (dirname)
   "Save the Desktop file.  Parameter DIRNAME specifies where to save desktop."
   (interactive "DDirectory to save desktop file in: ")
@@ -481,42 +486,46 @@
 		 (mapcar
 		  (function
 		   (lambda (b)
-			      (set-buffer b)
-			      (list
-			       (buffer-file-name)
-			       (buffer-name)
-			       major-mode
-			       ;; minor modes
-			       (let (ret)
-				 (mapcar
-				  #'(lambda (mim)
-				      (and (boundp mim)
-					   (symbol-value mim)
-					   (setq ret
-						 (cons (let ((special (assq mim desktop-minor-mode-table)))
-							(if special
-							    (cadr special)
-							  mim))
-						      ret))))
-				  (mapcar #'car minor-mode-alist))
-				 ret)
-			       (point)
-			       (list (mark t) mark-active)
-			       buffer-read-only
-                               (run-hook-with-args-until-success
-                                'desktop-buffer-misc-functions)
-			       (let ((locals desktop-locals-to-save)
-				     (loclist (buffer-local-variables))
-				     (ll))
-				 (while locals
-				   (let ((here (assq (car locals) loclist)))
-				     (if here
-					 (setq ll (cons here ll))
-				       (if (member (car locals) loclist)
-					   (setq ll (cons (car locals) ll)))))
-				   (setq locals (cdr locals)))
-				 ll)
-			       )))
+                    (set-buffer b)
+                    (list
+                     (let ((bn (buffer-file-name)))
+                       (if bn
+                           (if desktop-relative-file-names
+                               (file-relative-name bn dirname)
+                             bn)))
+                     (buffer-name)
+                     major-mode
+                     ;; minor modes
+                     (let (ret)
+                       (mapcar
+                        #'(lambda (mim)
+                            (and (boundp mim)
+                                 (symbol-value mim)
+                                 (setq ret
+                                       (cons (let ((special (assq mim desktop-minor-mode-table)))
+                                               (if special
+                                                   (cadr special)
+                                                 mim))
+                                             ret))))
+                        (mapcar #'car minor-mode-alist))
+                       ret)
+                     (point)
+                     (list (mark t) mark-active)
+                     buffer-read-only
+                     (run-hook-with-args-until-success
+                      'desktop-buffer-misc-functions)
+                     (let ((locals desktop-locals-to-save)
+                           (loclist (buffer-local-variables))
+                           (ll))
+                       (while locals
+                         (let ((here (assq (car locals) loclist)))
+                           (if here
+                               (setq ll (cons here ll))
+                             (if (member (car locals) loclist)
+                                 (setq ll (cons (car locals) ll)))))
+                         (setq locals (cdr locals)))
+                       ll)
+                     )))
 		  (buffer-list))))
 	  (buf (get-buffer-create "*desktop*")))
       (set-buffer buf)
@@ -537,15 +546,15 @@
       (insert "\n;; Buffer section:\n")
       (mapcar
        (function (lambda (l)
-		   (if (apply 'desktop-save-buffer-p l)
-		       (progn
-			 (insert desktop-create-buffer-form)
-			 (mapcar
-			  (function (lambda (e)
-				      (insert "\n  "
-					      (desktop-value-to-string e))))
-			  l)
-			 (insert ")\n\n")))))
+         (if (apply 'desktop-save-buffer-p l)
+             (progn
+               (insert desktop-create-buffer-form)
+               (mapcar
+                (function (lambda (e)
+                  (insert "\n  "
+                          (desktop-value-to-string e))))
+                l)
+               (insert ")\n\n")))))
        info)
       (setq default-directory dirname)
       (if (file-exists-p filename) (delete-file filename))