summaryrefslogtreecommitdiff
path: root/lisp/midnight.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1998-06-15 22:11:48 +0000
committerRichard M. Stallman <rms@gnu.org>1998-06-15 22:11:48 +0000
commite9d7cff0fa3f3a4b9f65794ae79c6e4022d4cf42 (patch)
treea384c6b4b08f8aa1a5c96de117930855009ce57d /lisp/midnight.el
parent416cd771be9f138ddd77ff21f2c059a68855b680 (diff)
downloademacs-e9d7cff0fa3f3a4b9f65794ae79c6e4022d4cf42.tar.gz
(midnight-mode): New variable.
(midnight-timer-function): New function. (midnight-delay-set): Make the timer run midnight-timer-function.
Diffstat (limited to 'lisp/midnight.el')
-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 @@
"Run something every day at midnight."
:group 'calendar)
+(defcustom midnight-mode t
+ "*Non-nil means run `midnight-hook' at midnight.
+Setting this variable outside customize has no effect;
+call `cancel-timer' or `timer-activate' on `midnight-timer' instead."
+ :type 'boolean
+ :group 'midnight
+ :require 'midnight
+ :version "20.3"
+ :set (lambda (symb val)
+ (set symb val) (require 'midnight)
+ (if val (timer-activate midnight-timer)
+ (cancel-timer midnight-timer))))
+
;;; time conversion
(defun float-time (&optional tm)
@@ -209,7 +222,12 @@ to its second argument."
(when (timerp midnight-timer) (cancel-timer midnight-timer))
(setq midnight-timer
(run-at-time (if (numberp tm) (+ (midnight-next) tm) tm)
- midnight-period 'run-hooks 'midnight-hook)))
+ midnight-period 'midnight-timer-function)))
+
+(defun midnight-timer-function ()
+ "This is the function run by the `midnight-mode' timer once each day."
+ (when midnight-mode
+ (run-hooks 'midnight-hook)))
(defcustom midnight-delay 3600
"*The number of seconds after the midnight when the `midnight-timer' is run.