Commit 6c8e0ae6 authored by Juri Linkov's avatar Juri Linkov

* lisp/desktop.el (desktop-auto-save-timeout): Change default to

`auto-save-timeout'.  Doc fix.
(desktop-save): Skip the timestamp in desktop-saved-frameset
when checking for auto-save changes.
(desktop-auto-save): Don't call desktop-auto-save-set-timer since
`desktop-auto-save' is called repeatedly by the idle timer.
(desktop-auto-save-set-timer): Replace `run-with-timer' with
`run-with-idle-timer' and a non-nil arg REPEAT.  Doc fix.

Fixes: debbugs:15331
parent 2178e858
......@@ -398,8 +398,8 @@ on the given date.
** Desktop
*** `desktop-auto-save-timeout' defines the number of seconds between
auto-saves of the desktop.
*** `desktop-auto-save-timeout' defines the number of seconds idle time
before auto-save of the desktop.
*** `desktop-restore-frames', enabled by default, allows saving and
restoring the frame/window configuration (frameset). Additional options
......
2013-12-16 Juri Linkov <juri@jurta.org>
* desktop.el (desktop-auto-save-timeout): Change default to
`auto-save-timeout'. Doc fix.
(desktop-save): Skip the timestamp in desktop-saved-frameset
when checking for auto-save changes.
(desktop-auto-save): Don't call desktop-auto-save-set-timer since
`desktop-auto-save' is called repeatedly by the idle timer.
(desktop-auto-save-set-timer): Replace `run-with-timer' with
`run-with-idle-timer' and a non-nil arg REPEAT. Doc fix.
(Bug#15331)
2013-12-16 Juri Linkov <juri@jurta.org>
* isearch.el (isearch-mode-map): Remove [escape] key bindinds.
......
......@@ -191,9 +191,9 @@ determine where the desktop is saved."
:group 'desktop
:version "22.1")
(defcustom desktop-auto-save-timeout nil
"Number of seconds between auto-saves of the desktop.
Zero or nil means disable timer-based auto-saving."
(defcustom desktop-auto-save-timeout auto-save-timeout
"Number of seconds idle time before auto-save of the desktop.
Zero or nil means disable auto-saving due to idleness."
:type '(choice (const :tag "Off" nil)
(integer :tag "Seconds"))
:set (lambda (symbol value)
......@@ -992,12 +992,21 @@ and don't save the buffer if they are the same."
(insert ")\n\n"))))
(setq default-directory desktop-dirname)
;; If auto-saving, avoid writing if nothing has changed since the last write.
;; Don't check 300 characters of the header that contains the timestamp.
(let ((checksum (and auto-save (md5 (current-buffer)
(+ (point-min) 300) (point-max)
'emacs-mule))))
(unless (and auto-save (equal checksum desktop-file-checksum))
;; When auto-saving, avoid writing if nothing has changed since the last write.
(let* ((beg (and auto-save
(save-excursion
(goto-char (point-min))
;; Don't check the header with changing timestamp
(and (search-forward "Global section" nil t)
;; Also skip the timestamp in desktop-saved-frameset
;; if it's saved in the first non-header line
(search-forward "desktop-saved-frameset"
(line-beginning-position 3) t)
;; This is saved after the timestamp
(search-forward (format "%S" desktop--app-id) nil t))
(point))))
(checksum (and beg (md5 (current-buffer) beg (point-max) 'emacs-mule))))
(unless (and checksum (equal checksum desktop-file-checksum))
(let ((coding-system-for-write 'emacs-mule))
(write-region (point-min) (point-max) (desktop-full-file-name) nil 'nomessage))
(setq desktop-file-checksum checksum)
......@@ -1199,21 +1208,21 @@ Called by the timer created in `desktop-auto-save-set-timer'."
;; Save only to own desktop file.
(eq (emacs-pid) (desktop-owner))
desktop-dirname)
(desktop-save desktop-dirname nil t))
(desktop-auto-save-set-timer))
(desktop-save desktop-dirname nil t)))
(defun desktop-auto-save-set-timer ()
"Reset the auto-save timer.
"Set the auto-save timer.
Cancel any previous timer. When `desktop-auto-save-timeout' is a positive
integer, start a new timer to call `desktop-auto-save' in that many seconds."
integer, start a new idle timer to call `desktop-auto-save' repeatedly
after that many seconds of idle time."
(when desktop-auto-save-timer
(cancel-timer desktop-auto-save-timer)
(setq desktop-auto-save-timer nil))
(when (and (integerp desktop-auto-save-timeout)
(> desktop-auto-save-timeout 0))
(setq desktop-auto-save-timer
(run-with-timer desktop-auto-save-timeout nil
'desktop-auto-save))))
(run-with-idle-timer desktop-auto-save-timeout t
'desktop-auto-save))))
;; ----------------------------------------------------------------------------
;;;###autoload
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment