"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
set it by calling `midnight-delay-set', or use `custom'.
If you wish, you can use a string instead, it will be passed as the
first argument to `run-at-time'."
- :type 'sexp
+ :type '(choice integer string)
:set #'midnight-delay-set)
(provide 'midnight)