aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2013-12-16 23:48:51 +0200
committerJuri Linkov2013-12-16 23:48:51 +0200
commit6c8e0ae69b3488e4ff38527cc930202e9cd9a98e (patch)
tree9781f728a7f21b474fe44525af24877d18b2ae43
parent2178e8589a6f650eba114153be01d14f9ed08b60 (diff)
downloademacs-6c8e0ae69b3488e4ff38527cc930202e9cd9a98e.tar.gz
emacs-6c8e0ae69b3488e4ff38527cc930202e9cd9a98e.zip
* 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
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/desktop.el39
3 files changed, 38 insertions, 17 deletions
diff --git a/etc/NEWS b/etc/NEWS
index ad385f4d373..0977accff3f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -398,8 +398,8 @@ on the given date.
398 398
399** Desktop 399** Desktop
400 400
401*** `desktop-auto-save-timeout' defines the number of seconds between 401*** `desktop-auto-save-timeout' defines the number of seconds idle time
402auto-saves of the desktop. 402before auto-save of the desktop.
403 403
404*** `desktop-restore-frames', enabled by default, allows saving and 404*** `desktop-restore-frames', enabled by default, allows saving and
405restoring the frame/window configuration (frameset). Additional options 405restoring the frame/window configuration (frameset). Additional options
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0cf8ed3da1e..1fe7bd62b04 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,17 @@
12013-12-16 Juri Linkov <juri@jurta.org> 12013-12-16 Juri Linkov <juri@jurta.org>
2 2
3 * desktop.el (desktop-auto-save-timeout): Change default to
4 `auto-save-timeout'. Doc fix.
5 (desktop-save): Skip the timestamp in desktop-saved-frameset
6 when checking for auto-save changes.
7 (desktop-auto-save): Don't call desktop-auto-save-set-timer since
8 `desktop-auto-save' is called repeatedly by the idle timer.
9 (desktop-auto-save-set-timer): Replace `run-with-timer' with
10 `run-with-idle-timer' and a non-nil arg REPEAT. Doc fix.
11 (Bug#15331)
12
132013-12-16 Juri Linkov <juri@jurta.org>
14
3 * isearch.el (isearch-mode-map): Remove [escape] key bindinds. 15 * isearch.el (isearch-mode-map): Remove [escape] key bindinds.
4 (Bug#16035) 16 (Bug#16035)
5 (isearch-pre-command-hook): Check `this-command' for symbolp. 17 (isearch-pre-command-hook): Check `this-command' for symbolp.
diff --git a/lisp/desktop.el b/lisp/desktop.el
index cff78ba9da6..bdb16c00262 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -191,9 +191,9 @@ determine where the desktop is saved."
191 :group 'desktop 191 :group 'desktop
192 :version "22.1") 192 :version "22.1")
193 193
194(defcustom desktop-auto-save-timeout nil 194(defcustom desktop-auto-save-timeout auto-save-timeout
195 "Number of seconds between auto-saves of the desktop. 195 "Number of seconds idle time before auto-save of the desktop.
196Zero or nil means disable timer-based auto-saving." 196Zero or nil means disable auto-saving due to idleness."
197 :type '(choice (const :tag "Off" nil) 197 :type '(choice (const :tag "Off" nil)
198 (integer :tag "Seconds")) 198 (integer :tag "Seconds"))
199 :set (lambda (symbol value) 199 :set (lambda (symbol value)
@@ -992,12 +992,21 @@ and don't save the buffer if they are the same."
992 (insert ")\n\n")))) 992 (insert ")\n\n"))))
993 993
994 (setq default-directory desktop-dirname) 994 (setq default-directory desktop-dirname)
995 ;; If auto-saving, avoid writing if nothing has changed since the last write. 995 ;; When auto-saving, avoid writing if nothing has changed since the last write.
996 ;; Don't check 300 characters of the header that contains the timestamp. 996 (let* ((beg (and auto-save
997 (let ((checksum (and auto-save (md5 (current-buffer) 997 (save-excursion
998 (+ (point-min) 300) (point-max) 998 (goto-char (point-min))
999 'emacs-mule)))) 999 ;; Don't check the header with changing timestamp
1000 (unless (and auto-save (equal checksum desktop-file-checksum)) 1000 (and (search-forward "Global section" nil t)
1001 ;; Also skip the timestamp in desktop-saved-frameset
1002 ;; if it's saved in the first non-header line
1003 (search-forward "desktop-saved-frameset"
1004 (line-beginning-position 3) t)
1005 ;; This is saved after the timestamp
1006 (search-forward (format "%S" desktop--app-id) nil t))
1007 (point))))
1008 (checksum (and beg (md5 (current-buffer) beg (point-max) 'emacs-mule))))
1009 (unless (and checksum (equal checksum desktop-file-checksum))
1001 (let ((coding-system-for-write 'emacs-mule)) 1010 (let ((coding-system-for-write 'emacs-mule))
1002 (write-region (point-min) (point-max) (desktop-full-file-name) nil 'nomessage)) 1011 (write-region (point-min) (point-max) (desktop-full-file-name) nil 'nomessage))
1003 (setq desktop-file-checksum checksum) 1012 (setq desktop-file-checksum checksum)
@@ -1199,21 +1208,21 @@ Called by the timer created in `desktop-auto-save-set-timer'."
1199 ;; Save only to own desktop file. 1208 ;; Save only to own desktop file.
1200 (eq (emacs-pid) (desktop-owner)) 1209 (eq (emacs-pid) (desktop-owner))
1201 desktop-dirname) 1210 desktop-dirname)
1202 (desktop-save desktop-dirname nil t)) 1211 (desktop-save desktop-dirname nil t)))
1203 (desktop-auto-save-set-timer))
1204 1212
1205(defun desktop-auto-save-set-timer () 1213(defun desktop-auto-save-set-timer ()
1206 "Reset the auto-save timer. 1214 "Set the auto-save timer.
1207Cancel any previous timer. When `desktop-auto-save-timeout' is a positive 1215Cancel any previous timer. When `desktop-auto-save-timeout' is a positive
1208integer, start a new timer to call `desktop-auto-save' in that many seconds." 1216integer, start a new idle timer to call `desktop-auto-save' repeatedly
1217after that many seconds of idle time."
1209 (when desktop-auto-save-timer 1218 (when desktop-auto-save-timer
1210 (cancel-timer desktop-auto-save-timer) 1219 (cancel-timer desktop-auto-save-timer)
1211 (setq desktop-auto-save-timer nil)) 1220 (setq desktop-auto-save-timer nil))
1212 (when (and (integerp desktop-auto-save-timeout) 1221 (when (and (integerp desktop-auto-save-timeout)
1213 (> desktop-auto-save-timeout 0)) 1222 (> desktop-auto-save-timeout 0))
1214 (setq desktop-auto-save-timer 1223 (setq desktop-auto-save-timer
1215 (run-with-timer desktop-auto-save-timeout nil 1224 (run-with-idle-timer desktop-auto-save-timeout t
1216 'desktop-auto-save)))) 1225 'desktop-auto-save))))
1217 1226
1218;; ---------------------------------------------------------------------------- 1227;; ----------------------------------------------------------------------------
1219;;;###autoload 1228;;;###autoload