changeset 42998:144c91651228

(display-time-mail-directory): New option. (display-time-mail-function): Update doc-string. (display-time-mail-icon): Use XPM image when available. (display-time-string-forms): Use more descriptive text as help-echo property. (display-time-mail-check-directory): New function. (display-time-update): Use it.
author Pavel Janík <Pavel@Janik.cz>
date Sun, 27 Jan 2002 18:14:55 +0000
parents 4fec5d1a39fa
children 0dd2c7d849f5
files lisp/time.el
diffstat 1 files changed, 29 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/time.el	Sun Jan 27 16:44:10 2002 +0000
+++ b/lisp/time.el	Sun Jan 27 18:14:55 2002 +0000
@@ -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.