From: Richard Stallman <rms@gnu.org>
To: emacs-devel@gnu.org
Subject: uptime.el
Date: Wed, 19 Dec 2007 05:12:31 -0500 [thread overview]
Message-ID: <E1J4vuh-0005Un-UT@fencepost.gnu.org> (raw)
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
next reply other threads:[~2007-12-19 10:12 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-19 10:12 Richard Stallman [this message]
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
-- strict thread matches above, loose matches on Subject: below --
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1J4vuh-0005Un-UT@fencepost.gnu.org \
--to=rms@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.