org 模式将 NAME 赋予 clocktable 以使用 perl 进行解析

org mode give NAME to clocktable to parse with perl

我试着给时钟表起个名字:

#+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

在 perl src 块中使用它:

* 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 |

但是当我更新 clocktable 时,#+NAME: d1 消失了。如果我把它放在 #+BEGIN 行之前,perl 块找不到引用。

您可以通过传递 :header header 在 BEGIN 块中设置 #+NAME,如下所示:

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

并且应该与你所拥有的一起工作。