From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Automatic Elapsed Time Stamps? Date: Sat, 28 Jul 2007 18:58:03 +0200 Message-ID: <87vec431pg.fsf@bzg.ath.cx> References: <876445wjpj.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IEpcJ-00031C-R7 for emacs-orgmode@gnu.org; Sat, 28 Jul 2007 12:58:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IEpcI-000305-EA for emacs-orgmode@gnu.org; Sat, 28 Jul 2007 12:58:11 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IEpcI-000302-7y for emacs-orgmode@gnu.org; Sat, 28 Jul 2007 12:58:10 -0400 Received: from hu-out-0506.google.com ([72.14.214.237]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IEpcH-00073m-MF for emacs-orgmode@gnu.org; Sat, 28 Jul 2007 12:58:09 -0400 Received: by hu-out-0506.google.com with SMTP id 23so572115huc for ; Sat, 28 Jul 2007 09:58:07 -0700 (PDT) In-Reply-To: <876445wjpj.fsf@bzg.ath.cx> (Bastien's message of "Sat\, 28 Jul 2007 00\:44\:08 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Bastien writes: > 2. Use an `Elapsed_time' property. I've been playing a bit with Org's property API[1]. So here is a much cleaner version of the code: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=bzg-step-time-report.el Content-Transfer-Encoding: 8bit ;; for report with time step (defvar bzg-step-time-report-time nil) (defun bzg-step-time-report-initialize (project) "Insert a 1st-level project at point." (interactive "sProject name: ") (insert "* " project) (org-insert-property-drawer) (org-entry-put (point) "COLUMNS" "%25ITEM %5Elapsed_time(Elapsed Time){:}") (next-line 2) (setq bzg-step-time-report-time (current-time))) (defun bzg-step-time-report-add-step (&optional step) "Update elapsed time for previous step and insert the next one." (interactive "P") (let ((elapsed-time (format-time-string "%H:%M" (time-since bzg-step-time-report-time) t)) (step-name (when step (read-from-minibuffer "Step name: ")))) (org-entry-put (point) "Elapsed_time" elapsed-time) (insert "** " (or step-name "Step")) (org-insert-property-drawer) (org-entry-put (point) "Elapsed_time" nil) (next-line 2) (setq bzg-step-time-report-time (current-time)))) (defun bzg-step-time-report-finish () "Update elapsed time for previous step." (interactive) (let ((elapsed-time (format-time-string "%H:%M" (time-since bzg-step-time-report-time) t))) (org-entry-put (point) "Elapsed_time" elapsed-time))) --=-=-= Notes: [1] See (info "(Org)Using the property API") for details. -- Bastien --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--