emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Date-centric Clocktable


From: Olaf Dietsche
Subject: Re: [O] Date-centric Clocktable
Date: Wed, 07 Sep 2011 15:38:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Olaf Dietsche <address@hidden> writes:

> Rasmus <address@hidden> writes:
>
>> 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. 
>
> If you insist on elisp, maybe something along these (untested) lines
> might work:
>
> ---8<--- cut here ---
[buggy code]
> --- cut here --->8---

I finally came around and tested the code, but unfortunately it doesn't
work as expected. Here is another version:

---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. ;-)

Regards, Olaf



reply via email to

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