From 2b777cd9a2bb84a5d3c3b14c70eb2efc0b8de124 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Fri, 7 Feb 2014 09:44:29 +0200 Subject: [PATCH] * lisp/desktop.el (desktop-save-mode): Call `desktop-auto-save-set-timer' when enabling, and `desktop-auto-save-cancel-timer' when disabling. (desktop-auto-save-cancel-timer): New function with some code from `desktop-auto-save-set-timer'. (after-init-hook): Don't call `desktop-auto-save-set-timer'. Instead of setting `desktop-save-mode' to nil, call `desktop-save-mode' with arg 0. Fixes: debbugs:16630 --- lisp/ChangeLog | 10 ++++++++++ lisp/desktop.el | 17 +++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 97fc72e90ed..ca224a78108 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2014-02-07 Juri Linkov + + * desktop.el (desktop-save-mode): Call `desktop-auto-save-set-timer' + when enabling, and `desktop-auto-save-cancel-timer' when disabling. + (desktop-auto-save-cancel-timer): New function with some code from + `desktop-auto-save-set-timer'. + (after-init-hook): Don't call `desktop-auto-save-set-timer'. + Instead of setting `desktop-save-mode' to nil, call + `desktop-save-mode' with arg 0. (Bug#16630) + 2014-02-07 Glenn Morris * hi-lock.el (hi-lock-auto-select-face, hi-lock-line-face-buffer) diff --git a/lisp/desktop.el b/lisp/desktop.el index 78ecc2f5376..161ddc717cc 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -162,7 +162,10 @@ If Desktop Save mode is enabled, the state of Emacs is saved from one session to another. See variable `desktop-save' and function `desktop-read' for details." :global t - :group 'desktop) + :group 'desktop + (if desktop-save-mode + (desktop-auto-save-set-timer) + (desktop-auto-save-cancel-timer))) (defun desktop-save-mode-off () "Disable `desktop-save-mode'. Provided for use in hooks." @@ -1216,15 +1219,18 @@ Called by the timer created in `desktop-auto-save-set-timer'." Cancel any previous timer. When `desktop-auto-save-timeout' is a positive 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)) + (desktop-auto-save-cancel-timer) (when (and (integerp desktop-auto-save-timeout) (> desktop-auto-save-timeout 0)) (setq desktop-auto-save-timer (run-with-idle-timer desktop-auto-save-timeout t 'desktop-auto-save)))) +(defun desktop-auto-save-cancel-timer () + (when desktop-auto-save-timer + (cancel-timer desktop-auto-save-timer) + (setq desktop-auto-save-timer nil))) + ;; ---------------------------------------------------------------------------- ;;;###autoload (defun desktop-revert () @@ -1465,10 +1471,9 @@ If there are no buffers left to create, kill the timer." (let ((key "--no-desktop")) (when (member key command-line-args) (setq command-line-args (delete key command-line-args)) - (setq desktop-save-mode nil))) + (desktop-save-mode 0))) (when desktop-save-mode (desktop-read) - (desktop-auto-save-set-timer) (setq inhibit-startup-screen t)))) ;; So we can restore vc-dir buffers. -- 2.39.2