From: Russ Allbery <rra@stanford.edu>
To: ding@gnus.org
Subject: Re: Restricting frequency of 'g'
Date: Sun, 06 Apr 2008 18:30:16 -0700 [thread overview]
Message-ID: <877ifaxxhz.fsf@windlord.stanford.edu> (raw)
In-Reply-To: <86wsnbjiyp.fsf@ankh.home.genehack.org> (John SJ Anderson's message of "Sun\, 06 Apr 2008 07\:55\:42 -0400")
John SJ Anderson <genehack@genehack.org> writes:
> I had the same problem; so I came up with this and then retrained
> myself to hit 'F6' instead of 'g'.
>
> (defvar jsja/last-mail-check (float-time)
> "last time i checked mail via magic key")
> (defvar jsja/mail-check-interval (* 60 5)
> "how long i should wait before checking mail")
> (defun jsja/switch-to-gnus ()
> "Bring Gnus *Group* buffer to front, starting Gnus if needed"
> (interactive)
> (if (or (not (fboundp 'gnus-alive-p))
> (not (gnus-alive-p)))
> (gnus)
> (switch-to-buffer "*Group*")
> (delete-other-windows)
> (setq next-mail-check (+ jsja/last-mail-check jsja/mail-check-interval))
> (if (< (float-time) next-mail-check)
> (message (concat
> "no gnus is good news ("
> (int-to-string (floor (- next-mail-check (float-time))))
> " seconds until next check allowed)" ))
> (gnus-group-get-new-news 1)
> (setq jsja/last-mail-check (float-time)))))
> (global-set-key (kbd "<f6>") 'jsja/switch-to-gnus)
Thanks! This gave me the logic that I wanted. I'm now using this (I
suppose I'm supposed to use rra/ instead of rra- as a prefix for private
functions, aren't I?):
;; Use this function instead of gnus-group-get-new-news as the action for g.
;; It changes the level of subscribedness that it checks based on how long
;; it's been since the previous check and tries to throttle checking mail too
;; often.
(defvar rra-last-mail-important-check (float-time)
"The last time I checked mail in important groups.")
(defvar rra-last-mail-normal-check (float-time)
"The last time I checked mail in normal groups.")
(defvar rra-last-mail-low-check (float-time)
"The last time I checked mail in low-priority groups.")
(defvar rra-mail-important-check-interval (* 60 15)
"How long I'm required to wait before checking mail in important groups.")
(defvar rra-mail-normal-check-interval (* 60 30)
"How long I'm required to wait before checking mail in normal groups.")
(defvar rra-mail-low-check-interval (* 60 60)
"How long I'm required to wait before checking mail in low-priority groups.")
(defun rra-timed-gnus-group-get-new-news ()
"Get newly arrived articles based on the interval since the last time I've
checked for new articles."
(interactive)
(cond
((> (float-time) (+ rra-last-mail-low-check rra-mail-low-check-interval))
(gnus-group-get-new-news)
(setq rra-last-mail-low-check (float-time))
(setq rra-last-mail-normal-check (float-time))
(setq rra-last-mail-important-check (float-time)))
((> (float-time) (+ rra-last-mail-normal-check
rra-mail-normal-check-interval))
(gnus-group-get-new-news 3)
(setq rra-last-mail-normal-check (float-time))
(setq rra-last-mail-important-check (float-time)))
((> (float-time) (+ rra-last-mail-important-check
rra-mail-important-check-interval))
(gnus-group-get-new-news 1)
(setq rra-last-mail-important-check (float-time)))
(t
(let ((next-check (+ rra-last-mail-important-check
rra-mail-important-check-interval)))
(message (concat "No gnus is good news ("
(int-to-string (floor (- next-check (float-time))))
" seconds until check allowed)"))))))
and rebinding "g" to rra-timed-gnus-group-get-new-news.
--
Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
next prev parent reply other threads:[~2008-04-07 1:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-06 3:36 Russ Allbery
2008-04-06 4:54 ` Bill O'Connor
2008-04-06 6:43 ` Russ Allbery
2008-04-06 11:55 ` John SJ Anderson
2008-04-07 1:30 ` Russ Allbery [this message]
2008-04-07 23:45 ` jidanni
2008-04-08 0:54 ` John SJ Anderson
2008-04-08 3:41 ` Russ Allbery
2008-04-08 21:12 ` a Gnus biff (was: Restricting frequency of 'g') Ted Zlatanov
2008-04-09 13:59 ` a Gnus biff Wes Hardaker
2008-04-08 3:55 ` Restricting frequency of 'g' Dan Nicolaescu
2008-04-09 6:49 ` Dan Nicolaescu
2008-04-09 19:22 ` Reiner Steib
2008-04-12 14:58 ` Mark Plaksin
2008-07-29 21:14 ` Dan Nicolaescu
2008-07-30 18:04 ` Reiner Steib
2009-07-30 19:32 ` Dan Nicolaescu
2010-10-07 6:27 ` Dan Nicolaescu
2010-10-07 20:16 ` Lars Magne Ingebrigtsen
2010-10-07 21:55 ` Russ Allbery
2010-10-08 17:28 ` Ted Zlatanov
2010-10-08 15:14 ` Jason L Tibbitts III
2010-10-09 15:36 ` Lars Magne Ingebrigtsen
2010-10-09 15:50 ` Richard Riley
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=877ifaxxhz.fsf@windlord.stanford.edu \
--to=rra@stanford.edu \
--cc=ding@gnus.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.
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 NNTP newsgroup(s).