From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benjamin Andresen Subject: Re: question and use example Date: Wed, 26 Aug 2009 22:18:49 +0200 Message-ID: <877hwqpbva.fsf@gmail.com> References: <20090826163829.GA4578@new-host-2.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgOxZ-0001If-2m for emacs-orgmode@gnu.org; Wed, 26 Aug 2009 16:19:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgOxU-0001Gg-Ch for emacs-orgmode@gnu.org; Wed, 26 Aug 2009 16:19:08 -0400 Received: from [199.232.76.173] (port=42169 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgOxU-0001Gd-5J for emacs-orgmode@gnu.org; Wed, 26 Aug 2009 16:19:04 -0400 Received: from mail-ew0-f211.google.com ([209.85.219.211]:58893) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MgOxT-00052O-OY for emacs-orgmode@gnu.org; Wed, 26 Aug 2009 16:19:03 -0400 Received: by ewy7 with SMTP id 7so561152ewy.31 for ; Wed, 26 Aug 2009 13:19:01 -0700 (PDT) In-Reply-To: <20090826163829.GA4578@new-host-2.home> (Paul Menair's message of "Wed, 26 Aug 2009 12:38:29 -0400") 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 Hey Paul, Paul Menair writes: > My problem is this. I populate the fifth field with c-- c-u c-y. I > would be nice if it happened automatically, but that's no big deal. > However, I've been going through and manually entering the sixth > field, and that does end up being a hassle. I whipped something up that should work for you. You need to evaluate the code below and then the below table will work for you. (defun ba/org-timerange (s &optional in-min) (let* ((re "^\\(.*?\\)--\\(.*?\\)$") (start (replace-regexp-in-string re "\\1" s)) (end (replace-regexp-in-string re "\\2" s)) (start-in-min (org-hh:mm-string-to-minutes start)) (end-in-min (org-hh:mm-string-to-minutes end)) (diff-in-min (- end-in-min start-in-min))) (if in-min diff-in-min (format "%.2f" (/ diff-in-min (float 60)))))) | date | client | desc | timerange | H:M | in dec | |------------------+--------+-------+------------------------------------------------+------+--------| | <2009-08-26 Wed> | benny | foo'd | <2009-08-26 Wed 21:55>--<2009-08-26 Wed 21:58> | 0:03 | 0.05 | #+TBLFM: $5='(org-minutes-to-hh:mm-string (ba/org-timerange $4 t))::$6='(ba/org-timerange $4) If you're on the table and you press C-u C-c C-c and it should put the correct info at the respective places. Now what I recommend is using autocalc instead so you don't have to worry about doing this. This would require you to change your table to the following format: | | date | client | desc | timerange | H:M | in dec | |---+------------------+--------+--------+------------------------------------------------+------+--------| | # | <2009-08-25 Tue> | benny | foo'd | <2009-08-25 Tue 20:55>--<2009-08-25 Tue 23:58> | 3:03 | 3.05 | | # | <2009-08-26 Wed> | bar | quux'd | <2009-08-26 Wed 22:10>--<2009-08-26 Wed 22:14> | 0:04 | 0.07 | #+TBLFM: $6='(org-minutes-to-hh:mm-string (ba/org-timerange $5 t))::$7='(ba/org-timerange $5) The "#" in the first column achieves this. See (info "(org)Advanced features") for more information. > Paul HTH, benny