]> code.delx.au - gnu-emacs/commitdiff
Don't start the 'midnight' timer twice
authorEli Zaretskii <eliz@gnu.org>
Sun, 27 Mar 2016 15:15:06 +0000 (18:15 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sun, 27 Mar 2016 15:15:06 +0000 (18:15 +0300)
* lisp/midnight.el (midnight-mode): Avoid starting the midnight
timer twice when activating the mode the first time.  (Bug#23123)

lisp/midnight.el

index 0e68eb923cd382a860f1c494150731df9ef21dee..878c5a7f71fcd69eb94604ac589b9f6318794389 100644 (file)
@@ -53,8 +53,12 @@ the time when it is run.")
   "Non-nil means run `midnight-hook' at midnight."
   :global t
   :initialize #'custom-initialize-default
-  (if midnight-mode (timer-activate midnight-timer)
-    (cancel-timer midnight-timer)))
+  ;; Disable first, since the ':initialize' function above already
+  ;; starts the timer when the mode is turned on for the first time,
+  ;; via setting 'midnight-delay', which calls 'midnight-delay-set',
+  ;; which starts the timer.
+  (when (timerp midnight-timer) (cancel-timer midnight-timer))
+  (if midnight-mode (timer-activate midnight-timer)))
 
 ;;; time conversion