From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: uptime.el Date: Sun, 23 Dec 2007 19:48:05 +0200 Organization: JURTA Message-ID: <87abo1z4iy.fsf@jurta.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1198432389 10189 80.91.229.12 (23 Dec 2007 17:53:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 23 Dec 2007 17:53:09 +0000 (UTC) Cc: emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 23 18:53:20 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1J6V0o-0005EA-Fo for ged-emacs-devel@m.gmane.org; Sun, 23 Dec 2007 18:53:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J6V0U-0000ES-Ce for ged-emacs-devel@m.gmane.org; Sun, 23 Dec 2007 12:52:58 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J6Uzw-0008Pp-2b for emacs-devel@gnu.org; Sun, 23 Dec 2007 12:52:24 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J6Uzv-0008P2-Ix for emacs-devel@gnu.org; Sun, 23 Dec 2007 12:52:23 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J6Uzv-0008Oz-Gc for emacs-devel@gnu.org; Sun, 23 Dec 2007 12:52:23 -0500 Original-Received: from relay02.kiev.sovam.com ([62.64.120.197]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J6Uzr-0002ZB-BW; Sun, 23 Dec 2007 12:52:19 -0500 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay02.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1J6Uzi-0000n2-Fy; Sun, 23 Dec 2007 19:52:17 +0200 In-Reply-To: (Richard Stallman's message of "Wed, 19 Dec 2007 05:12:31 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) X-Scanner-Signature: ebef06da57613c13a9510a9a5e517e93 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 1946 [Dec 22 2007] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: none X-SpamTest-Rate: 19 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.8-5.1 (or MacOS X 10.2-10.3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:85411 Archived-At: > What do people think of this? (The patch in startup.el should be done > differently.) This looks like a good fit to time.el with `display-uptime', no? > Message-ID: > Date: Tue, 18 Dec 2007 00:01:18 +0100 > From: "Francesc Rocher" > To: "Richard M. Stallman" > Subject: uptime.el > MIME-Version: 1.0 > Content-Type: text/plain; charset=ISO-8859-1 > Content-Transfer-Encoding: 7bit > Content-Disposition: inline > X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) > > Hello, > > Please consider adding this little piece of elisp code into GNU Emacs: > > ---8<------ > ;;; uptime.el --- tell how long Emacs has been up and running > > ;; Copyright (C) 2007 Free Software Foundation, Inc. > > ;; Author: Francesc Rocher > ;; Keywords: time, uptime. > > ;; This file is part of GNU Emacs. > > ;; GNU Emacs is free software; you can redistribute it and/or modify > ;; it under the terms of the GNU General Public License as published by > ;; the Free Software Foundation; either version 3, or (at your option) > ;; any later version. > > ;; GNU Emacs is distributed in the hope that it will be useful, > ;; but WITHOUT ANY WARRANTY; without even the implied warranty of > ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > ;; GNU General Public License for more details. > > ;; You should have received a copy of the GNU General Public License > ;; along with GNU Emacs; see the file COPYING. If not, write to the > ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, > ;; Boston, MA 02110-1301, USA. > > ;;; Commentary: > > ;; This file provides a couple of functions: `emacs-uptime' tells you how > ;; long Emacs has been up and running. `emacs-startup-time' return a string > ;; containing the date and time Emacs was started up. > > ;;; Code: > > (require 'time-date) > > ;;;###autoload > (defun emacs-uptime (&optional here) "\ > Tell how long GNU Emacs has been running. > If the optional argument HERE is non-nil, insert string at point." > (interactive "P") > (let* ((days (time-to-number-of-days (time-since emacs-startup-time))) > (hours (* 24 (- days (truncate days)))) > (minutes (* 60 (- hours (truncate hours)))) > (seconds (* 60 (- minutes (truncate minutes)))) > (uptime-string > (format "%s, up %s" > (format-time-string "%x %T %Z" (current-time)) > (format "%s%02d:%02d:%02d" > (if (> (truncate days) 0) > (format "%d days, " days) "") > hours minutes seconds)))) > (if here > (insert uptime-string) > (if (interactive-p) > (message "%s" uptime-string) > uptime-string)))) > > ;;;###autoload > (defun emacs-startup-time (&optional here format) "\ > Return string containing the date and time Emacs was started up. > If the optional argument FORMAT is non-nil, it is used to format > the string. See `format-time-string' for valid formats. > If the optional argument HERE is non-nil, insert string at point." > (interactive "P") > (let ((time-string (format-time-string > (if (stringp format) > format > "%x %T %Z") > emacs-startup-time))) > (if here > (insert time-string) > (if (interactive-p) > (message "%s" time-string) > time-string)))) > > (provide 'uptime) > > ;;; arch-tag: > ;;; uptime.el ends here > ---8<------ > > > Complemented with this constant definition: > > diff -u startup.el.~1.470.~ startup.el > --- startup.el.~1.470.~ 2007-12-09 12:08:54.000000000 +0100 > +++ startup.el 2007-12-17 23:18:01.000000000 +0100 > @@ -2243,5 +2243,9 @@ > (setq file (replace-match "/" t t file))) > file)) > > +(eval-at-startup > + (defconst emacs-startup-time (current-time) > + "Time at which GNU Emacs was started up.")) > + > ;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db > ;;; startup.el ends here -- Juri Linkov http://www.jurta.org/emacs/