From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Date-centric Clocktable Date: Wed, 7 Sep 2011 12:28:22 +0200 Message-ID: References: <87zkip7oc6.fsf@gmail.com> <87mxegenfh.fsf@rat.lan> <87d3fcsoqf.fsf@gmail.com> <871uvsejxp.fsf@rat.lan> Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:33722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1FMo-0003cz-BW for emacs-orgmode@gnu.org; Wed, 07 Sep 2011 06:28:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1FMn-0005po-7h for emacs-orgmode@gnu.org; Wed, 07 Sep 2011 06:28:26 -0400 Received: from mail-ew0-f41.google.com ([209.85.215.41]:42738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1FMn-0005pj-1m for emacs-orgmode@gnu.org; Wed, 07 Sep 2011 06:28:25 -0400 Received: by ewy9 with SMTP id 9so40708ewy.0 for ; Wed, 07 Sep 2011 03:28:24 -0700 (PDT) In-Reply-To: <871uvsejxp.fsf@rat.lan> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Olaf Dietsche Cc: emacs-orgmode@gnu.org, Rasmus On Sep 7, 2011, at 12:16 PM, Olaf Dietsche wrote: > Rasmus writes: >=20 >>> Why don't you just use a simple (perl/python/...) script to collect = your >>> data? Here's a quick hack in perl: >>=20 >> That was my plan if I was not able to do from within Org. To me it = would >> be a lot faster than hacking something together in emacs-lisp, >> unfortunately.=20 >=20 > If you insist on elisp, maybe something along these (untested) lines > might work: >=20 > ---8<--- cut here --- > (defvar clockstable) >=20 > (defun collect-clock-lines () > (org-narrow-to-subtree) > (let ((re (concat "^[ \t]*" org-clock-string "[ \t]+\\(.+?\\)[ = \t]+=3D>[ \t]+\\(.+\\)")) > (headline (nth 4 (org-heading-components)))) > (while (re-search-forward re) > (setq clockstable (concat clockstable (match-string 1) "|" = headline "|" (match-string 2) "\n"))))) >=20 > (defun summarize-clocks () > (interactive) > (setq clockstable "| date | headline | total |\n|-----+----+----|\n") > (org-map-entries collect-clock-lines nil 'agenda) > (insert clockstable)) > --- cut here --->8--- Hi Olaf, this is great! Maybe we should make this a little builtin function, with a format specification to create the lines. What is still missing, I think, is some sorting by time would. Basically, use (org-float-time (apply 'encode-time (save-match-data (org-parse-time-string = (match-string 1))))) after the successful search for a clock string to get a floating point number representing the starting time, collect the=20 line you are creating into an alist with the times and sort them before inserting into the buffer. - Carsten