aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/time.el91
1 files changed, 48 insertions, 43 deletions
diff --git a/lisp/time.el b/lisp/time.el
index 08e13353ca3..09e5e6b76bd 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -39,7 +39,7 @@
39 "*File name of mail inbox file, for indicating existence of new mail. 39 "*File name of mail inbox file, for indicating existence of new mail.
40Non-nil and not a string means don't check for mail. nil means use 40Non-nil and not a string means don't check for mail. nil means use
41default, which is system-dependent, and is the same as used by Rmail." 41default, which is system-dependent, and is the same as used by Rmail."
42 :type '(choice (const :tag "(None)" none) 42 :type '(choice (const :tag "None" none)
43 (const :tag "Default" nil) 43 (const :tag "Default" nil)
44 (file :format "%v")) 44 (file :format "%v"))
45 :group 'display-time) 45 :group 'display-time)
@@ -67,10 +67,12 @@ Almost every system can provide values of load for past 1 minute, past 5 or
67past 15 minutes. The default is to display 1 minute load average." 67past 15 minutes. The default is to display 1 minute load average."
68 :type '(choice (const :tag "1 minute load" 0) 68 :type '(choice (const :tag "1 minute load" 0)
69 (const :tag "5 minutes load" 1) 69 (const :tag "5 minutes load" 1)
70 (const :tag "15 minutes load" 2)) 70 (const :tag "15 minutes load" 2)
71 (const :tag "None" nil))
71 :group 'display-time) 72 :group 'display-time)
72 73
73(defvar display-time-load-average display-time-default-load-average) 74(defvar display-time-load-average nil
75 "Load average currently being shown in mode line")
74 76
75(defcustom display-time-load-average-threshold 0.1 77(defcustom display-time-load-average-threshold 0.1
76 "*Load-average values below this value won't be shown in the mode line." 78 "*Load-average values below this value won't be shown in the mode line."
@@ -245,26 +247,28 @@ would give mode line times like `94/12/30 21:07:48 (UTC)'."
245(defun display-time-update () 247(defun display-time-update ()
246 (let* ((now (current-time)) 248 (let* ((now (current-time))
247 (time (current-time-string now)) 249 (time (current-time-string now))
248 (load (condition-case () 250 (load (if (null display-time-load-average)
249 ;; Do not show values less than 251 ""
250 ;; `display-time-load-average-threshold'. 252 (condition-case ()
251 (if (> (* display-time-load-average-threshold 100) 253 ;; Do not show values less than
252 (nth display-time-load-average (load-average))) 254 ;; `display-time-load-average-threshold'.
253 "" 255 (if (> (* display-time-load-average-threshold 100)
254 ;; The load average number is mysterious, so 256 (nth display-time-load-average (load-average)))
255 ;; provide some help. 257 ""
256 (let ((str (format " %03d" (nth display-time-load-average (load-average))))) 258 ;; The load average number is mysterious, so
257 (propertize 259 ;; provide some help.
258 (concat (substring str 0 -2) "." (substring str -2)) 260 (let ((str (format " %03d" (nth display-time-load-average (load-average)))))
259 'local-map (make-mode-line-mouse-map 'mouse-2 261 (propertize
260 'display-time-next-load-average) 262 (concat (substring str 0 -2) "." (substring str -2))
261 'help-echo (concat "System load average for past " 263 'local-map (make-mode-line-mouse-map 'mouse-2
262 (if (= 0 display-time-load-average) 264 'display-time-next-load-average)
263 "1 minute" 265 'help-echo (concat "System load average for past "
264 (if (= 1 display-time-load-average) 266 (if (= 0 display-time-load-average)
265 "5 minutes" 267 "1 minute"
266 "15 minutes")) "; mouse-2: next" )))) 268 (if (= 1 display-time-load-average)
267 (error ""))) 269 "5 minutes"
270 "15 minutes")) "; mouse-2: next" ))))
271 (error ""))))
268 (mail-spool-file (or display-time-mail-file 272 (mail-spool-file (or display-time-mail-file
269 (getenv "MAIL") 273 (getenv "MAIL")
270 (concat rmail-spool-directory 274 (concat rmail-spool-directory
@@ -330,26 +334,27 @@ If `display-time-day-and-date' is non-nil, the current day and date
330are displayed as well. 334are displayed as well.
331This runs the normal hook `display-time-hook' after each update." 335This runs the normal hook `display-time-hook' after each update."
332 :global t :group 'display-time 336 :global t :group 'display-time
333 (and display-time-timer (cancel-timer display-time-timer)) 337 (and display-time-timer (cancel-timer display-time-timer))
334 (setq display-time-timer nil) 338 (setq display-time-timer nil)
335 (setq display-time-string "") 339 (setq display-time-string "")
336 (or global-mode-string (setq global-mode-string '(""))) 340 (or global-mode-string (setq global-mode-string '("")))
337 (if display-time-mode 341 (setq display-time-load-average display-time-default-load-average)
338 (progn 342 (if display-time-mode
339 (or (memq 'display-time-string global-mode-string) 343 (progn
340 (setq global-mode-string 344 (or (memq 'display-time-string global-mode-string)
341 (append global-mode-string '(display-time-string)))) 345 (setq global-mode-string
342 ;; Set up the time timer. 346 (append global-mode-string '(display-time-string))))
343 (setq display-time-timer 347 ;; Set up the time timer.
344 (run-at-time t display-time-interval 348 (setq display-time-timer
345 'display-time-event-handler)) 349 (run-at-time t display-time-interval
346 ;; Make the time appear right away. 350 'display-time-event-handler))
347 (display-time-update) 351 ;; Make the time appear right away.
348 ;; When you get new mail, clear "Mail" from the mode line. 352 (display-time-update)
349 (add-hook 'rmail-after-get-new-mail-hook 353 ;; When you get new mail, clear "Mail" from the mode line.
350 'display-time-event-handler)) 354 (add-hook 'rmail-after-get-new-mail-hook
351 (remove-hook 'rmail-after-get-new-mail-hook 355 'display-time-event-handler))
352 'display-time-event-handler))) 356 (remove-hook 'rmail-after-get-new-mail-hook
357 'display-time-event-handler)))
353 358
354(provide 'time) 359(provide 'time)
355 360