1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-04 11:40:22 +00:00

* lisp/desktop.el (desktop-auto-save-enable)

(desktop-auto-save-disable): New functions.
(desktop-save-mode, desktop-auto-save-timeout): Use them.
(desktop-read): Disable the autosave before loading the desktop,
and enable afterwards.

Fixes: debbugs:17351
This commit is contained in:
Juri Linkov 2014-06-25 02:23:41 +03:00
parent 370ceb2210
commit a4d8b73e1c
2 changed files with 26 additions and 8 deletions

View File

@ -1,3 +1,11 @@
2014-06-24 Juri Linkov <juri@jurta.org>
* desktop.el (desktop-auto-save-enable)
(desktop-auto-save-disable): New functions.
(desktop-save-mode, desktop-auto-save-timeout): Use them.
(desktop-read): Disable the autosave before loading the desktop,
and enable afterwards. (Bug#17351)
2014-06-24 Stefan Monnier <monnier@iro.umontreal.ca>
Fix some indentation problem with \; and pipes (bug#17842).

View File

@ -174,11 +174,8 @@ For further details, see info node `(emacs)Saving Emacs Sessions'."
:global t
:group 'desktop
(if desktop-save-mode
(when (and (integerp desktop-auto-save-timeout)
(> desktop-auto-save-timeout 0))
(add-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer))
(remove-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)
(desktop-auto-save-cancel-timer)))
(desktop-auto-save-enable)
(desktop-auto-save-disable)))
(defun desktop-save-mode-off ()
"Disable `desktop-save-mode'. Provided for use in hooks."
@ -219,9 +216,8 @@ Zero or nil means disable auto-saving due to idleness."
(set-default symbol value)
(ignore-errors
(if (and (integerp value) (> value 0))
(add-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)
(remove-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)
(desktop-auto-save-cancel-timer))))
(desktop-auto-save-enable value)
(desktop-auto-save-disable))))
:group 'desktop
:version "24.4")
@ -1132,6 +1128,10 @@ Using it may cause conflicts. Use it anyway? " owner)))))
(unless desktop-dirname
(message "Desktop file in use; not loaded.")))
(desktop-lazy-abort)
;; Temporarily disable the autosave that will leave it
;; disabled when loading the desktop fails with errors,
;; thus not overwriting the desktop with broken contents.
(desktop-auto-save-disable)
;; Evaluate desktop buffer and remember when it was modified.
(load (desktop-full-file-name) t t t)
(setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name))))
@ -1184,6 +1184,7 @@ Using it may cause conflicts. Use it anyway? " owner)))))
(set-window-prev-buffers window nil)
(set-window-next-buffers window nil))))
(setq desktop-saved-frameset nil)
(desktop-auto-save-enable)
t))
;; No desktop file found.
(desktop-clear)
@ -1230,6 +1231,15 @@ directory DIRNAME."
;; Auto-Saving.
(defvar desktop-auto-save-timer nil)
(defun desktop-auto-save-enable (&optional timeout)
(when (and (integerp (or timeout desktop-auto-save-timeout))
(> (or timeout desktop-auto-save-timeout) 0))
(add-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)))
(defun desktop-auto-save-disable ()
(remove-hook 'window-configuration-change-hook 'desktop-auto-save-set-timer)
(desktop-auto-save-cancel-timer))
(defun desktop-auto-save ()
"Save the desktop periodically.
Called by the timer created in `desktop-auto-save-set-timer'."