Search code examples
org-mode

org mode give NAME to clocktable to parse with perl


I try to give a name to a clocktable :

#+BEGIN: clocktable :scope file :maxlevel 2
#+NAME: d1
#+CAPTION: Clock summary at [2020-04-21 mar. 14:31]
| Headline     |   Time |
|--------------+--------|
| *Total time* | *0:15* |
|--------------+--------|
| t1           |   0:05 |
| t2           |   0:10 |
#+END:


* t1
  CLOCK: [2020-04-21 mar. 14:10]--[2020-04-21 mar. 14:16] =>  0:05

* t2
  CLOCK: [2020-04-21 mar. 14:20]--[2020-04-21 mar. 14:30] =>  0:10

To use it in a perl src block :

* code 
  #+NAME: t1
  #+begin_src perl :var d=d1
  $d;
  #+end_src

  #+RESULTS: t1
  | Headline     |   Time |
  | *Total time* | *0:16* |
  | t1           |   0:06 |
  | t2           |   0:10 |

But When I update the clocktable, the #+NAME: d1 disappear. And If I put it before the #+BEGIN line, the perl block do not find the reference.


Solution

  • you can set the #+NAME within the BEGIN block by passing the :header header like this:

    #+BEGIN: clocktable :scope file :maxlevel 2 :header "#+NAME: d1\n"
    

    and should work with what you have.