all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Cecil Westerhof <Cecil@decebal.nl>
To: help-gnu-emacs@gnu.org
Subject: Can this be improved
Date: Mon, 15 Sep 2014 10:53:37 +0200	[thread overview]
Message-ID: <87wq95jmcu.fsf@Equus.decebal.nl> (raw)

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


                 reply	other threads:[~2014-09-15  8:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wq95jmcu.fsf@Equus.decebal.nl \
    --to=cecil@decebal.nl \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.