]> git.eshelyaron.com Git - emacs.git/commitdiff
(display-time-file-nonempty-p): Check existence here.
authorRichard M. Stallman <rms@gnu.org>
Thu, 6 Jan 1994 09:24:30 +0000 (09:24 +0000)
committerRichard M. Stallman <rms@gnu.org>
Thu, 6 Jan 1994 09:24:30 +0000 (09:24 +0000)
(display-time-server-down-time): New variable.
(display-time-filter): If accessing mail-spool-time takes too long,
don't try again for twenty minutes.

lisp/time.el

index 3f89438a8021928ce5b775b749747e2ffea74d5e..bcd0ae445fc7d3ad5c799ec803fd5bc296b2f631 100644 (file)
@@ -49,6 +49,10 @@ Nil means 1 <= hh <= 12, and an AM/PM suffix is used.")
 (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.
@@ -97,7 +101,7 @@ After each update, `display-time-hook' is run with `run-hooks'."
                                     (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
@@ -107,15 +111,30 @@ After each update, `display-time-hook' is run with `run-hooks'."
            (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
@@ -128,6 +147,7 @@ After each update, `display-time-hook' is run with `run-hooks'."
   (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