diff options
| author | Richard M. Stallman | 1994-01-06 09:24:30 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-01-06 09:24:30 +0000 |
| commit | c44565c8369526ba9e95be4dc3d54b0ca90095cd (patch) | |
| tree | 6a0da8756e80198fe2a387568aabd6bcad18fec0 | |
| parent | 9897e2d538688ed4ef8db43bfb7f68f3f7487e50 (diff) | |
| download | emacs-c44565c8369526ba9e95be4dc3d54b0ca90095cd.tar.gz emacs-c44565c8369526ba9e95be4dc3d54b0ca90095cd.zip | |
(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.
| -rw-r--r-- | lisp/time.el | 34 |
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.") | |||
| 49 | (defvar display-time-hook nil | 49 | (defvar display-time-hook nil |
| 50 | "* List of functions to be called when the time is updated on the mode line.") | 50 | "* List of functions to be called when the time is updated on the mode line.") |
| 51 | 51 | ||
| 52 | (defvar display-time-server-down-time nil | ||
| 53 | "Time when mail file's file system was recorded to be down. | ||
| 54 | If that file system seems to be up, the value is nil.") | ||
| 55 | |||
| 52 | ;;;###autoload | 56 | ;;;###autoload |
| 53 | (defun display-time () | 57 | (defun display-time () |
| 54 | "Display current time, load level, and mail flag in mode line of each buffer. | 58 | "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'." | |||
| 97 | (or (getenv "LOGNAME") | 101 | (or (getenv "LOGNAME") |
| 98 | (getenv "USER") | 102 | (getenv "USER") |
| 99 | (user-login-name))))) | 103 | (user-login-name))))) |
| 100 | hour am-pm-flag) | 104 | hour am-pm-flag mail-flag) |
| 101 | (setq hour (read (substring time 11 13))) | 105 | (setq hour (read (substring time 11 13))) |
| 102 | (if (not display-time-24hr-format) | 106 | (if (not display-time-24hr-format) |
| 103 | (progn | 107 | (progn |
| @@ -107,15 +111,30 @@ After each update, `display-time-hook' is run with `run-hooks'." | |||
| 107 | (if (= hour 0) | 111 | (if (= hour 0) |
| 108 | (setq hour 12)))) | 112 | (setq hour 12)))) |
| 109 | (setq am-pm-flag "")) | 113 | (setq am-pm-flag "")) |
| 114 | (setq mail-flag | ||
| 115 | (if (and (or (null display-time-server-down-time) | ||
| 116 | ;; If have been down for 20 min, try again. | ||
| 117 | (> (- (nth 1 (current-time)) | ||
| 118 | display-time-server-down-time) | ||
| 119 | 1200)) | ||
| 120 | (let ((start-time (current-time))) | ||
| 121 | (prog1 | ||
| 122 | (display-time-file-nonempty-p mail-spool-file) | ||
| 123 | (if (> (- (nth 1 (current-time)) (nth 1 start-time)) | ||
| 124 | 20) | ||
| 125 | ;; Record that mail file is not accessible. | ||
| 126 | (setq display-time-server-down-time | ||
| 127 | (nth 1 (current-time))) | ||
| 128 | ;; Record that mail file is accessible. | ||
| 129 | (setq display-time-server-down-time nil)) | ||
| 130 | ))) | ||
| 131 | " Mail" | ||
| 132 | "")) | ||
| 110 | (setq display-time-string | 133 | (setq display-time-string |
| 111 | (concat (format "%d" hour) (substring time 13 16) | 134 | (concat (format "%d" hour) (substring time 13 16) |
| 112 | am-pm-flag | 135 | am-pm-flag |
| 113 | load | 136 | load |
| 114 | (if (and (file-exists-p mail-spool-file) | 137 | mail-flag)) |
| 115 | ;; file not empty? | ||
| 116 | (display-time-file-nonempty-p mail-spool-file)) | ||
| 117 | " Mail" | ||
| 118 | ""))) | ||
| 119 | ;; Append the date if desired. | 138 | ;; Append the date if desired. |
| 120 | (if display-time-day-and-date | 139 | (if display-time-day-and-date |
| 121 | (setq display-time-string | 140 | (setq display-time-string |
| @@ -128,6 +147,7 @@ After each update, `display-time-hook' is run with `run-hooks'." | |||
| 128 | (sit-for 0)) | 147 | (sit-for 0)) |
| 129 | 148 | ||
| 130 | (defun display-time-file-nonempty-p (file) | 149 | (defun display-time-file-nonempty-p (file) |
| 131 | (< 0 (nth 7 (file-attributes (file-chase-links file))))) | 150 | (and (file-exists-p file) |
| 151 | (< 0 (nth 7 (file-attributes (file-chase-links file)))))) | ||
| 132 | 152 | ||
| 133 | ;;; time.el ends here | 153 | ;;; time.el ends here |