[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

time.el and display-time-mail-function

From: Jason Bastek
Subject: time.el and display-time-mail-function
Date: 17 Aug 2005 00:49:51 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

My mail system was recently converted from mbox to "maildir++", and
while my mailreader (vm) is able to deal with this, I soon found that
display-time was not.

For anyone not using it, display-time can be used to put the string
"Mail" into your status line when you have new mail.  (It also displays
the current time)  It does this by periodically checking the mail
spool file.

With maildir++, there is no longer a single spool file to watch, there
is a directory of files.  If there are any files in that directory,
you have new mail.  It seemed that time.el anticipated something like
this, because it has an optional "display-time-mail-function", which I
defined as follows:

(defun my-check-mail-function ()
  (let ((result (if (directory-files (concat (getenv "MAIL") "/new")
                                     nil "panix")
(setq display-time-mail-function 'my-check-mail-function)

However after setting this up, the status line contained "Mail" and it
never went away, even after I read all my new mail.

Looking at time.el some more, I think there's an error in the logic of
the display-time-update function.  The problem is that, if the
display-time-mail-function returns nil (indicating that I have no new
mail in my maildir++ folder), the function will continue trying other
ways to find new mail:

         (mail (or (and display-time-mail-function
                        (funcall display-time-mail-function))
                   (and (stringp mail-spool-file)
                        ... ;Stuff it shouldn't be doing for maildir++

I think that "or" should be change to a "cond", or maybe just an "if":

         (mail (if display-time-mail-function
                   (funcall display-time-mail-function)
                 (and (stringp mail-spool-file)

This would behave correctly, i.e. if my display-time-mail-function
returns nil, it will stop there and realize there's no new mail,
rather than continue trying alternate methods.

Since I didn't want to make a local modified time.el, a small hack was
enough to get it to work correctly:

(setq display-time-mail-file t) ;To trick time.el (display-time-update)

This setting, while seemingly meaningless, will force time.el to not
try the alternate methods when display-time-mail-function returns nil.

Just thought I'd throw this out there, in case any other display-time
users run into a similar situation.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]