diff options
| author | Pavel Janík | 2001-12-22 09:18:01 +0000 |
|---|---|---|
| committer | Pavel Janík | 2001-12-22 09:18:01 +0000 |
| commit | 4b05e68da250cc3b5214207cbd332920f5296e13 (patch) | |
| tree | 716d686eaa2939d44ffdc95390666d11498d59b8 | |
| parent | a43dbef8899766788fda9e206bf9ac59a4167088 (diff) | |
| download | emacs-4b05e68da250cc3b5214207cbd332920f5296e13.tar.gz emacs-4b05e68da250cc3b5214207cbd332920f5296e13.zip | |
(display-time-load-average-threshold): New variable.
(display-time-update): Use it.
(display-time-default-load-average): New customizable option.
(display-time-load-average): New variable.
(display-time-cycle-load-average): New function.
(display-time-update): Use them.
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/time.el | 42 |
2 files changed, 50 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e2277fe5c77..583f3440afa 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2001-12-22 Pavel Jan,Bm(Bk <Pavel@Janik.cz> | ||
| 2 | |||
| 3 | * time.el (display-time-load-average-threshold): New variable. | ||
| 4 | (display-time-update): Use it. | ||
| 5 | |||
| 6 | These changes allow cycling through past 1, 5 and 15 minutes | ||
| 7 | load-average displayed in the mode-line. | ||
| 8 | |||
| 9 | * time.el (display-time-default-load-average): New customizable option. | ||
| 10 | (display-time-load-average): New variable. | ||
| 11 | (display-time-cycle-load-average): New function. | ||
| 12 | (display-time-update): Use them. | ||
| 13 | |||
| 1 | 2001-12-21 Richard M. Stallman <rms@gnu.org> | 14 | 2001-12-21 Richard M. Stallman <rms@gnu.org> |
| 2 | 15 | ||
| 3 | * apropos.el (apropos-print): SPACING is now nil or a separator string. | 16 | * apropos.el (apropos-print): SPACING is now nil or a separator string. |
diff --git a/lisp/time.el b/lisp/time.el index ac7fb2246a7..5e4e4721e8f 100644 --- a/lisp/time.el +++ b/lisp/time.el | |||
| @@ -51,6 +51,20 @@ nil means use the default method of checking `display-time-mail-file'." | |||
| 51 | (function)) | 51 | (function)) |
| 52 | :group 'display-time) | 52 | :group 'display-time) |
| 53 | 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 | |||
| 54 | ;;;###autoload | 68 | ;;;###autoload |
| 55 | (defcustom display-time-day-and-date nil "\ | 69 | (defcustom display-time-day-and-date nil "\ |
| 56 | *Non-nil means \\[display-time] should display day and date as well as time." | 70 | *Non-nil means \\[display-time] should display day and date as well as time." |
| @@ -66,7 +80,7 @@ nil means use the default method of checking `display-time-mail-file'." | |||
| 66 | 80 | ||
| 67 | (defcustom display-time-24hr-format nil | 81 | (defcustom display-time-24hr-format nil |
| 68 | "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23. | 82 | "*Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23. |
| 69 | Nil means 1 <= hh <= 12, and an AM/PM suffix is used." | 83 | nil means 1 <= hh <= 12, and an AM/PM suffix is used." |
| 70 | :type 'boolean | 84 | :type 'boolean |
| 71 | :group 'display-time) | 85 | :group 'display-time) |
| 72 | 86 | ||
| @@ -191,6 +205,13 @@ would give mode line times like `94/12/30 21:07:48 (UTC)'." | |||
| 191 | display-time-interval) | 205 | display-time-interval) |
| 192 | (timer-activate timer))))) | 206 | (timer-activate timer))))) |
| 193 | 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 | |||
| 194 | ;; Update the display-time info for the mode line | 215 | ;; Update the display-time info for the mode line |
| 195 | ;; but don't redisplay right now. This is used for | 216 | ;; but don't redisplay right now. This is used for |
| 196 | ;; things like Rmail `g' that want to force an update | 217 | ;; things like Rmail `g' that want to force an update |
| @@ -199,13 +220,24 @@ would give mode line times like `94/12/30 21:07:48 (UTC)'." | |||
| 199 | (let* ((now (current-time)) | 220 | (let* ((now (current-time)) |
| 200 | (time (current-time-string now)) | 221 | (time (current-time-string now)) |
| 201 | (load (condition-case () | 222 | (load (condition-case () |
| 202 | (if (zerop (car (load-average))) "" | 223 | ;; 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 | "" | ||
| 203 | ;; The load average number is mysterious, so | 228 | ;; The load average number is mysterious, so |
| 204 | ;; propvide some help. | 229 | ;; provide some help. |
| 205 | (let ((str (format " %03d" (car (load-average))))) | 230 | (let ((str (format " %03d" (nth display-time-load-average (load-average))))) |
| 206 | (propertize | 231 | (propertize |
| 207 | (concat (substring str 0 -2) "." (substring str -2)) | 232 | (concat (substring str 0 -2) "." (substring str -2)) |
| 208 | 'help-echo "System load average"))) | 233 | '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" )))) | ||
| 209 | (error ""))) | 241 | (error ""))) |
| 210 | (mail-spool-file (or display-time-mail-file | 242 | (mail-spool-file (or display-time-mail-file |
| 211 | (getenv "MAIL") | 243 | (getenv "MAIL") |