Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 240dfedfff
Fetching contributors…

Cannot retrieve contributors at this time

76 lines (61 sloc) 2.455 kb
;;; wg-gnus-biff.el --- Dead simple Gnus biff
;; Copyright (C) 2012 William Gardella
;; Author: William Gardella <wgg2 at pitt dot edu>;
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; 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."))
((= 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))))
(provide 'wg-gnus-biff)
;;; wg-gnus-biff.el ends here
Jump to Line
Something went wrong with that request. Please try again.