(desktop-save-mode 1)
When this mode is enabled, Emacs will save the desktop when it exits
-(this may prompt you, see the option `desktop-save'). The next time
+\(this may prompt you, see the option `desktop-save'). The next time
Emacs starts, if this mode is active it will restore the desktop.
To manually save the desktop at any time, use the command \\[desktop-save].
For further details, see info node `(emacs)Saving Emacs Sessions'."
:global t
- :group 'desktop
(if desktop-save-mode
(desktop-auto-save-enable)
(desktop-auto-save-disable)))
(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-auto-save-timeout auto-save-timeout
(if (and (integerp value) (> value 0))
(desktop-auto-save-enable value)
(desktop-auto-save-disable))))
- :group 'desktop
:version "24.4")
(defcustom desktop-load-locked-desktop 'ask
(const :tag "Don't load" nil)
(const :tag "Ask the user" ask)
(const :tag "Load if no local process" check-pid))
- :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)
+ :type 'file)
(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 user-emacs-directory "~")
"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 "23.2") ; user-emacs-directory added
(defcustom desktop-missing-file-warning nil
If nil, just print error messages in the message buffer."
:type 'boolean
- :group 'desktop
:version "22.1")
(defcustom desktop-no-desktop-file-hook nil
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
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")
"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")
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)
+ :type 'hook)
(defcustom desktop-globals-to-save
'(desktop-missing-file-warning
\(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)
+ :type '(repeat (restricted-sexp :match-alternatives (symbolp consp))))
(defcustom desktop-globals-to-clear
'(kill-ring
\(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
Each element is a regular expression. Buffers with a name matched by any of
these won't be deleted."
:version "23.3" ; added Warnings - bug#6336
- :type '(repeat regexp)
- :group 'desktop)
+ :type '(repeat regexp))
;;;###autoload
(defcustom desktop-locals-to-save
"List of local variables to save for each buffer.
The variables are saved only when they really are local. Conventional minor
modes are restored automatically; they should not be listed here."
- :type '(repeat symbol)
- :group 'desktop)
+ :type '(repeat symbol))
(defcustom desktop-buffers-not-to-save "\\` "
"Regexp identifying buffers that are to be excluded from saving.
or `desktop-modes-not-to-save'."
:type '(choice (const :tag "None" nil)
regexp)
- :version "24.4" ; skip invisible temporary buffers
- :group 'desktop)
+ :version "24.4") ; skip invisible temporary buffers
;; Skip tramp and ange-ftp files
(defcustom desktop-files-not-to-save
value, to avoid hanging the desktop restoration because some remote
host is off-line."
:type '(choice (const :tag "None" nil)
- regexp)
- :group 'desktop)
+ regexp))
;; 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)
+ :type '(repeat symbol))
(defcustom desktop-restore-frames (not (featurep 'android))
"When non-nil, save and restore the frame and window configuration.
default on Android because the window manager there prevents programs from
restoring frames."
:type 'boolean
- :group 'desktop
:version "31.1")
(defcustom desktop-restore-in-current-display t
:type '(choice (const :tag "Restore in current display" t)
(const :tag "Restore in original display" nil)
(const :tag "Delete frames in other displays" delete))
- :group 'desktop
:version "24.4")
(defcustom desktop-restore-forces-onscreen t
:type '(choice (const :tag "Only fully offscreen frames" t)
(const :tag "Also partially offscreen frames" all)
(const :tag "Do not force frames onscreen" nil))
- :group 'desktop
:version "24.4")
(defcustom desktop-restore-reuses-frames t
:type '(choice (const :tag "Reuse existing frames" t)
(const :tag "Delete existing frames" nil)
(const :tag "Keep existing frames" keep))
- :group 'desktop
:version "24.4")
(defcustom desktop-file-name-format 'absolute
tilde -- Relative to ~.
local -- Relative to directory of desktop file."
:type '(choice (const absolute) (const tilde) (const local))
- :group 'desktop
:version "22.1")
(defcustom desktop-restore-eager t
Remaining buffers are restored lazily (when Emacs is idle).
If value is t, all buffers are restored immediately."
:type '(choice (const t) integer)
- :group 'desktop
:version "22.1")
(defcustom desktop-lazy-verbose t
"Verbose reporting of lazily created buffers."
:type 'boolean
- :group 'desktop
:version "22.1")
(defcustom desktop-lazy-idle-delay 5
"Idle delay before starting to create buffers.
See `desktop-restore-eager'."
:type 'natnum
- :group 'desktop
:version "22.1")
;;;###autoload
this table. See also `desktop-minor-mode-handlers'."
:type '(alist :key-type (symbol :tag "Minor mode")
:value-type (list :tag "Restore function"
- (choice (const nil) function)))
- :group 'desktop)
+ (choice (const nil) function))))
;;;###autoload
(defvar desktop-minor-mode-handlers nil
(lambda (mr)
(mapcar #'copy-marker mr))))
"Table of serialization/deserialization functions for variables.
-Each record is a list of form: (var serializer deserializer).
+Each record is a list of form: (VAR SERIALIZER DESERIALIZER).
These records can be freely reordered, deleted, or new ones added.
However, for compatibility, don't modify the functions for existing records.")
(dolist (var desktop-globals-to-clear)
(if (symbolp var)
(set-default var nil)
- (set-default var (eval (cdr var)))))
+ ;; FIXME: To avoid maiming kitten we should also support `funcall'
+ ;; instead of only `eval' here.
+ (set-default var (eval (cdr var) t))))
(let ((preserve-regexp (concat "\\`\\("
(mapconcat (lambda (regexp)
(concat "\\(" regexp "\\)"))
`buffer-file-name';
`buffer-name';
`major-mode';
- list of minor-modes,;
+ list of minor-modes;
`point';
`mark';
`buffer-read-only';
(cons 'must
`(,@(mapcar #'cdr
(nreverse (if use-list* (cdr newlist) newlist)))
- ,@(if use-list* (cdar newlist)))))))
+ . ,(if use-list* (cdar newlist)))))))
((subrp value)
(cons nil `(symbol-function
',(intern-soft (substring (prin1-to-string value) 7 -1)))))
(when (boundp var)
(when (and (integerp size)
(> size 0)
- (listp (eval var)))
- (desktop-truncate (eval var) size))
+ (listp (symbol-value var)))
+ (desktop-truncate (symbol-value var) size))
(insert "(setq "
(symbol-name var)
" "
"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.
-\n\(fn FILENAME BUFNAME MODE)"
+\n(fn FILENAME BUFNAME MODE)"
(let ((case-fold-search nil)
(no-regexp-to-check (not (stringp desktop-files-not-to-save)))
dired-skip)
;; Else, with a prefix arg, ask for a directory name.
(and ask (read-directory-name "Directory for desktop file: " nil nil t))
;; Otherwise search desktop file in desktop-path.
- (let ((dirs desktop-path))
- (while (and dirs
- (not (file-exists-p
- (desktop-full-file-name (car dirs)))))
- (setq dirs (cdr dirs)))
- (and dirs (car dirs)))
+ (locate-file desktop-base-file-name desktop-path)
;; If not found and `desktop-path' is non-nil, use its first element.
- (and desktop-path (car desktop-path))
+ (car desktop-path)
;; Default: .emacs.d.
user-emacs-directory))))
(if (file-exists-p (desktop-full-file-name))
(> desktop-auto-save-timeout 0))
(setq desktop-auto-save-timer
(run-with-idle-timer desktop-auto-save-timeout nil
- 'desktop-auto-save))))
+ #'desktop-auto-save))))
(defun desktop-auto-save-cancel-timer ()
(when desktop-auto-save-timer
(condition-case err
;; Evaluate point. Thus point can be something like
;; '(search-forward ...
- (eval desktop-buffer-point)
- (error (message "%s" (error-message-string err)) 1))))
+ ;; FIXME: How/where could this happen? AFAICT this var
+ ;; is lexical has been lexical since 2013 and thus equal
+ ;; to the arg `buffer-point' which always comes from the
+ ;; corresponding entry in `desktop-buffer-info' where we
+ ;; put just an integer.
+ ;; FIXME: If we want to keep this feature, we should
+ ;; also allow `desktop-buffer-point' to be a function.
+ (eval desktop-buffer-point t)
+ (error (message "%s" (error-message-string err))
+ (point-min)))))
(when desktop-buffer-mark
(if (consp desktop-buffer-mark)
(progn
;; Backward compatibility -- update parameters to 205 standards.
(defun desktop-buffer (buffer-filename buffer-name buffer-majormode
mim pt mk ro tl fc cfs cr buffer-misc)
+ ;; FIXME: Actually, it's been obsolete since 1994 (commit ec4c6f225a81)!
+ (declare (obsolete desktop-create-buffer "31"))
(desktop-create-buffer 205 buffer-filename buffer-name
buffer-majormode (cdr mim) pt mk ro
buffer-misc
(setq desktop-buffer-args-list (nconc desktop-buffer-args-list (list args)))
(unless desktop-lazy-timer
(setq desktop-lazy-timer
- (run-with-idle-timer desktop-lazy-idle-delay t 'desktop-idle-create-buffers))))
+ (run-with-idle-timer desktop-lazy-idle-delay t
+ #'desktop-idle-create-buffers))))
(defun desktop-lazy-create-buffer ()
"Pop args from `desktop-buffer-args-list', create buffer and bury it."