简体   繁体   中英

Add comment column to emacs org-mode clock table

I really want to be able to log work with comment on each item, eg:

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

When I use the :properties ("COMMENT") the comment column in the clock table is created, but it does not get the comments I write under each task. Also, the comment column is actually created as the first column, whereas I would like it as the last one. I cannot seem to figure out how to solve this.

How can this be done?

It turns out I was missing an :END: after the :PROPERTIES: , ie

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

Regarding the order of the columns, I found help at: https://emacs.stackexchange.com/questions/42329/how-to-choose-the-order-of-clocktable-columns

The solution was to use the org-mode formatter and call a function defined in the .emacs init file. To move my COMMENT column to the far right, I put this is my .emacs file:

(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)
    ))

And in my .org file I use:

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

note the :properties and :formatter above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM