-(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. See variable `desktop-save' for a description of when the
+desktop is saved."
+ :global t
+ :group 'desktop)
+
+;; Maintained for backward compatibility
+(defvaralias 'desktop-enable 'desktop-save-mode)
+(make-obsolete-variable 'desktop-enable 'desktop-save-mode)
+
+(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-directory' 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)
+
+(defcustom desktop-base-file-name
+ (convert-standard-filename ".emacs.desktop")
+ "Name of file for Emacs desktop, excluding the directory part."
+ :type 'file
+ :group 'desktop)
+(defvaralias 'desktop-basefilename 'desktop-base-file-name)
+
+(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)
+
+(defcustom desktop-missing-file-warning nil
+ "*If non-nil then `desktop-read' warns when a file no longer exists.
+Otherwise it simply ignores that file."
+ :type 'boolean
+ :group 'desktop)
+
+(defcustom desktop-no-desktop-file-hook nil
+ "Normal hook run when `desktop-read' can't find a desktop file.
+May e.g. be used to show a dired buffer."
+ :type 'hook
+ :group 'desktop)
+
+(defcustom desktop-after-read-hook nil
+ "Normal hook run after a sucessful `desktop-read'.
+May e.g. be used to show a buffer list."
+ :type 'hook
+ :group 'desktop)
+
+(defcustom desktop-save-hook nil
+ "Normal hook run before the desktop is saved in a desktop file.
+This is useful for truncating 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 to clear by `desktop-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 evaluateing FORM."
+ :type '(repeat (restricted-sexp :match-alternatives (symbolp consp)))
+ :group 'desktop)
+
+(defcustom desktop-clear-preserve-buffers-regexp
+ "^\\(\\*scratch\\*\\|\\*Messages\\*\\|\\*tramp/.+\\*\\)$"
+ "Regexp identifying buffers that `desktop-clear' should not delete."
+ :type 'regexp
+ :group 'desktop)
+
+;; Maintained for backward compatibility
+(defcustom desktop-clear-preserve-buffers nil
+ "*List of buffer names that `desktop-clear' should not delete.
+This variable is maintained for backward compatibility only. Use
+`desktop-clear-preserve-buffers-regexp' instead."
+ :type '(repeat string)
+ :group 'desktop)
+(make-obsolete-variable 'desktop-clear-preserve-buffers
+ 'desktop-clear-preserve-buffers-regexp)
+
+(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
+ buffer-file-coding-system)