;;; ceder-maildir.el -- make display-time aware of Maildir ;; Copyright (C) 2005 Per Cederqvist ;; Author: Per Cederqvist ;; Created: 2005-03-18 ;; Version: 1.2 ;; Keywords: mail, calendar ;; 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 2 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, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ;;; Commentary: ;; By default, M-x display-time will check for new mail in ;; /var/mail/$USER, and expect it to be an mbox file. If you use ;; Maildir, this file will check for the presence of new mail using ;; that format instead. ;; ;; If your incoming Maildir is located in /var/mail/$USER/Maildir, all ;; you have to do to enable this code is to put ;; ;; (require 'ceder-maildir) ;; (ceder-enable-display-time-maildir) ;; ;; in your .emacs. Otherwise, you also have to specify where your ;; primary inbox is: ;; ;; (setq ceder-maildir-dir "/home/ceder/Maildir") ;; (require 'ceder-maildir) ;; (ceder-enable-display-time-maildir) ;; ;; You may also want to change the value of ;; ceder-maildir-boxes-to-check. ;;; Code: (provide 'ceder-maildir) (defvar ceder-maildir-dir (expand-file-name "Maildir" (expand-file-name (user-login-name) "/var/mail")) "*The Maildir that display-time should check for new mail. The default is good for Lysator, but $HOME/Maildir is probably a more common value.") (defvar ceder-maildir-boxes-to-check '("new") "*The mailboxes inside ceder-maildir-dir that should be checked for mail. This is a list of strings. Typically, this is set to '(\"new\") to check for unread mail, or '(\"new\" \"cur\") to check for any mail in the inbox.") (defun ceder-display-time-check-mail-maildir () "Return true if mail exists. Depending on the value of `ceder-maildir-boxes-to-check', this will return true if unseen mail exists, or if any mail exists in the maildir. `ceder-maildir-dir' specifies what maildir to check." ;; FIXME: ceder-maildir-dir should be replaced by a list, and we ;; should loop through that entire list. But this is good enough ;; for me and all those who sort their mail using Gnus instead of ;; Procmail, Sieve or something similar. (catch 'got-mail (let ((mail nil) (boxes ceder-maildir-boxes-to-check)) (while boxes (let ((mails (directory-files (expand-file-name (car boxes) ceder-maildir-dir) nil nil t))) (while mails (cond ((string= (car mails) ".")) ((string= (car mails) "..")) (t (throw 'got-mail t))) (setq mails (cdr mails)))) (setq boxes (cdr boxes)))) nil)) ;;;###autoload (defun ceder-enable-display-time-maildir () "*Make display-time check for mail using maildir." (interactive) ;; Tell display-time to check for mail using the above function. (setq display-time-mail-function 'ceder-display-time-check-mail-maildir) ;; Disable the default method of looking for mail. I found no cleaner ;; way than this... (setq display-time-mail-file "/no-such-file")) ;;; ceder-maildir.el ends here