emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Date-centric Clocktable


From: Rasmus
Subject: Re: [O] Date-centric Clocktable
Date: Thu, 08 Sep 2011 01:38:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> ---8<--- cut here ---
> (defun collect-clock-lines ()
>   (let ((re (concat "^[ \t]*" org-clock-string "[ \t]+\\(.+?\\)[ \t]+=>[ 
> \t]+\\(.+\\)"))
>       (headline (nth 4 (org-heading-components)))
>       clocks)
>     (org-narrow-to-subtree)
>     (while (re-search-forward re nil t)
>       (setq clocks (concat clocks (format "| %s | %s | %s |\n" (match-string 
> 1) headline (match-string 2)))))
>     (widen)
>     clocks))
>
> (defun summarize-clocks ()
>   (interactive)
>   (insert "| date | headline | total |\n|-----+----+----|\n")
>   (let ((headings (org-map-entries 'collect-clock-lines nil 'file)))
>     (mapc (lambda (clocks)
>           (mapc (lambda (line) (insert line)) clocks))
>           headings)))
> --- cut here --->8---
>
> This version works a little bit better, but has its own drawbacks.
> Anyway, it's a start and I don't want to take all the fun away. ;-)

I think I found one of the drawbacks :)  

#+begin_src org
* COMMENT Organization Headline
** Collecting data
   :LOGBOOK:
   CLOCK: [2011-09-08 Thu 00:31]--[2011-09-08 Thu 00:59] =>  0:28
   :END:
* Clocktable
  :LOGBOOK:
  CLOCK: [2011-09-08 Thu 01:30]--[2011-09-08 Thu 01:37] =>  0:07
  :END:

Note that subitems are counted twice: 

| date                                           | headline                     
 | total |
|------------------------------------------------+-------------------------------+-------|
| [2011-09-08 Thu 00:31]--[2011-09-08 Thu 00:59] | COMMENT Organization 
Headline |  0:28 |
| [2011-09-08 Thu 00:31]--[2011-09-08 Thu 00:59] | Collecting data              
 |  0:28 |
| [2011-09-08 Thu 01:30]--[2011-09-08 Thu 01:37] | Clocktable                   
 |  0:07 |

#+end_src

I might look into it later.

–Rasmus

-- 
Sent from my Emacs




reply via email to

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