;;; desktop.el --- save partial status of Emacs when killed
;; Copyright (C) 1993, 1994, 1995, 1997, 2000, 2001, 2002, 2003,
-;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
;; Author: Morten Welinder <terra@diku.dk>
;; Keywords: convenience
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; (desktop-save-mode 1)
;;
;; For further usage information, look at the section
-;; "Saving Emacs Sessions" in the GNU Emacs Manual.
+;; (info "(emacs)Saving Emacs Sessions") in the GNU Emacs Manual.
;; When the desktop module is loaded, the function `desktop-kill' is
;; added to the `kill-emacs-hook'. This function is responsible for
;; (add-to-list 'desktop-minor-mode-handlers
;; '(bar-mode . bar-desktop-restore))
-;; in the module itself, and make shure that the mode function is
+;; in the module itself, and make sure that the mode function is
;; autoloaded. See the docstrings of `desktop-buffer-mode-handlers' and
;; `desktop-minor-mode-handlers' for more info.
(desktop-save-mode 0))
(defcustom desktop-save 'ask-if-new
- "*Specifies whether the desktop should be saved when it is killed.
+ "Specifies whether the desktop should be saved when it is killed.
A desktop is killed when the user changes desktop or quits Emacs.
Possible values are:
t -- always save.
:group 'desktop
:version "22.2")
+(define-obsolete-variable-alias 'desktop-basefilename
+ 'desktop-base-file-name "22.1")
+
(defcustom desktop-base-file-name
(convert-standard-filename ".emacs.desktop")
"Name of file for Emacs desktop, excluding the directory part."
:type 'file
:group 'desktop)
-(define-obsolete-variable-alias 'desktop-basefilename
- 'desktop-base-file-name "22.1")
(defcustom desktop-base-lock-name
(convert-standard-filename ".emacs.desktop.lock")
(defcustom desktop-clear-preserve-buffers
'("\\*scratch\\*" "\\*Messages\\*" "\\*server\\*" "\\*tramp/.+\\*")
- "*List of buffers that `desktop-clear' should not delete.
+ "List of buffers that `desktop-clear' should not delete.
Each element is a regular expression. Buffers with a name matched by any of
these won't be deleted."
:type '(repeat string)
:group 'desktop)
(defcustom desktop-file-name-format 'absolute
- "*Format in which desktop file names should be saved.
+ "Format in which desktop file names should be saved.
Possible values are:
absolute -- Absolute file name.
tilde -- Relative to ~.
(defcustom desktop-minor-mode-table
'((auto-fill-function auto-fill-mode)
(vc-mode nil)
- (vc-dired-mode nil))
+ (vc-dired-mode nil)
+ (erc-track-minor-mode nil)
+ (savehist-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
((eq desktop-file-name-format 'local) (file-relative-name filename dirname))
(t (expand-file-name filename))))
+
;; ----------------------------------------------------------------------------
;;;###autoload
(defun desktop-save (dirname &optional release)
"desktop-append-buffer-args")
" "
desktop-file-version)
- ;; If the base name is non-nil, we save it instead of the buffer name
- (when base (setcar (nthcdr 1 l) base))
+ ;; If there's a non-empty base name, we save it instead of the buffer name
+ (when (and base (not (string= base "")))
+ (setcar (nthcdr 1 l) base))
(dolist (e l)
(insert "\n " (desktop-value-to-string e)))
(insert ")\n\n"))))
(or (null desktop-load-locked-desktop)
(not (y-or-n-p (format "Warning: desktop file appears to be in use by PID %s.\n\
Using it may cause conflicts. Use it anyway? " owner)))))
- (progn
- (let ((default-directory desktop-dirname))
- (run-hooks 'desktop-not-loaded-hook))
+ (let ((default-directory desktop-dirname))
(setq desktop-dirname nil)
- (message "Desktop file in use; not loaded."))
+ (run-hooks 'desktop-not-loaded-hook)
+ (unless desktop-dirname
+ (message "Desktop file in use; not loaded.")))
(desktop-lazy-abort)
;; Evaluate desktop buffer and remember when it was modified.
(load (desktop-full-file-name) t t t)
(if desktop-dirname
(desktop-save desktop-dirname)
(call-interactively 'desktop-save))
- (message "Desktop saved in %s" desktop-dirname))
+ (message "Desktop saved in %s" (abbreviate-file-name desktop-dirname)))
;; ----------------------------------------------------------------------------
;;;###autoload
(desktop-load-file desktop-buffer-major-mode)
(let ((buffer-list (buffer-list))
(result
- (condition-case err
+ (condition-case-no-debug err
(funcall (or (cdr (assq desktop-buffer-major-mode
desktop-buffer-mode-handlers))
'desktop-restore-file-buffer)
(when (member key command-line-args)
(setq command-line-args (delete key command-line-args))
(setq desktop-save-mode nil)))
- (when desktop-save-mode (desktop-read))))
+ (when desktop-save-mode
+ (desktop-read)
+ (setq inhibit-startup-screen t))))
(provide 'desktop)