From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/80935 Path: news.gmane.org!not-for-mail From: =?utf-8?Q?Vida_G=C3=A1bor?= Newsgroups: gmane.emacs.gnus.general Subject: Re: HH:MM time spec for gnus-demon-add-handler Date: Tue, 24 Jan 2012 07:35:20 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary_(ID_71zbRId6MHoGRU20U8nMMA)" X-Trace: dough.gmane.org 1327397688 4679 80.91.229.12 (24 Jan 2012 09:34:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 24 Jan 2012 09:34:48 +0000 (UTC) Cc: ding@gnus.org To: Lars Magne Ingebrigtsen Original-X-From: ding-owner+M29217@lists.math.uh.edu Tue Jan 24 10:34:44 2012 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rpcm3-0004Ip-RT for ding-account@gmane.org; Tue, 24 Jan 2012 10:34:44 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1RpclC-0006dh-23; Tue, 24 Jan 2012 03:33:50 -0600 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1RpclA-0006da-Gj for ding@lists.math.uh.edu; Tue, 24 Jan 2012 03:33:48 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1Rpcl6-00010m-58 for ding@lists.math.uh.edu; Tue, 24 Jan 2012 03:33:48 -0600 Original-Received: from a.relay.invitel.net ([62.77.203.3]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1Rpcl4-0007LT-Az; Tue, 24 Jan 2012 10:33:42 +0100 Original-Received: from mail.invitel.hu (mail.invitel.hu [213.163.59.4]) by a.relay.invitel.net (Invitel Core SMTP Transmitter) with ESMTP id DAD5F11A0A8; Tue, 24 Jan 2012 10:33:41 +0100 (CET) Original-Received: from nedu.dyndns.org ([87.97.105.164]) by mail.invitel.hu (Invitel Messaging Server) with ESMTPA id <0LYA00FZ5QK4KN40@invitel.hu>; Tue, 24 Jan 2012 10:33:40 +0100 (CET) Original-Received: from EV001A4B593FDA (localhost [127.0.0.1]) by nedu.dyndns.org (Postfix) with ESMTP id 8C7FF45C568; Tue, 24 Jan 2012 10:33:39 +0100 (CET) In-reply-to: User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.3 (windows-nt) X-Spam-Score: -1.0 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:80935 Archived-At: --Boundary_(ID_71zbRId6MHoGRU20U8nMMA) Content-type: text/plain; charset=utf-8 Content-transfer-encoding: quoted-printable Lars Magne Ingebrigtsen writes: > I've now resurrected this code, which was apparently lost in 2010. Hi Lars! Here comes my findings and a patch that fix them. - `gnus-demon-time-to-step' returns the steps needed to TIME, but run-with-timer requires seconds. - The repeat value in case the time is "HH:MM" should be a day. - There were an other missing -- but documented -- feature when TIME is a number and IDLE is nil when calling `gnus-demon-add-handler'. - And I removed those clauses of the last cond in `gnus-demon-time-to-step' that became unnecessary due to the previous modification. --=20 Regards, G=C3=A1bor --Boundary_(ID_71zbRId6MHoGRU20U8nMMA) Content-type: text/x-patch; NAME=gnus-demon.el.diff Content-transfer-encoding: 7BIT Content-disposition: inline; filename=gnus-demon.el.diff diff --git a/lisp/gnus-demon.el b/lisp/gnus-demon.el index 2f99522..78035f8 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 idle (> (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,28 @@ 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)))) (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) + ;; (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)) --Boundary_(ID_71zbRId6MHoGRU20U8nMMA)--