emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: allow cycling through 1, 5 and 15 minutes load averages


From: Pavel Janík
Subject: Re: allow cycling through 1, 5 and 15 minutes load averages
Date: Mon, 17 Dec 2001 08:31:48 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1.50 (i386-suse-linux-gnu)

   From: Richard Stallman <address@hidden>
   Date: Sat, 15 Dec 2001 23:21:40 -0700 (MST)

   > In general, user options should not be altered by execution of
   > programs.  They should be reserved for the user to change.
   > Programs should set other variables.

Here is fixed version. I will wait for your opinion about "disappearing
load-average" before installing this.

--- time.el.~1.70.~     Mon Oct 29 20:06:53 2001
+++ time.el     Sun Dec 16 12:27:47 2001
@@ -51,6 +51,17 @@
                 (function))
   :group 'display-time)
 
+(defcustom display-time-default-load-average 0
+  "*Which load-average value will be shown in the mode-line.
+Almost every system can provide values of load for past 1 minute, past 5 or
+past 15 minutes. The default is to display 1 minute load average."
+  :type '(choice (const :tag "1 minute load" 0)
+                (const :tag "5 minutes load" 1)
+                (const :tag "15 minutes load" 2))
+  :group 'display-time)
+
+(defvar display-time-load-average display-time-default-load-average)
+
 ;;;###autoload
 (defcustom display-time-day-and-date nil "\
 *Non-nil means \\[display-time] should display day and date as well as time."
@@ -191,6 +202,13 @@
                          display-time-interval)
          (timer-activate timer)))))
 
+(defun display-time-next-load-average ()
+  (interactive)
+  (if (= 3 (setq display-time-load-average (1+ display-time-load-average)))
+      (setq display-time-load-average 0))
+  (display-time-update)
+  (sit-for 0))
+
 ;; 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
@@ -199,13 +217,20 @@
   (let* ((now (current-time))
         (time (current-time-string now))
          (load (condition-case ()
-                   (if (zerop (car (load-average))) ""
+                   (if (zerop (nth display-time-load-average (load-average))) 
""
                     ;; The load average number is mysterious, so
-                    ;; propvide some help.
-                     (let ((str (format " %03d" (car (load-average)))))
+                    ;; provide some help.
+                     (let ((str (format " %03d" (nth display-time-load-average 
(load-average)))))
                       (propertize
                        (concat (substring str 0 -2) "." (substring str -2))
-                       'help-echo "System load average")))
+                       'local-map (make-mode-line-mouse-map 'mouse-2 
+                                                            
'display-time-next-load-average)
+                       'help-echo (concat "System load average for past "
+                                          (if (= 0 display-time-load-average)
+                                              "1 minute"
+                                            (if (= 1 display-time-load-average)
+                                                "5 minutes"
+                                              "15 minutes")) "; mouse-2: next" 
))))
                  (error "")))
          (mail-spool-file (or display-time-mail-file
                               (getenv "MAIL")

-- 
Pavel Janík

In protocol design, perfection has been reached not when there is nothing
left to add, but when there is nothing left to take away.
                  -- RFC1925: The Twelve Networking Truths



reply via email to

[Prev in Thread] Current Thread [Next in Thread]