From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/80953 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: Thu, 26 Jan 2012 09:33:05 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary_(ID_1uM9ACprp+tdTnSAn7nvkA)" X-Trace: dough.gmane.org 1327566892 11469 80.91.229.12 (26 Jan 2012 08:34:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 26 Jan 2012 08:34:52 +0000 (UTC) Cc: ding@gnus.org To: Lars Magne Ingebrigtsen Original-X-From: ding-owner+M29235@lists.math.uh.edu Thu Jan 26 09:34:43 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 1RqKn4-0004S7-WB for ding-account@gmane.org; Thu, 26 Jan 2012 09:34:43 +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 1RqKmb-0003AE-5m; Thu, 26 Jan 2012 02:34:13 -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 1RqKmY-00039y-8A for ding@lists.math.uh.edu; Thu, 26 Jan 2012 02:34:10 -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 1RqKmR-0002EK-L4 for ding@lists.math.uh.edu; Thu, 26 Jan 2012 02:34:07 -0600 Original-Received: from a.relay.invitel.net ([62.77.203.3]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1RqKmQ-00075K-4V; Thu, 26 Jan 2012 09:34:02 +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 3F22511A2B1; Thu, 26 Jan 2012 09:33:59 +0100 (CET) Original-Received: from nedu.dyndns.org ([87.97.49.78]) by mail.invitel.hu (Invitel Messaging Server) with ESMTPA id <0LYE00B2DD4KQ360@invitel.hu>; Thu, 26 Jan 2012 09:33:56 +0100 (CET) Original-Received: from EV001A4B593FDA (localhost [127.0.0.1]) by nedu.dyndns.org (Postfix) with ESMTP id 86AE4452809; Thu, 26 Jan 2012 09:33:55 +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:80953 Archived-At: --Boundary_(ID_1uM9ACprp+tdTnSAn7nvkA) Content-type: text/plain; charset=utf-8 Content-transfer-encoding: quoted-printable Vida G=C3=A1bor writes: > 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. I've fixed two more bugs: one that I had introduced with my previous modification and one that the IDLE should be interpreted as minutes and passed to run-with-timer in seconds (according to the documentation). The attached diff contains every hunks I posted before. --=20 Best regards, G=C3=A1bor --Boundary_(ID_1uM9ACprp+tdTnSAn7nvkA) 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..c91c725 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,32 @@ 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) + ;; (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_1uM9ACprp+tdTnSAn7nvkA)--