An Application of Org-element

The other day, I saw this query on the reddit Emacs subreddit. I
already have solutions for this type of problem but I’m always
interested in the how people use Org mode to record and report data so
I followed the link that primitiveinds provided for his solution to
generating time reports.

Even if, like me, you already have your time tracking and reporting
needs under control, primitiveinds’ solution is worth looking at for
its own sake. It works by looking for CLOCK entries in an Org buffer
and accumulating the relevant information in the CLOCK line as well
data about the associated task. That might seem like it would require
routine but tedious text manipulation but primitiveinds leverages the
org-element functionality to easily handle the task.

He starts by calling org-element-parse-buffer to generate a tree
representation of the Org buffer. Then he uses org-element-map to
examine each CLOCK element (and only CLOCK elements) to extract the
necessary information. It’s a great technique that can easily be
adapted for other parsing of Org data. The code that primitiveinds
presents is easy to follow and he provides a nice explanation of what
it’s doing.

If you need to programmatically examine Org data for further
processing, you should take a look at primitiveinds’ post. It’s
definitely worth a read.

This entry was posted in General and tagged , . Bookmark the permalink.