向 emacs 组织模式时钟添加评论栏 table

Add comment column to emacs org-mode clock table

我真的希望能够记录每件作品的评论,例如:

#+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")时,时钟table中的评论栏被创建,但它没有得到我在每个任务下写的评论。此外,评论栏实际上是作为第一栏创建的,而我希望它作为最后一栏。我似乎无法弄清楚如何解决这个问题。

如何做到这一点?

原来我在 :PROPERTIES: 之后少了一个 :END:,即

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

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

解决方案是使用 org-mode 格式化程序并调用 .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