help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The longest Emacs uptime


From: Pascal J. Bourguignon
Subject: Re: The longest Emacs uptime
Date: Sat, 11 Jul 2009 13:22:45 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin)

Eddie Hillenbrand <address@hidden> writes:

> How does one check their Emacs uptime?
>
> On Jul 10, 2009, at 10:10 AM, Leo wrote:
>
>> My Emacs uptime has reached 30 days, 3 hours, 27 minutes, 44 seconds.
>> This is the longest since I started using Emacs in 2005.

I've got this in my ~/.emacs:


(defun .EMACS (fctl &rest args)
  (let ((text (apply (function format) (concat ".EMACS: " fctl) args)))
    (with-current-buffer (get-buffer-create " .EMACS temporary buffer")
      (erase-buffer)
      (insert text "\n")
      (append-to-file (point-min) (point-max) "/tmp/messages.txt"))
    (message text)))


(defvar *emacs-start-time*   (current-time) "For (emacs-uptime)")

(.EMACS "emacs-uptime")
(defun emacs-uptime ()
  "Gives Emacs' uptime, based on global var `*emacs-start-time*'."
  (interactive)
  (let* ((st *emacs-start-time*)
         (cur (current-time))
         (hi-diff (- (car cur) (car st)))
         (tot-sec (+ (ash hi-diff 16) (- (cadr cur) (cadr st))))
         (days (/ tot-sec (* 60 60 24)))
         (hrs  (/ (- tot-sec (* days 60 60 24)) (* 60 60)))
         (mins (/ (- tot-sec (* days 60 60 24) (* hrs 60 60)) 60))
         (secs (/ (- tot-sec (* days 60 60 24) (* hrs 60 60) (* mins 60)) 1)))
    (.EMACS "Up %dd %dh %dm %ds (%s), %d buffers, %d files"
             days hrs mins secs
             (format-time-string "%a %Y-%m-%d %T" st)
             (length (buffer-list))
             (count t (buffer-list)
                    :test-not
                    (lambda (ignore buf)
                      (null (cdr (assoc 'buffer-file-truename
                                        (buffer-local-variables buf)))))))))
(defalias 'uptime 'emacs-uptime)

-- 
__Pascal Bourguignon__


reply via email to

[Prev in Thread] Current Thread [Next in Thread]