summaryrefslogtreecommitdiff
path: root/lisp/time.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-01-06 09:24:30 +0000
committerRichard M. Stallman <rms@gnu.org>1994-01-06 09:24:30 +0000
commitc44565c8369526ba9e95be4dc3d54b0ca90095cd (patch)
tree6a0da8756e80198fe2a387568aabd6bcad18fec0 /lisp/time.el
parent9897e2d538688ed4ef8db43bfb7f68f3f7487e50 (diff)
downloademacs-c44565c8369526ba9e95be4dc3d54b0ca90095cd.tar.gz
(display-time-file-nonempty-p): Check existence here.
(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.
Diffstat (limited to 'lisp/time.el')
-rw-r--r--lisp/time.el34
1 files changed, 27 insertions, 7 deletions
diff --git a/lisp/time.el b/lisp/time.el
index 3f89438a802..bcd0ae445fc 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -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