From: aycock@cuc.ab.CA (John Aycock)
Subject: patch for load-average and mail indicator
Organization: UUCP, University of Calgary
Distribution: gnu
Date: Thu, 23 Jul 1992 02:52:28 GMT

As a followup to my earlier question, Jim Blandy (jimb@occs.cs.oberlin.edu)
gave me the clue I was looking for, that a function intrinsic to emacs was
perusing my kernel.  What the code in time.el to call /usr/ucb/uptime is
for, and why it doesn't get executed, I don't know.

In any case, this patch to time.el causes the load average to appear for
non-root, non-group-kmem, non-emacs-setgid-kmem types.  It also makes
the string "Mail" change to "MAIL" if there is new mail (useful for
people like me who let stuff accumulate on the spool for a while).

Disclaimer: it works for me; I make no other claims.
:ja

--
*** time.el.dist	Wed Jul 22 22:29:27 1992
--- time.el	Wed Jul 22 22:30:00 1992
***************
*** 66,72 ****
  (defun display-time-filter (proc string)
    (let ((time (current-time-string))
  	(load (condition-case ()
! 		  (if (zerop (car (load-average))) ""
  		    (format "%03d" (car (load-average))))
  		(error
  		 (condition-case ()
--- 66,93 ----
  (defun display-time-filter (proc string)
    (let ((time (current-time-string))
  	(load (condition-case ()
! ;;		  (if (zerop (car (load-average))) ""
! 		  ;; local hack, gets load average off uptime
! 		  ;; so emacs doesn't have to be setgid kmem;
! 		  ;; why the code already in here doing this
! 		  ;; doesn't work I don't know
! 		  (if (zerop (car (load-average))) 
! 		      (let ((load-hack
! 			     (save-excursion
! 			       (set-buffer
! 				(get-buffer-create " *uptime*"))
! 			       (call-process "/usr/ucb/uptime" nil t)
! 			       (goto-char (point-min))
! 			       (search-forward "average: ")
! 			       (concat
! 				(buffer-substring (point)
! 						  (progn (forward-word 1)
! 							 (point)))
! 				(buffer-substring (1+ (point))
! 						  (progn (forward-word 1)
! 							 (point)))))))
! 			(kill-buffer " *uptime*")
! 			load-hack)
  		    (format "%03d" (car (load-average))))
  		(error
  		 (condition-case ()
***************
*** 99,104 ****
--- 120,127 ----
  	(setq hour (- hour 12))
        (if (= hour 0)
  	  (setq hour 12)))
+     ;; prepare for hack
+     (setq mail-notify-hack (file-attributes mail-spool-file))
      (setq display-time-string
  	  (concat (format "%d" hour) (substring time 13 16)
  		  (if pm "pm" "am")
***************
*** 108,114 ****
  		  (if (and (file-exists-p mail-spool-file)
  			   ;; file not empty?
  			   (> (nth 7 (file-attributes mail-spool-file)) 0))
! 		      " Mail"
  		    "")))
      ;; Append the date if desired.
      (if display-time-day-and-date
--- 131,147 ----
  		  (if (and (file-exists-p mail-spool-file)
  			   ;; file not empty?
  			   (> (nth 7 (file-attributes mail-spool-file)) 0))
! 		      ;; local hack, puts mail indicator in all
! 		      ;; uppercase if there is new mail (modification
! 		      ;; time > access time)
! 		      (if (or (> (nth 1 (nth 5 mail-notify-hack))
! 				 (nth 1 (nth 4 mail-notify-hack)))
! 			      (and (= (nth 1 (nth 5 mail-notify-hack))
! 				      (nth 1 (nth 4 mail-notify-hack)))
! 				   (> (nth 2 (nth 5 mail-notify-hack))
! 				      (nth 2 (nth 4 mail-notify-hack)))))
! 			  " MAIL"
! 			  " Mail")
  		    "")))
      ;; Append the date if desired.
      (if display-time-day-and-date
--

  //\|_||\|	John D. Aycock		aycock@cpsc.ucalgary.ca
\/ \/| || |	(403) 285-8727		aycock@pogo.cuc.ab.ca

Newsgroups: gnu.emacs.bug