-(defconst desktop-basefilename
- (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
- "emacs.dsk" ; Ms-Dos does not support multiple dots in file name
- ".emacs.desktop")
- "File for Emacs desktop, not including the directory name.")
-
-(defvar desktop-missing-file-warning t
- "*If non-nil then desktop warns when a file no longer exists.
-Otherwise it simply ignores that file.")
-
-(defvar desktop-globals-to-save
- (list 'desktop-missing-file-warning
- ;; Feature: saving kill-ring implies saving kill-ring-yank-pointer
- ;; 'kill-ring
- 'tags-file-name
- 'tags-table-list
- 'search-ring
- 'regexp-search-ring
- 'register-alist
- ;; 'desktop-globals-to-save ; Itself!
- )
- "List of global variables to save when killing Emacs.
-An element may be variable name (a symbol)
-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.")
-
-(defvar desktop-locals-to-save
- (list 'desktop-locals-to-save ; Itself! Think it over.
- 'truncate-lines
- 'case-fold-search
- 'case-replace
- 'fill-column
- 'overwrite-mode
- 'change-log-default-name
- 'line-number-mode
- )
+
+(defgroup desktop nil
+ "Save status of Emacs when you exit."
+ :group 'frames)
+
+;;;###autoload
+(define-minor-mode desktop-save-mode
+ "Toggle desktop saving mode.
+With numeric ARG, turn desktop saving on if ARG is positive, off
+otherwise. If desktop saving is turned on, the state of Emacs is
+saved from one session to another. See variable `desktop-save'
+and function `desktop-read' for details."
+ :global t
+ :group 'desktop)
+
+;; Maintained for backward compatibility
+(define-obsolete-variable-alias 'desktop-enable
+ 'desktop-save-mode "22.1")
+
+(defun desktop-save-mode-off ()
+ "Disable `desktop-save-mode'. Provided for use in hooks."
+ (desktop-save-mode 0))
+
+(defcustom desktop-save 'ask-if-new
+ "*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.
+ ask -- always ask.
+ ask-if-new -- ask if no desktop file exists, otherwise just save.
+ ask-if-exists -- ask if desktop file exists, otherwise don't save.
+ if-exists -- save if desktop file exists, otherwise don't save.
+ nil -- never save.
+The desktop is never saved when `desktop-save-mode' is nil.
+The variables `desktop-dirname' and `desktop-base-file-name'
+determine where the desktop is saved."
+ :type
+ '(choice
+ (const :tag "Always save" t)
+ (const :tag "Always ask" ask)
+ (const :tag "Ask if desktop file is new, else do save" ask-if-new)
+ (const :tag "Ask if desktop file exists, else don't save" ask-if-exists)
+ (const :tag "Save if desktop file exists, else don't" if-exists)
+ (const :tag "Never save" nil))
+ :group 'desktop
+ :version "22.1")
+
+(defcustom desktop-load-locked-desktop 'ask
+ "Specifies whether the desktop should be loaded if locked.
+Possible values are:
+ t -- load anyway.
+ nil -- don't load.
+ ask -- ask the user.
+If the value is nil, or `ask' and the user chooses not to load the desktop,
+the normal hook `desktop-not-loaded-hook' is run."
+ :type
+ '(choice
+ (const :tag "Load anyway" t)
+ (const :tag "Don't load" nil)
+ (const :tag "Ask the user" ask))
+ :group 'desktop
+ :version "22.2")
+
+(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")
+ "Name of lock file for Emacs desktop, excluding the directory part."
+ :type 'file
+ :group 'desktop
+ :version "22.2")
+
+(defcustom desktop-path '("." "~")
+ "List of directories to search for the desktop file.
+The base name of the file is specified in `desktop-base-file-name'."
+ :type '(repeat directory)
+ :group 'desktop
+ :version "22.1")
+
+(defcustom desktop-missing-file-warning nil
+ "If non-nil, offer to recreate the buffer of a deleted file.
+Also pause for a moment to display message about errors signaled in
+`desktop-buffer-mode-handlers'.
+
+If nil, just print error messages in the message buffer."
+ :type 'boolean
+ :group 'desktop
+ :version "22.1")
+
+(defcustom desktop-no-desktop-file-hook nil
+ "Normal hook run when `desktop-read' can't find a desktop file.
+Run in the directory in which the desktop file was sought.
+May be used to show a dired buffer."
+ :type 'hook
+ :group 'desktop
+ :version "22.1")
+
+(defcustom desktop-not-loaded-hook nil
+ "Normal hook run when the user declines to re-use a desktop file.
+Run in the directory in which the desktop file was found.
+May be used to deal with accidental multiple Emacs jobs."
+ :type 'hook
+ :group 'desktop
+ :options '(desktop-save-mode-off save-buffers-kill-emacs)
+ :version "22.2")
+
+(defcustom desktop-after-read-hook nil
+ "Normal hook run after a successful `desktop-read'.
+May be used to show a buffer list."
+ :type 'hook
+ :group 'desktop
+ :options '(list-buffers)
+ :version "22.1")
+
+(defcustom desktop-save-hook nil
+ "Normal hook run before the desktop is saved in a desktop file.
+Run with the desktop buffer current with only the header present.
+May be used to add to the desktop code or to truncate history lists,
+for example."
+ :type 'hook
+ :group 'desktop)
+
+(defcustom desktop-globals-to-save
+ '(desktop-missing-file-warning
+ tags-file-name
+ tags-table-list
+ search-ring
+ regexp-search-ring
+ register-alist)
+ "List of global variables saved by `desktop-save'.
+An element may be variable name (a symbol) 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.
+Feature: Saving `kill-ring' implies saving `kill-ring-yank-pointer'."
+ :type '(repeat (restricted-sexp :match-alternatives (symbolp consp)))
+ :group 'desktop)
+
+(defcustom desktop-globals-to-clear
+ '(kill-ring
+ kill-ring-yank-pointer
+ search-ring
+ search-ring-yank-pointer
+ regexp-search-ring
+ regexp-search-ring-yank-pointer)
+ "List of global variables that `desktop-clear' will clear.
+An element may be variable name (a symbol) or a cons cell of the form
+\(VAR . FORM). Symbols are set to nil and for cons cells VAR is set
+to the value obtained by evaluating FORM."
+ :type '(repeat (restricted-sexp :match-alternatives (symbolp consp)))
+ :group 'desktop
+ :version "22.1")
+
+(defcustom desktop-clear-preserve-buffers
+ '("\\*scratch\\*" "\\*Messages\\*" "\\*server\\*" "\\*tramp/.+\\*")
+ "*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)
+
+;;;###autoload
+(defcustom desktop-locals-to-save
+ '(desktop-locals-to-save ; Itself! Think it over.
+ truncate-lines
+ case-fold-search
+ case-replace
+ fill-column
+ overwrite-mode
+ change-log-default-name
+ line-number-mode
+ column-number-mode
+ size-indication-mode
+ buffer-file-coding-system
+ indent-tabs-mode
+ tab-width
+ indicate-buffer-boundaries
+ indicate-empty-lines
+ show-trailing-whitespace)