aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-06-15 22:11:48 +0000
committerRichard M. Stallman1998-06-15 22:11:48 +0000
commite9d7cff0fa3f3a4b9f65794ae79c6e4022d4cf42 (patch)
treea384c6b4b08f8aa1a5c96de117930855009ce57d
parent416cd771be9f138ddd77ff21f2c059a68855b680 (diff)
downloademacs-e9d7cff0fa3f3a4b9f65794ae79c6e4022d4cf42.tar.gz
emacs-e9d7cff0fa3f3a4b9f65794ae79c6e4022d4cf42.zip
(midnight-mode): New variable.
(midnight-timer-function): New function. (midnight-delay-set): Make the timer run midnight-timer-function.
-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.