X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fgnus-demon.el;h=d0baf25d5d9682abdcab910b052a793b9659689a;hb=6910044663bc77081e08faabd6385cd34a9c8f5d;hp=2f9952241aa85cf02ada2195cf010f68d5024def;hpb=f2f9c8e1c2d80a591d0d03fd62deae37f4f19f73;p=gnus diff --git a/lisp/gnus-demon.el b/lisp/gnus-demon.el index 2f9952241..d0baf25d5 100644 --- a/lisp/gnus-demon.el +++ b/lisp/gnus-demon.el @@ -102,6 +102,7 @@ Emacs has been idle for IDLE `gnus-demon-timestep's." "Run FUNC if Emacs has been idle for longer than IDLE seconds." (unless gnus-inhibit-demon (when (or (not idle) + (and (eq idle t) (> (gnus-demon-idle-since) 0)) (<= idle (gnus-demon-idle-since))) (with-local-quit (ignore-errors @@ -115,6 +116,7 @@ Emacs has been idle for IDLE `gnus-demon-timestep's." ;; Set up the timer. (let* ((func (nth 0 handler)) (time (nth 1 handler)) + (time-type (type-of time)) (idle (nth 2 handler)) ;; Compute time according with timestep. ;; If t, replace by 1 @@ -123,33 +125,31 @@ Emacs has been idle for IDLE `gnus-demon-timestep's." ((null time) nil) ((stringp time) - (gnus-demon-time-to-step time)) + (* (gnus-demon-time-to-step time) gnus-demon-timestep)) (t (* time gnus-demon-timestep)))) + (idle (if (numberp idle) + (* idle gnus-demon-timestep) + idle)) + (timer (cond - ;; (func number t) - ;; Call when Emacs has been idle for `time' - ((and (numberp time) (eq idle t)) - (run-with-timer time time 'gnus-demon-run-callback func time)) - ;; (func number number) - ;; Call every `time' when Emacs has been idle for `idle' - ((and (numberp time) (numberp idle)) - (run-with-timer time time 'gnus-demon-run-callback func idle)) ;; (func nil number) ;; Only call when Emacs has been idle for `idle' ((and (null time) (numberp idle)) - (run-with-idle-timer (* idle gnus-demon-timestep) t - 'gnus-demon-run-callback func)) - ;; (func number nil) + (run-with-idle-timer idle t 'gnus-demon-run-callback func)) + ;; (func number any) ;; Call every `time' - ((and (numberp time) (null idle)) - (run-with-timer time time 'gnus-demon-run-callback func))))) + ((eq time-type 'integer) + (run-with-timer time time 'gnus-demon-run-callback func idle)) + ;; (func string any) + ((eq time-type 'string) + (run-with-timer time (* 24 60 60) 'gnus-demon-run-callback func idle))))) (when timer (add-to-list 'gnus-demon-timers timer))))) (defun gnus-demon-time-to-step (time) - "Find out how many seconds to TIME, which is on the form \"17:43\"." + "Find out how many steps to TIME, which is on the form \"17:43\"." (let* ((now (current-time)) ;; obtain NOW as discrete components -- make a vector for speed (nowParts (decode-time now))