Mercurial > emacs
comparison lisp/time.el @ 14638:46556543f4e6
(display-time-update): New subroutine broken out from
display-time-event-handler.
(display-time): Add hook to rmail-get-new-mail-hook.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Wed, 21 Feb 1996 21:33:35 +0000 |
parents | c1154020b9c3 |
children | 87d459e75dad |
comparison
equal
deleted
inserted
replaced
14637:89952d6af6c2 | 14638:46556543f4e6 |
---|---|
72 (or (memq 'display-time-string global-mode-string) | 72 (or (memq 'display-time-string global-mode-string) |
73 (setq global-mode-string | 73 (setq global-mode-string |
74 (append global-mode-string '(display-time-string)))) | 74 (append global-mode-string '(display-time-string)))) |
75 (timer-set-time display-time-timer (current-time) display-time-interval) | 75 (timer-set-time display-time-timer (current-time) display-time-interval) |
76 (timer-set-function display-time-timer 'display-time-event-handler) | 76 (timer-set-function display-time-timer 'display-time-event-handler) |
77 (timer-activate display-time-timer)) | 77 (timer-activate display-time-timer) |
78 ;; When you get new mail, clear "Mail" from the mode line. | |
79 (add-hook 'rmail-get-new-mail-hook 'display-time-event-handler)) | |
78 | 80 |
79 (defvar display-time-string-forms | 81 (defvar display-time-string-forms |
80 '((if display-time-day-and-date | 82 '((if display-time-day-and-date |
81 (format "%s %s %s " dayname monthname day) | 83 (format "%s %s %s " dayname monthname day) |
82 "") | 84 "") |
100 (if mail \" Mail\" \"\")) | 102 (if mail \" Mail\" \"\")) |
101 | 103 |
102 would give mode line times like `94/12/30 21:07:48 (UTC)'.") | 104 would give mode line times like `94/12/30 21:07:48 (UTC)'.") |
103 | 105 |
104 (defun display-time-event-handler () | 106 (defun display-time-event-handler () |
107 (display-time-update) | |
108 ;; Do redisplay right now, if no input pending. | |
109 (sit-for 0)) | |
110 | |
111 ;; Update the display-time info for the mode line | |
112 ;; but don't redisplay right now. This is used for | |
113 ;; things like Rmail `g' that want to force an update | |
114 ;; which can wait for the next redisplay. | |
115 (defun display-time-update () | |
105 (let* ((now (current-time)) | 116 (let* ((now (current-time)) |
106 (time (current-time-string now)) | 117 (time (current-time-string now)) |
107 (load (condition-case () | 118 (load (condition-case () |
108 (if (zerop (car (load-average))) "" | 119 (if (zerop (car (load-average))) "" |
109 (let ((str (format " %03d" (car (load-average))))) | 120 (let ((str (format " %03d" (car (load-average))))) |
150 (setq display-time-string | 161 (setq display-time-string |
151 (mapconcat 'eval display-time-string-forms "")) | 162 (mapconcat 'eval display-time-string-forms "")) |
152 ;; This is inside the let binding, but we are not going to document | 163 ;; This is inside the let binding, but we are not going to document |
153 ;; what variables are available. | 164 ;; what variables are available. |
154 (run-hooks 'display-time-hook)) | 165 (run-hooks 'display-time-hook)) |
155 (force-mode-line-update) | 166 (force-mode-line-update)) |
156 ;; Do redisplay right now, if no input pending. | |
157 (sit-for 0)) | |
158 | 167 |
159 (defun display-time-file-nonempty-p (file) | 168 (defun display-time-file-nonempty-p (file) |
160 (and (file-exists-p file) | 169 (and (file-exists-p file) |
161 (< 0 (nth 7 (file-attributes (file-chase-links file)))))) | 170 (< 0 (nth 7 (file-attributes (file-chase-links file)))))) |
162 | 171 |