aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/midnight.el20
1 files changed, 19 insertions, 1 deletions
diff --git a/lisp/midnight.el b/lisp/midnight.el
index 6f85ca3f180..ec5db1fd0d9 100644
--- a/lisp/midnight.el
+++ b/lisp/midnight.el
@@ -42,6 +42,19 @@
42 "Run something every day at midnight." 42 "Run something every day at midnight."
43 :group 'calendar) 43 :group 'calendar)
44 44
45(defcustom midnight-mode t
46 "*Non-nil means run `midnight-hook' at midnight.
47Setting this variable outside customize has no effect;
48call `cancel-timer' or `timer-activate' on `midnight-timer' instead."
49 :type 'boolean
50 :group 'midnight
51 :require 'midnight
52 :version "20.3"
53 :set (lambda (symb val)
54 (set symb val) (require 'midnight)
55 (if val (timer-activate midnight-timer)
56 (cancel-timer midnight-timer))))
57
45;;; time conversion 58;;; time conversion
46 59
47(defun float-time (&optional tm) 60(defun float-time (&optional tm)
@@ -209,7 +222,12 @@ to its second argument."
209 (when (timerp midnight-timer) (cancel-timer midnight-timer)) 222 (when (timerp midnight-timer) (cancel-timer midnight-timer))
210 (setq midnight-timer 223 (setq midnight-timer
211 (run-at-time (if (numberp tm) (+ (midnight-next) tm) tm) 224 (run-at-time (if (numberp tm) (+ (midnight-next) tm) tm)
212 midnight-period 'run-hooks 'midnight-hook))) 225 midnight-period 'midnight-timer-function)))
226
227(defun midnight-timer-function ()
228 "This is the function run by the `midnight-mode' timer once each day."
229 (when midnight-mode
230 (run-hooks 'midnight-hook)))
213 231
214(defcustom midnight-delay 3600 232(defcustom midnight-delay 3600
215 "*The number of seconds after the midnight when the `midnight-timer' is run. 233 "*The number of seconds after the midnight when the `midnight-timer' is run.