51 |
(function)) |
(function)) |
52 |
:group 'display-time) |
:group 'display-time) |
53 |
|
|
54 |
|
(defcustom display-time-default-load-average 0 |
55 |
|
"*Which load-average value will be shown in the mode line. |
56 |
|
Almost every system can provide values of load for past 1 minute, past 5 or |
57 |
|
past 15 minutes. The default is to display 1 minute load average." |
58 |
|
:type '(choice (const :tag "1 minute load" 0) |
59 |
|
(const :tag "5 minutes load" 1) |
60 |
|
(const :tag "15 minutes load" 2)) |
61 |
|
:group 'display-time) |
62 |
|
|
63 |
|
(defvar display-time-load-average display-time-default-load-average) |
64 |
|
|
65 |
|
(defcustom display-time-load-average-threshold 0.1 |
66 |
|
"*Load-average values below this value won't be shown in the mode line.") |
67 |
|
|
68 |
;;;###autoload |
;;;###autoload |
69 |
(defcustom display-time-day-and-date nil "\ |
(defcustom display-time-day-and-date nil "\ |
70 |
*Non-nil means \\[display-time] should display day and date as well as time." |
*Non-nil means \\[display-time] should display day and date as well as time." |
80 |
|
|
81 |
(defcustom display-time-24hr-format nil |
(defcustom display-time-24hr-format nil |
82 |
"*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23. |
"*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23. |
83 |
Nil means 1 <= hh <= 12, and an AM/PM suffix is used." |
nil means 1 <= hh <= 12, and an AM/PM suffix is used." |
84 |
:type 'boolean |
:type 'boolean |
85 |
:group 'display-time) |
:group 'display-time) |
86 |
|
|
205 |
display-time-interval) |
display-time-interval) |
206 |
(timer-activate timer))))) |
(timer-activate timer))))) |
207 |
|
|
208 |
|
(defun display-time-next-load-average () |
209 |
|
(interactive) |
210 |
|
(if (= 3 (setq display-time-load-average (1+ display-time-load-average))) |
211 |
|
(setq display-time-load-average 0)) |
212 |
|
(display-time-update) |
213 |
|
(sit-for 0)) |
214 |
|
|
215 |
;; Update the display-time info for the mode line |
;; Update the display-time info for the mode line |
216 |
;; but don't redisplay right now. This is used for |
;; but don't redisplay right now. This is used for |
217 |
;; things like Rmail `g' that want to force an update |
;; things like Rmail `g' that want to force an update |
220 |
(let* ((now (current-time)) |
(let* ((now (current-time)) |
221 |
(time (current-time-string now)) |
(time (current-time-string now)) |
222 |
(load (condition-case () |
(load (condition-case () |
223 |
(if (zerop (car (load-average))) "" |
;; Do not show values less than |
224 |
|
;; `display-time-load-average-threshold'. |
225 |
|
(if (> (* display-time-load-average-threshold 100) |
226 |
|
(nth display-time-load-average (load-average))) |
227 |
|
"" |
228 |
;; The load average number is mysterious, so |
;; The load average number is mysterious, so |
229 |
;; propvide some help. |
;; provide some help. |
230 |
(let ((str (format " %03d" (car (load-average))))) |
(let ((str (format " %03d" (nth display-time-load-average (load-average))))) |
231 |
(propertize |
(propertize |
232 |
(concat (substring str 0 -2) "." (substring str -2)) |
(concat (substring str 0 -2) "." (substring str -2)) |
233 |
'help-echo "System load average"))) |
'local-map (make-mode-line-mouse-map 'mouse-2 |
234 |
|
'display-time-next-load-average) |
235 |
|
'help-echo (concat "System load average for past " |
236 |
|
(if (= 0 display-time-load-average) |
237 |
|
"1 minute" |
238 |
|
(if (= 1 display-time-load-average) |
239 |
|
"5 minutes" |
240 |
|
"15 minutes")) "; mouse-2: next" )))) |
241 |
(error ""))) |
(error ""))) |
242 |
(mail-spool-file (or display-time-mail-file |
(mail-spool-file (or display-time-mail-file |
243 |
(getenv "MAIL") |
(getenv "MAIL") |