unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: uptime.el
@ 2008-02-11 23:03 Francesc Rocher
  2008-02-12  5:54 ` uptime.el Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Francesc Rocher @ 2008-02-11 23:03 UTC (permalink / raw)
  To: emacs-devel

>Glenn Morris wrote:
>
>Might as well have this functionality. I installed something similar.
>
>I set emacs-startup-time in command-line.

I prefer `emacs-startup-time' defined as a constant, not as a variable. As
such, it needs to be evaluated only at startup:

   (eval-at-startup
    (defconst emacs-startup-time (current-time)
      "Time at which GNU Emacs was started up."))


>> (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."
>
>Didn't see the point of the HERE argument; used an alternative
>implementation based on something in gnus-art.

The HERE argument is the same as of the function `emacs-version'.


>> (defun emacs-startup-time (&optional here format) "\
>> Return string containing the date and time Emacs was started up.
>
>Didn't see the point of this function, which is basically just a call
>to format-time-string.

`emacs-uptime' tells you how long emacs has been running, whilst
`emacs-startup-time' tells you the time at which Emacs was started up.


Regards,
---
Francesc Rocher




^ permalink raw reply	[flat|nested] 27+ messages in thread
* uptime.el
@ 2007-12-19 10:12 Richard Stallman
  2007-12-19 10:33 ` uptime.el Leo
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Richard Stallman @ 2007-12-19 10:12 UTC (permalink / raw)
  To: emacs-devel

What do people think of this?  (The patch in startup.el should be done
differently.)

Message-ID: <ade856a30712171501q7b6ebb8p8a016058ddd7ab2e@mail.gmail.com>
Date: Tue, 18 Dec 2007 00:01:18 +0100
From: "Francesc Rocher" <francesc.rocher@gmail.com>
To: "Richard M. Stallman" <rms@gnu.org>
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 <rocher@member.fsf.org>
;; 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




Best regards,
---
Francesc Rocher

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2008-02-17 23:11 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-11 23:03 uptime.el Francesc Rocher
2008-02-12  5:54 ` uptime.el Glenn Morris
2008-02-12 23:35   ` uptime.el Juri Linkov
2008-02-14  9:04     ` uptime.el Glenn Morris
2008-02-14 20:56       ` uptime.el Juri Linkov
2008-02-15  8:02         ` uptime.el Glenn Morris
2008-02-16  0:27           ` uptime.el Juri Linkov
2008-02-16  3:35             ` uptime.el Glenn Morris
2008-02-16 19:14               ` uptime.el Juri Linkov
2008-02-16 22:22                 ` uptime.el Glenn Morris
2008-02-16 23:18                   ` uptime.el Juri Linkov
2008-02-17  0:19                     ` uptime.el Glenn Morris
2008-02-17  0:45                       ` uptime.el Juri Linkov
2008-02-17 22:55                         ` uptime.el Glenn Morris
2008-02-17 23:11                           ` uptime.el Juri Linkov
2008-02-16  2:00           ` uptime.el Xavier Maillard
  -- strict thread matches above, loose matches on Subject: below --
2007-12-19 10:12 uptime.el Richard Stallman
2007-12-19 10:33 ` uptime.el Leo
2007-12-23  2:26 ` uptime.el Ævar Arnfjörð Bjarmason
2007-12-23 21:11   ` uptime.el Richard Stallman
2007-12-23 17:48 ` uptime.el Juri Linkov
2007-12-24 13:31   ` uptime.el Richard Stallman
2007-12-24 21:59     ` uptime.el Juri Linkov
2007-12-25 21:13       ` uptime.el Richard Stallman
2008-02-11  0:34 ` uptime.el Glenn Morris
2008-02-12  0:14   ` uptime.el Juri Linkov
2008-02-12  5:50     ` uptime.el Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).