(defvar display-time-hook nil
"* List of functions to be called when the time is updated on the mode line.")
+(defvar display-time-server-down-time nil
+ "Time when mail file's file system was recorded to be down.
+If that file system seems to be up, the value is nil.")
+
;;;###autoload
(defun display-time ()
"Display current time, load level, and mail flag in mode line of each buffer.
(or (getenv "LOGNAME")
(getenv "USER")
(user-login-name)))))
- hour am-pm-flag)
+ hour am-pm-flag mail-flag)
(setq hour (read (substring time 11 13)))
(if (not display-time-24hr-format)
(progn
(if (= hour 0)
(setq hour 12))))
(setq am-pm-flag ""))
+ (setq mail-flag
+ (if (and (or (null display-time-server-down-time)
+ ;; If have been down for 20 min, try again.
+ (> (- (nth 1 (current-time))
+ display-time-server-down-time)
+ 1200))
+ (let ((start-time (current-time)))
+ (prog1
+ (display-time-file-nonempty-p mail-spool-file)
+ (if (> (- (nth 1 (current-time)) (nth 1 start-time))
+ 20)
+ ;; Record that mail file is not accessible.
+ (setq display-time-server-down-time
+ (nth 1 (current-time)))
+ ;; Record that mail file is accessible.
+ (setq display-time-server-down-time nil))
+ )))
+ " Mail"
+ ""))
(setq display-time-string
(concat (format "%d" hour) (substring time 13 16)
am-pm-flag
load
- (if (and (file-exists-p mail-spool-file)
- ;; file not empty?
- (display-time-file-nonempty-p mail-spool-file))
- " Mail"
- "")))
+ mail-flag))
;; Append the date if desired.
(if display-time-day-and-date
(setq display-time-string
(sit-for 0))
(defun display-time-file-nonempty-p (file)
- (< 0 (nth 7 (file-attributes (file-chase-links file)))))
+ (and (file-exists-p file)
+ (< 0 (nth 7 (file-attributes (file-chase-links file))))))
;;; time.el ends here