Mercurial > emacs
comparison lisp/desktop.el @ 80110:b2a178c5133e
(uniquify-managed): Don't defvar.
(desktop-buffer-info): Use `uniquify-buffer-base-name', not `uniquify-managed'.
Return also the buffer's base name.
(desktop-save): When saving the buffer info, filter out the base name,
and save it as buffer name if the buffer is managed by uniquify.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 12 Feb 2008 14:34:01 +0000 |
parents | 73661ddc7ac7 |
children | 371aabe44346 |
comparison
equal
deleted
inserted
replaced
80109:0867191fcef1 | 80110:b2a178c5133e |
---|---|
132 ;; Save window configuration. | 132 ;; Save window configuration. |
133 ;; Recognize more minor modes. | 133 ;; Recognize more minor modes. |
134 ;; Save mark rings. | 134 ;; Save mark rings. |
135 | 135 |
136 ;;; Code: | 136 ;;; Code: |
137 | |
138 (defvar uniquify-managed) | |
139 | 137 |
140 (defvar desktop-file-version "206" | 138 (defvar desktop-file-version "206" |
141 "Version number of desktop file format. | 139 "Version number of desktop file format. |
142 Written into the desktop file and used at desktop read to provide | 140 Written into the desktop file and used at desktop read to provide |
143 backward compatibility.") | 141 backward compatibility.") |
651 | 649 |
652 ;; ---------------------------------------------------------------------------- | 650 ;; ---------------------------------------------------------------------------- |
653 (defun desktop-buffer-info (buffer) | 651 (defun desktop-buffer-info (buffer) |
654 (set-buffer buffer) | 652 (set-buffer buffer) |
655 (list | 653 (list |
654 ;; base name of the buffer; replaces the buffer name if managed by uniquify | |
655 (and (fboundp 'uniquify-buffer-base-name) (uniquify-buffer-base-name)) | |
656 ;; basic information | 656 ;; basic information |
657 (desktop-file-name (buffer-file-name) desktop-dirname) | 657 (desktop-file-name (buffer-file-name) desktop-dirname) |
658 (if (bound-and-true-p uniquify-managed) | 658 (buffer-name) |
659 (uniquify-item-base (car uniquify-managed)) | |
660 (buffer-name)) | |
661 major-mode | 659 major-mode |
662 ;; minor modes | 660 ;; minor modes |
663 (let (ret) | 661 (let (ret) |
664 (mapc | 662 (mapc |
665 #'(lambda (minor-mode) | 663 #'(lambda (minor-mode) |
884 (int-to-string (- (length kill-ring) (length kill-ring-yank-pointer))) | 882 (int-to-string (- (length kill-ring) (length kill-ring-yank-pointer))) |
885 " kill-ring))\n")) | 883 " kill-ring))\n")) |
886 | 884 |
887 (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n") | 885 (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n") |
888 (dolist (l (mapcar 'desktop-buffer-info (buffer-list))) | 886 (dolist (l (mapcar 'desktop-buffer-info (buffer-list))) |
889 (when (apply 'desktop-save-buffer-p l) | 887 (let ((base (pop l))) |
890 (insert "(" | 888 (when (apply 'desktop-save-buffer-p l) |
891 (if (or (not (integerp eager)) | 889 (insert "(" |
892 (if (zerop eager) | 890 (if (or (not (integerp eager)) |
893 nil | 891 (if (zerop eager) |
894 (setq eager (1- eager)))) | 892 nil |
895 "desktop-create-buffer" | 893 (setq eager (1- eager)))) |
896 "desktop-append-buffer-args") | 894 "desktop-create-buffer" |
897 " " | 895 "desktop-append-buffer-args") |
898 desktop-file-version) | 896 " " |
899 (dolist (e l) | 897 desktop-file-version) |
900 (insert "\n " (desktop-value-to-string e))) | 898 ;; If the base name is non-nil, we save it instead of the buffer name |
901 (insert ")\n\n"))) | 899 (when base (setcar (nthcdr 1 l) base)) |
900 (dolist (e l) | |
901 (insert "\n " (desktop-value-to-string e))) | |
902 (insert ")\n\n")))) | |
902 | 903 |
903 (setq default-directory desktop-dirname) | 904 (setq default-directory desktop-dirname) |
904 (let ((coding-system-for-write 'emacs-mule)) | 905 (let ((coding-system-for-write 'emacs-mule)) |
905 (write-region (point-min) (point-max) (desktop-full-file-name) nil 'nomessage)) | 906 (write-region (point-min) (point-max) (desktop-full-file-name) nil 'nomessage)) |
906 ;; We remember when it was modified (which is presumably just now). | 907 ;; We remember when it was modified (which is presumably just now). |