将注释列添加到emacs组织模式时钟表

时间:2018-12-06 14:29:59

标签: emacs org-mode

我真的希望能够记录对每个项目的评论,例如:

#+BEGIN: clocktable :maxlevel 3 :emphasize nil :scope file :block thisweek :properties ("COMMENT")
#+CAPTION: Clock summary at [2018-12-06 Thu 15:16], for week 2018-W49.
| Headline                         | Time   |      |  COMMENT  |
+----------------------------------+--------+------|-----------|
| *Total time*                     | *0:15* |      |           |
+----------------------------------+--------+------|-----------|
| task list                        | 0:15   |      |           |
| \_  First task                   |        | 0:06 | comment 1 |
| \_  Second task                  |        | 0:09 | comment 2 |
#+END: clocktable


* task list
** First task
   :PROPERTIES:
   :COMMENT: comment 1
   :LOGBOOK:
   CLOCK: [2018-12-06 Thu 13:35]--[2018-12-06 Thu 13:41] =>  0:06
   :END:
** Second task
   :PROPERTIES:
   :COMMENT: comment 2
   :LOGBOOK:
   CLOCK: [2018-12-06 Thu 13:41]--[2018-12-06 Thu 13:50] =>  0:09
   :END:

当我使用:properties ("COMMENT")时,会创建时钟表中的注释列,但它没有得到我在每个任务下编写的注释。另外,comment列实际上是创建为第一列,而我希望它是最后一个列。我似乎无法弄清楚该如何解决。

这怎么办?

1 个答案:

答案 0 :(得分:2)

事实证明,我在:END:之后错过了一个:PROPERTIES:,即

   :PROPERTIES:
   :COMMENT: comment 1
   :END: <----- THIS IS WHAT WAS MISSING 

关于列的顺序,我在以下位置找到了帮助: https://emacs.stackexchange.com/questions/42329/how-to-choose-the-order-of-clocktable-columns

解决方案是使用组织模式格式化程序并调用.emacs初始化文件中定义的函数。将我的COMMENT列移到最右边,这是我的.emacs文件:

(defun my-clocktable-write (&rest args)
  "Custom clocktable writer.
Uses the default writer but shifts the first column right."
  (apply #'org-clocktable-write-default args)
  (save-excursion
    (forward-char) ;; move into the first table field
    (org-table-move-column-right)
    (org-table-move-column-right)
    (org-table-move-column-right)
    (org-table-move-column-right)
    ))

在我的.org文件中,我使用:

#+BEGIN: clocktable :maxlevel 4 :scope file :block today-1 :properties ("Comment") :formatter my-clocktable-write
#+CAPTION: 

注意上面的:properties:formatter