emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] display-time-mail-icon and directory


From: Pavel Janík
Subject: [PATCH] display-time-mail-icon and directory
Date: Sat, 19 Jan 2002 20:42:25 +0100
User-agent: Gnus/5.090005 (Oort Gnus v0.05) Emacs/21.2.50 (i386-suse-linux-gnu)

[ This e-mail solves message nr. 1. from after-21.1.xmail.  ]

Hi,

display-time can display display-time-mail-icon if you have e-mail. It
checks that situation by periodically scanning
display-time-mail-file. This is OK if you use only one file for mail
delivery. I use procmail to sort my e-mails and thus am using directory
~/.Spool which contains one file per folder. I have changed time.el in my
sources so that I can too see this icon:

--- time.el.~1.73.~     Sat Jan 19 15:07:56 2002
+++ time.el     Sat Jan 19 20:40:59 2002
@@ -1,6 +1,6 @@
 ;;; time.el --- display time, load and mail indicator in mode line of Emacs
 
-;; Copyright (C) 1985, 86, 87, 93, 94, 96, 2000, 2001
+;; Copyright (C) 1985, 86, 87, 93, 94, 96, 2000, 2001, 2002
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
@@ -44,9 +44,18 @@
                 (file :format "%v"))
   :group 'display-time)
 
+(defcustom display-time-mail-directory nil
+  "*Name of mail inbox directory, for indicating existence of new mail.
+Non-nil and not a string means don't check for mail.
+When nil, no checking for mail in directory is done."
+  :type '(choice (const :tag "None" nil)
+                (directory :format "%v"))
+  :group 'display-time)
+
 (defcustom display-time-mail-function nil
   "*Function to call, for indicating existence of new mail.
-nil means use the default method of checking `display-time-mail-file'."
+nil means use the default method of checking `display-time-mail-file'
+or files in `display-time-mail-directory'."
   :type '(choice (const :tag "Default" nil)
                 (function))
   :group 'display-time)
@@ -118,7 +127,8 @@
   :type 'face)
 
 (defvar display-time-mail-icon
-  (find-image '((:type xbm :file "letter.xbm" :ascent center)))
+  (find-image '((:type xpm :file "letter.xpm" :ascent center)
+               (:type xbm :file "letter.xbm" :ascent center)))
   "Image specification to offer as the mail indicator on a graphic
 display.  See `display-time-use-mail-icon' and
 `display-time-mail-face'.")
@@ -158,7 +168,7 @@
                             ,@(list :background (face-attribute
                                                  display-time-mail-face
                                                  :background)))
-                'help-echo "mouse-2: Read mail"
+                'help-echo "You have new mail; mouse-2: Read mail"
                 'local-map (make-mode-line-mouse-map 'mouse-2
                                                      read-mail-command)))
       ""))
@@ -214,6 +224,19 @@
   (display-time-update)
   (sit-for 0))
 
+(defun display-time-mail-check-directory ()
+  (let ((mail-files (directory-files display-time-mail-directory t))
+       (size 0))
+    (while (and mail-files (= size 0))
+      ;; Count size of regular files only.
+      (setq size (+ size (or (and (file-regular-p (car mail-files))
+                                 (nth 7 (file-attributes (car mail-files))))
+                            0)))
+      (setq mail-files (cdr mail-files)))
+    (if (> size 0)
+       size
+      nil)))
+
 ;; Update the display-time info for the mode line
 ;; but don't redisplay right now.  This is used for
 ;; things like Rmail `g' that want to force an update
@@ -247,6 +270,8 @@
                                       (user-login-name))))
         (mail (or (and display-time-mail-function
                        (funcall display-time-mail-function))
+                  (and display-time-mail-directory
+                       (display-time-mail-check-directory))
                   (and (stringp mail-spool-file)
                        (or (null display-time-server-down-time)
                            ;; If have been down for 20 min, try again.


I have also added XPM version of letter.xbm which is not transparent (it is
white where original file is transparent). This IMHO look much better.

What do you think?
-- 
Pavel Janík

I have decided to leave lkml because everybody else is doing it too.
                  -- Matthew Fredrickson in lkml



reply via email to

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