unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Can this be improved
@ 2014-09-15  8:53 Cecil Westerhof
  0 siblings, 0 replies; only message in thread
From: Cecil Westerhof @ 2014-09-15  8:53 UTC (permalink / raw)
  To: help-gnu-emacs

I have a few things I poll during idle time in Gnus.

At the moment I have the following structure:
      dcbl-gnus-poll-struct
          (list
           (list :idle          3
                 :function     'dcbl-gnus-delay-send-queue
                 :last-run     'dcbl-gnus-last-time-delay-send
                 :message      "send delayed messages"
                 :wait          5)
           (list :idle          5
                 :function     'dcbl-gnus-group-get-new-news
                 :last-run     'dcbl-gnus-last-time-got-news
                 :message      "getting new news"
                 :prefer-end   15
                 :prefer-start  5
                 :prefer-wait  30
                 :wait         60)
           (list :idle         15
                 :function     'dcbl-gnus-group-expire-all-groups
                 :last-run     'dcbl-gnus-last-time-expired-articles
                 :message      "expire"
                 :wait         (- (/ +seconds-in-day+ +seconds-in-minute+) 2))
           ))

At this moment I have three things I do: sending delayed messages,
getting new news and expiring articles.

Every polling structure needs at least:
- idle:     minutes idle before function is allowed to run
- function: function to run
- last-run: last time function was run
- message:  description used in logging
- wait:     minimum number of minutes between runs

Because I like the messages fetched shortly after the whole hour, I
have also:
- prefer-end:   end minute of preferred period
- prefer-start: start minute of preferred period
- prefer-wait:  minimum number of minutes that the function was not
  run in preferred period

Because with the current data structure it is no use to call the
daemon handler after a minute of idleness I set the Gnus idle daemon
with:
    (gnus-demon-add-handler 'dcbl-gnus-idle-daemon
                            1
                            (let  ((value nil))
                              (apply 'min
                                     (dolist (poll-element dcbl-gnus-poll-struct value)
                                       (push (getf poll-element :wait) value)))))

Is this the correct way to do this, or is there a better way?


By the way gnus-demon-add-handler is correct. Probably a spelling
mistake made long ago.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-09-15  8:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-15  8:53 Can this be improved Cecil Westerhof

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).