+ (sit-for 0)
+ (let* ((current (current-time))
+ (timer display-time-timer)
+ ;; Compute the time when this timer will run again, next.
+ (next-time (timer-relative-time
+ (list (aref timer 1) (aref timer 2) (aref timer 3))
+ (* 5 (aref timer 4)) 0)))
+ ;; If the activation time is far in the past,
+ ;; skip executions until we reach a time in the future.
+ ;; This avoids a long pause if Emacs has been suspended for hours.
+ (or (> (nth 0 next-time) (nth 0 current))
+ (and (= (nth 0 next-time) (nth 0 current))
+ (> (nth 1 next-time) (nth 1 current)))
+ (and (= (nth 0 next-time) (nth 0 current))
+ (= (nth 1 next-time) (nth 1 current))
+ (> (nth 2 next-time) (nth 2 current)))
+ (progn
+ (timer-set-time timer (timer-next-integral-multiple-of-time
+ current display-time-interval)
+ display-time-interval)
+ (timer-activate timer)))))
+
+;; Update the display-time info for the mode line
+;; but don't redisplay right now. This is used for
+;; things like Rmail `g' that want to force an update
+;; which can wait for the next redisplay.
+(defun display-time-update ()
+ (let* ((now (current-time))
+ (time (current-time-string now))
+ (load (condition-case ()
+ (if (zerop (car (load-average))) ""
+ (let ((str (format " %03d" (car (load-average)))))
+ (concat (substring str 0 -2) "." (substring str -2))))
+ (error "")))
+ (mail-spool-file (or display-time-mail-file
+ (getenv "MAIL")
+ (concat rmail-spool-directory
+ (user-login-name))))
+ (mail (and (stringp mail-spool-file)
+ (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))))))
+ (24-hours (substring time 11 13))
+ (hour (string-to-int 24-hours))
+ (12-hours (int-to-string (1+ (% (+ hour 11) 12))))
+ (am-pm (if (>= hour 12) "pm" "am"))
+ (minutes (substring time 14 16))
+ (seconds (substring time 17 19))
+ (time-zone (car (cdr (current-time-zone now))))
+ (day (substring time 8 10))
+ (year (substring time 20 24))
+ (monthname (substring time 4 7))
+ (month
+ (cdr
+ (assoc
+ monthname
+ '(("Jan" . "1") ("Feb" . "2") ("Mar" . "3") ("Apr" . "4")
+ ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8")
+ ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12")))))
+ (dayname (substring time 0 3)))
+ (setq display-time-string
+ (mapconcat 'eval display-time-string-forms ""))
+ ;; This is inside the let binding, but we are not going to document
+ ;; what variables are available.
+ (run-hooks 'display-time-hook))
+ (force-mode-line-update))