;;; desktop.el --- save partial status of Emacs when killed
;; Copyright (C) 1993, 1994, 1995, 1997, 2000, 2001, 2002, 2003,
-;; 2004, 2005 Free Software Foundation, Inc.
+;; 2004, 2005, 2006 Free Software Foundation, Inc.
;; Author: Morten Welinder <terra@diku.dk>
;; Maintainter: Lars Hansen <larsh@soem.dk>
;; are supplied to handle special major and minor modes respectively.
;; `desktop-buffer-mode-handlers' is an alist of major mode specific functions
;; to restore a desktop buffer. Elements must have the form
-;;
+;;
;; (MAJOR-MODE . RESTORE-BUFFER-FUNCTION).
-;;
+;;
;; Functions listed are called by `desktop-create-buffer' when `desktop-read'
;; evaluates the desktop file. Buffers with a major mode not specified here,
;; are restored by the default handler `desktop-restore-file-buffer'.
;; `desktop-minor-mode-handlers' is an alist of functions to restore
;; non-standard minor modes. Elements must have the form
-;;
+;;
;; (MINOR-MODE . RESTORE-FUNCTION).
-;;
+;;
;; Functions are called by `desktop-create-buffer' to restore minor modes.
;; Minor modes not specified here, are restored by the standard minor mode
;; function. If you write a module that defines a major or minor mode that
;; We skip .log files because they are normally temporary.
;; (ftp) files because they require passwords and whatnot.
-;; TAGS files to save time (tags-file-name is saved instead).
(defcustom desktop-buffers-not-to-save
- "\\(^nn\\.a[0-9]+\\|\\.log\\|(ftp)\\|^tags\\|^TAGS\\)$"
+ "\\(^nn\\.a[0-9]+\\|\\.log\\|(ftp)\\)$"
"Regexp identifying buffers that are to be excluded from saving."
:type 'regexp
:group 'desktop)
:type 'regexp
:group 'desktop)
-(defcustom desktop-modes-not-to-save nil
+;; We skip TAGS files to save time (tags-file-name is saved instead).
+(defcustom desktop-modes-not-to-save
+ '(tags-table-mode)
"List of major modes whose buffers should not be saved."
:type '(repeat symbol)
:group 'desktop)
Furthermore the major mode function must be autoloaded.")
+;;;###autoload
(put 'desktop-buffer-mode-handlers 'risky-local-variable t)
(make-obsolete-variable 'desktop-buffer-handlers
'desktop-buffer-mode-handlers "22.1")
(defcustom desktop-minor-mode-table
'((auto-fill-function auto-fill-mode)
- (vc-mode nil))
+ (vc-mode nil)
+ (vc-dired-mode nil))
"Table mapping minor mode variables to minor mode functions.
Each entry has the form (NAME RESTORE-FUNCTION).
NAME is the name of the buffer-local variable indicating that the minor
See also `desktop-minor-mode-table'.")
+;;;###autoload
(put 'desktop-minor-mode-handlers 'risky-local-variable t)
;; ----------------------------------------------------------------------------
(defun desktop-outvar (varspec)
"Output a setq statement for variable VAR to the desktop file.
The argument VARSPEC may be the variable name VAR (a symbol),
-or a cons cell of the form (VAR . MAX-SIZE),
+or a cons cell of the form (VAR . MAX-SIZE),
which means to truncate VAR's value to at most MAX-SIZE elements
\(if the value is a list) before saving the value."
(let (var size)
(defun desktop-save-buffer-p (filename bufname mode &rest dummy)
"Return t if buffer should have its state saved in the desktop file.
FILENAME is the visited file name, BUFNAME is the buffer name, and
-MODE is the major mode."
+MODE is the major mode.
+\n\(fn FILENAME BUFNAME MODE)"
(let ((case-fold-search nil))
(and (not (string-match desktop-buffers-not-to-save bufname))
(not (memq mode desktop-modes-not-to-save))
desktop-buffer-file-name)))
(if desktop-missing-file-warning
(y-or-n-p (concat msg " Re-create? "))
- (message msg)
+ (message "%s" msg)
nil)))
(let* ((auto-insert nil) ; Disable auto insertion
(coding-system-for-read
(defun desktop-load-file (function)
"Load the file where auto loaded FUNCTION is defined."
- (let ((fcell (symbol-function function)))
- (when (and (listp fcell)
- (eq 'autoload (car fcell)))
- (load (cadr fcell)))))
+ (when function
+ (let ((fcell (and (fboundp function) (symbol-function function))))
+ (when (and (listp fcell)
+ (eq 'autoload (car fcell)))
+ (load (cadr fcell))))))
;; ----------------------------------------------------------------------------
;; Create a buffer, load its file, set its mode, ...;
(msg (format "Desktop lazily opening %s (%s remaining)..."
buffer-name remaining)))
(when desktop-lazy-verbose
- (message msg))
+ (message "%s" msg))
(let ((desktop-first-buffer nil)
(desktop-buffer-ok-count 0)
(desktop-buffer-fail-count 0))