🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.help
Article #189468

Re: How do I make display-time only display the time?

#189468
From: Edgar Hoch
Date: Fri, 18 Jan 1991 20:14
80 lines
3898 bytes
In article <sean.663719994@s.ms.uky.edu> sean@ms.uky.edu (Sean Casey) writes:

   I have no interest whatsoever in the load average or whether I have
   mail, but it would be nice to have the time displayed in the mode
   line.

   Is there any way to make display-time display only the time? I looked
   in the manual and can't find anything to that effect.

   IMHO, the function should be called "sysline", since that's what it
   seems to be modeled after. I'd expect something called "display-time"
   to display just the time.

I had the same problem. I have a private emacs-lisp-directory where I put my
privat emacs-lisp-files in it. In my .emacs-file I had

(setq orginal-load-path load-path)
(defvar HOME (getenv "HOME")
  "This variables specifies the users home-directory")
(setq load-path (cons (concat HOME "/emacs/lisp") load-path))

(display-time)

Since through "(display-time)" the lisp-file "time" is auto-loaded, then my
own file time.el (or time.elc) is loaded. In this file I load the original
file and then modify the needed functions.


-----------------------time.el--------put it in your local directory----------
;; Chances to time.el in emacs-Distribution 18.55 by Edgar Hoch
;; Time should be displayed in 24-hours-format
;;  and the load-usage shouldn't be displayed.
;; In this file there are only the chanced functions!
;; 18. October 1990 20:36:35 MEZ

;  first load the original file
(let ((load-path (cond (orginal-load-path) (load-path))))
  (load "time"))



;  Now adapt the function:

(defun display-time-filter (proc string)
  ;; Desired data can't need more than the last 30 chars,
  ;; so save time by flushing the rest.
  ;; This way, if we have many different times all collected at once,
  ;; we can discard all but the last few very fast.
  ;;; CHANGES BY EDGAR HOCH: date in 24-hours-format
  ;;; following lines deleted (commented):
  ;;;; (if (> (length string) 30)
  ;;;;    (setq string (substring string -30)))
  ;; Now discard all but the very last one.
  ;;;; (while (and (> (length string) 4)
  ;;;;	      (string-match "[0-9]+:[0-9][0-9].." string 4))
  ;;;;  (setq string (substring string (match-beginning 0))))
  ;;;; (if (string-match "[^0-9][0-9]+:" string)
  ;;;;    (setq string (substring string 0 (1+ (match-beginning 0)))))
  ;;; read in time and date
  (setq jetzt (current-time-string))
  ;; extract time from string
  (setq string (substring jetzt 11 16))
  ;; Append the date if desired.
  (if display-time-day-and-date
      ;; hier (current-time-string) changed in jetzt,
      ;; because a second call is unnessesary
      (setq string (concat (substring jetzt 0 11) string)))
  ;; END CHANGES BY EDGAR HOCH
  ;; Install the new time for display.
  (setq display-time-string string)
  ;; Force redisplay of all buffers' mode lines to be considered.
  (save-excursion (set-buffer (other-buffer)))
  (set-buffer-modified-p (buffer-modified-p))
  ;; Do redisplay right now, if no input pending.
  (sit-for 0))

--
Edgar Hoch			| edgar@adler.philosophie.uni-stuttgart.de
Student of Informatik		| hochbb@helg.informatik.uni-stuttgart.de
University of Stuttgart		|
Technical Details
Message-ID: <EDGAR.91Jan18211458@milan.philosophie.uni-stuttgart.de>
Path: arc1-ca.pugleaf.net!gmdzi!unido!ira.uka.de!rusux1!edgar
References: <sean.663719994@s.ms.uky.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 103b8b,5496b629437623a0
X-Google-Attributes: gid103b8b,public
X-Google-ArrivalTime: 1991-01-18 12:25:12 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!ira.uka.de!rusux1!edgar
From: edgar@milan.philosophie.uni-stuttgart.de (Edgar Hoch)
Newsgroups: gnu.emacs.help
Subject: Re: How do I make display-time only display the time?
Message-ID: <EDGAR.91Jan18211458@milan.philosophie.uni-stuttgart.de>
Date: 18 Jan 91 20:14:58 GMT
References: <sean.663719994@s.ms.uky.edu>
Sender: zrf80385@rusux1.rus.uni-stuttgart.de
Organization: IMSV, University of Stuttgart, Germany
Lines: 80
In-reply-to: sean@ms.uky.edu's message of 12 Jan 91 22:39:54 GMT