mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
(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.
This commit is contained in:
parent
9897e2d538
commit
c44565c836
1 changed files with 27 additions and 7 deletions
34
lisp/time.el
34
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue