Mercurial > emacs
changeset 5463:e277328474cc
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 06 Jan 1994 09:24:30 +0000 |
parents | 09820fbab8d1 |
children | 4823e14b1314 |
files | lisp/time.el |
diffstat | 1 files changed, 27 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/time.el Thu Jan 06 09:22:49 1994 +0000 +++ b/lisp/time.el Thu Jan 06 09:24:30 1994 +0000 @@ -49,6 +49,10 @@ (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 @@ (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 @@ (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 @@ (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