From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/15852 Path: news.gmane.org!not-for-mail From: William Gardella Newsgroups: gmane.emacs.gnus.user Subject: A Gnus Biff Date: Fri, 28 Sep 2012 17:58:49 -0400 Message-ID: <871uhl24iu.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1348869547 25902 80.91.229.3 (28 Sep 2012 21:59:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 28 Sep 2012 21:59:07 +0000 (UTC) To: info-gnus-english-mXXj517/zsQ@public.gmane.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org-mXXj517/zsQ@public.gmane.org Fri Sep 28 23:59:12 2012 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1THiaW-0002Nu-BF for gegu-info-gnus-english@m.gmane.org; Fri, 28 Sep 2012 23:59:12 +0200 Original-Received: from localhost ([::1]:35884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THiaR-0003Zp-7m for gegu-info-gnus-english@m.gmane.org; Fri, 28 Sep 2012 17:59:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THiaO-0003Zk-CF for info-gnus-english-mXXj517/zsQ@public.gmane.org; Fri, 28 Sep 2012 17:59:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THiaM-0006AN-3o for info-gnus-english-mXXj517/zsQ@public.gmane.org; Fri, 28 Sep 2012 17:59:04 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:40218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THiaL-0006A6-PN for info-gnus-english-mXXj517/zsQ@public.gmane.org; Fri, 28 Sep 2012 17:59:02 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1THiaO-0002Jo-JE for info-gnus-english-mXXj517/zsQ@public.gmane.org; Fri, 28 Sep 2012 23:59:04 +0200 Original-Received: from c-24-131-17-1.hsd1.pa.comcast.net ([24.131.17.1]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 28 Sep 2012 23:59:04 +0200 Original-Received: from gardellawg by c-24-131-17-1.hsd1.pa.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 28 Sep 2012 23:59:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 122 Original-X-Complaints-To: usenet-dbVV3NMTNubNLxjTenLetw@public.gmane.org X-Gmane-NNTP-Posting-Host: c-24-131-17-1.hsd1.pa.comcast.net X-Archive: encrypt User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) Cancel-Lock: sha1:aCEZHdG1nEmtf51Jy4W5AmWlyCk= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: info-gnus-english-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org-mXXj517/zsQ@public.gmane.org Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.gnus.user:15852 Archived-At: --=-=-= Content-Type: text/plain Hey, I'm in the process of writing a simple "biff" for Gnus, to notify me if one or more of a list of designated Gnus groups has unread messages in it (see below). So far it crudely works, and is suitable for use interactively or by `display-time-mail-function' if you want "Mail" to appear in the mode line for Gnus messages instead of mails in your local mailspool. What it doesn't have as yet, as you'll see, is very good error handling. I get my data from the function `gnus-list-of-unread-articles' which I've just ham-fistedly wrapped in an (ignore-errors ...) form. This makes it silent enough to be suitable for use on a timer, e.g. with display-time, but it means that if a group name is invalid, the whole thing just returns nil as though there was no message in any group. Also, the way I've done it, if this is loaded by display-time in your initialization file, it will try to check (of course!). But in doing so, it doesn't fully start up Gnus. It enters some sort of nether state, where it checks my ~/.authinfo.gpg and makes some IMAP+NNTP connections, but there's no *Group* buffer, and the function continues to return nil until Gnus is actually started. Is there a function or variable I could use as a condition to determine whether Gnus is actually "running?" Eval-after-load is probably not quite right, because Gnus is not exactly a normal Elisp package, and it's not that I need some function to be available--it's that the group data hasn't been populated yet until Gnus is running. I also considered using the variable `gnus-demon-timers' as a condition, since the daemon timers are started when gnus starts/restarts and removed when it exits, and someone who wants a biff probably does use gnus-demon for periodic message checking. Is that a kludge? Is there a better way to check the status of Gnus? Thanks in advance for your thoughts, WGG --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=wg-gnus-biff.el Content-Transfer-Encoding: quoted-printable ;;; wg-gnus-biff.el --- Dead simple Gnus biff ;; Copyright (C) 2012 William Gardella ;; Author: William Gardella ;; Keywords: comm, mail ;; This file is NOT part of GNU Emacs. ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;;=20 ;;; Code: (defvar wg/gnus-biff-groups nil "List of Gnus groups whose unread articles should be tracked by `wg/gnus-biff'. Each element of the list should be a string containing the name of a Gnus group to be tracked. The group names should be spelled out just as they are in your *Group* buffer when Gnus is running.") (defun wg/gnus-biff () "Check `wg/gnus-biff-groups' for unread articles. If used programmatically, return a number if there are unread articles; otherwise return nil. If used as a command, also print a nice message for the user in the echo area. This function can be used as `display-time-mail-function' for putting a mail notification in the mode line. TODO/Caveat: Nicer error handling, instead of just wrapping all Gnus interaction in (ignore-errors)! At the moment, this function silently ignores all Gnus-related errors (Gnus not running, `wg/gnus-biff-groups' contains an invalid group, etc.) and returns nil." (interactive) (let* ((notreadyet (ignore-errors (mapcar 'gnus-list-of-unread-articles wg/gnus-biff-groups))) (notreadyet-subtotal (mapcar 'length notreadyet)) (notreadyet-total (apply '+ notreadyet-subtotal))) (if (called-interactively-p 'interactive) (cond ((zerop notreadyet-total) (message "No unread articles.")) ((=3D 1 notreadyet-total) (message "You have 1 unread article.")) (notreadyet-total (message "You have %s unread articles." notreadyet-total))) (unless (zerop notreadyet-total) notreadyet-total)))) =09=20=20=20=20=20 (provide 'wg-gnus-biff) ;;; wg-gnus-biff.el ends here --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ info-gnus-english mailing list info-gnus-english-mXXj517/zsQ@public.gmane.org https://lists.gnu.org/mailman/listinfo/info-gnus-english --=-=-=--