From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/66698 Path: news.gmane.org!not-for-mail From: Russ Allbery Newsgroups: gmane.emacs.gnus.general Subject: Re: Restricting frequency of 'g' Date: Sun, 06 Apr 2008 18:30:16 -0700 Organization: The Eyrie Message-ID: <877ifaxxhz.fsf@windlord.stanford.edu> References: <87zls71wod.fsf@windlord.stanford.edu> <86wsnbjiyp.fsf@ankh.home.genehack.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1207531844 19672 80.91.229.12 (7 Apr 2008 01:30:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Apr 2008 01:30:44 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M15182@lists.math.uh.edu Mon Apr 07 03:31:16 2008 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.50) id 1JigCX-0002sy-QZ for ding-account@gmane.org; Mon, 07 Apr 2008 03:31:14 +0200 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 1JigBp-0003my-DS; Sun, 06 Apr 2008 20:30:29 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1JigBo-0003mn-7u for ding@lists.math.uh.edu; Sun, 06 Apr 2008 20:30:28 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.67) (envelope-from ) id 1JigBf-0007su-Ta for ding@lists.math.uh.edu; Sun, 06 Apr 2008 20:30:28 -0500 Original-Received: from smtp1.stanford.edu ([171.67.22.28]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1JigBp-0003w3-00 for ; Mon, 07 Apr 2008 03:30:29 +0200 Original-Received: from smtp1.stanford.edu (localhost.localdomain [127.0.0.1]) by localhost (Postfix) with SMTP id 10AEE2D6950 for ; Sun, 6 Apr 2008 18:30:17 -0700 (PDT) Original-Received: from windlord.stanford.edu (windlord.Stanford.EDU [171.64.19.147]) by smtp1.stanford.edu (Postfix) with ESMTP id C85CE2D6978 for ; Sun, 6 Apr 2008 18:30:16 -0700 (PDT) Original-Received: by windlord.stanford.edu (Postfix, from userid 1000) id C54E1E791A; Sun, 6 Apr 2008 18:30:16 -0700 (PDT) In-Reply-To: <86wsnbjiyp.fsf@ankh.home.genehack.org> (John SJ Anderson's message of "Sun\, 06 Apr 2008 07\:55\:42 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-Spam-Score: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:66698 Archived-At: John SJ Anderson 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 "") '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)