Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org-mode clock table by tag

Tags:

emacs

org-mode

In Emacs org-mode, is it possible to have the clock report table show how much time has been spent on each tag? The manual seems to think so, but I can't make it work. This is what I have tried:

#+BEGIN: clocktable :maxlevel 2 :scope file :tags nicetag

#+END:

* Header one :nicetag:
:LOGBOOK:  
CLOCK: [2016-07-23 Sat 18:24]--[2016-07-23 Sat 19:38] =>  1:14
CLOCK: [2016-07-23 Sat 12:23]--[2016-07-23 Sat 13:43] =>  1:20
:END:      
* Another header :bigtag:
:LOGBOOK:  
CLOCK: [2016-07-23 Sat 20:24]--[2016-07-23 Sat 20:34] =>  0:10
:END:
* A task  :nicetag:
:LOGBOOK:  
CLOCK: [2016-07-23 Sat 10:26]--[2016-07-23 Sat 11:26] =>  1:00
:END:      

What I would like is for the table to show the time taken on all the headers with tag :nicetag:, but the table doesn't show anything. Even better would be a way to make the table show the time spent on each tag in the file.

like image 711
8n8 Avatar asked Jul 23 '16 19:07

8n8


2 Answers

Do you mean?

#+BEGIN: clocktable :maxlevel 2 :scope file :tags "nicetag"

(Note the "" around your tag.) The error message shown in the echo area when you try to use it without "" is "Wrong type argument: stringp, nicetag", which means that Emacs expected to read a string but got something that wasn't. Hope that helps!

like image 178
Sacha Chua Avatar answered Oct 22 '22 20:10

Sacha Chua


I believe :tags changed between 2016 and the present (2020) so here is an "update":

In the docs (https://orgmode.org/manual/The-clock-table.html#The-clock-table) I see :tags explanation is this

‘:tags’

    When this flag is non-nil, show the headline’s tags.

And so :tags should just enable a column of tags. I tried :tags "mytag" and found that it did not filter as the OP asked. Rather :match "mytag" does this filtering.

‘:match’

    A tags match to select entries that should contribute. See Matching tags and properties for the match syntax.

From the OP then:

#+BEGIN: clocktable :maxlevel 2 :scope file :tags t :match "nicetag"
#+CAPTION: Clock summary at [2020-01-23 Thu 09:51]
| Tags    | Headline     |   Time |
|---------+--------------+--------|
|         | *Total time* | *3:34* |
|---------+--------------+--------|
| nicetag | Header one   |   2:34 |
| nicetag | A task       |   1:00 |
#+END:

* Header one :nicetag:
:LOGBOOK:  
CLOCK: [2016-07-23 Sat 18:24]--[2016-07-23 Sat 19:38] =>  1:14
CLOCK: [2016-07-23 Sat 12:23]--[2016-07-23 Sat 13:43] =>  1:20
:END:      
* Another header :bigtag:
:LOGBOOK:  
CLOCK: [2016-07-23 Sat 20:24]--[2016-07-23 Sat 20:34] =>  0:10
:END:
* A task  :nicetag:
:LOGBOOK:  
CLOCK: [2016-07-23 Sat 10:26]--[2016-07-23 Sat 11:26] =>  1:00
:END:

And without the :tags t we get the same result without the tags column

#+BEGIN: clocktable :maxlevel 2 :scope file :match "nicetag"
#+CAPTION: Clock summary at [2020-01-23 Thu 09:53]
| Headline     |   Time |
|--------------+--------|
| *Total time* | *3:34* |
|--------------+--------|
| Header one   |   2:34 |
| A task       |   1:00 |
#+END:
like image 37
Craig Comstock Avatar answered Oct 22 '22 20:10

Craig Comstock