"Save status of Emacs when you exit."
:group 'frames)
+;; Maintained for backward compatibility
+(define-obsolete-variable-alias 'desktop-enable 'desktop-save-mode "22.1")
;;;###autoload
(define-minor-mode desktop-save-mode
"Toggle desktop saving (Desktop Save mode).
: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))
:group 'desktop
:version "22.2")
-(defcustom desktop-path (list "." user-emacs-directory "~")
+(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)
'desktop-save-buffer "22.1")
;;;###autoload
-(defvar desktop-buffer-mode-handlers
- nil
+(defvar desktop-buffer-mode-handlers nil
"Alist of major mode specific functions to restore a desktop buffer.
Functions listed are called by `desktop-create-buffer' when `desktop-read'
evaluates the desktop file. List elements must have the form
:group 'desktop)
;;;###autoload
-(defvar desktop-minor-mode-handlers
- nil
+(defvar desktop-minor-mode-handlers nil
"Alist of functions to restore non-standard minor modes.
Functions are called by `desktop-create-buffer' to restore minor modes.
List elements must have the form
(and dirs (car dirs)))
;; If not found and `desktop-path' is non-nil, use its first element.
(and desktop-path (car desktop-path))
- ;; Default: Home directory.
- "~"))))
+ ;; Default: .emacs.d.
+ user-emacs-directory))))
(if (file-exists-p (desktop-full-file-name))
;; Desktop file found, but is it already in use?
(let ((desktop-first-buffer nil)
(if (and owner
(memq desktop-load-locked-desktop '(nil ask))
(or (null desktop-load-locked-desktop)
+ (daemonp)
(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)))))
(let ((default-directory desktop-dirname))
(format ", %d to restore lazily"
(length desktop-buffer-args-list))
""))
+ ;; Bury the *Messages* buffer to not reshow it when burying
+ ;; the buffer we switched to above.
+ (when (buffer-live-p (get-buffer "*Messages*"))
+ (bury-buffer "*Messages*"))
+ ;; Clear all windows' previous and next buffers, these have
+ ;; been corrupted by the `switch-to-buffer' calls in
+ ;; `desktop-restore-file-buffer' (bug#11556). This is a
+ ;; brute force fix and should be replaced by a more subtle
+ ;; strategy eventually.
+ (walk-window-tree (lambda (window)
+ (set-window-prev-buffers window nil)
+ (set-window-next-buffers window nil)))
t))
;; No desktop file found.
(desktop-clear)
(defun desktop-load-file (function)
"Load the file where auto loaded FUNCTION is defined."
- (when function
- (let ((fcell (and (fboundp function) (symbol-function function))))
- (when (and (listp fcell)
- (eq 'autoload (car fcell)))
- (load (cadr fcell))))))
+ (when (fboundp function)
+ (autoload-do-load (symbol-function function) function)))
;; ----------------------------------------------------------------------------
;; Create a buffer, load its file, set its mode, ...;