使用 org-mode columnview 生成任務列表

原文地址:https://www.lujun9972.win/blog/2020/05/08/使用-org-mode-columnview-生成任務列表/index.html

org-mode的columnview動態塊能夠幫你把樹形的代辦事項歸整爲表格,方便查看

在org-mode中可以通過兩個命令來插入colmnviewa動態塊:

  • 一個是通過 M-x org-dynamic-block-insert-dblock 插入一個動態塊,默認情況下 org-mode 自帶了兩類動態塊 columnviewclocktable ,然後我們選擇 columnview 即可
  • 另一個是通過 M-x org-columns-insert-dblock 直接插入columnviewa動態塊

一個 columnview 動態塊大概長這個樣子的:

#+BEGIN: columnview :參數1 參數值 :參數N h參數值

#+END:

其中 columnview 標識動態塊的類型,該名字決定了org-mode會調用哪個函數來生成動態塊的內容,比如這裏調用的函數就是 org-dblock-write:columnview. 後面的 :參數1 參數值 :參數N h參數值 參數則會組裝成一個plist傳遞給函數作爲唯一的參數,並將函數的返回值作爲動態塊的內容

我們可以通過查看 org-dblock-write:columnview 的docstring來找出 columnwive 動態塊支持的參數:

(org-dblock-write:columnview PARAMS)

Write the column view table.

PARAMS is a property list of parameters:

‘:id’ (mandatory)

    The ID property of the entry where the columns view should be
    built.  When the symbol ‘local’, call locally.  When ‘global’
    call column view with the cursor at the beginning of the
    buffer (usually this means that the whole buffer switches to
    column view).  When "file:path/to/file.org", invoke column
    view at the start of that file.  Otherwise, the ID is located
    using ‘org-id-find’.

‘:exclude-tags’

    List of tags to exclude from column view table.

‘:format’

    When non-nil, specify the column view format to use.

‘:hlines’

    When non-nil, insert a hline before each item.  When
    a number, insert a hline before each level inferior or equal
    to that number.

‘:indent’

    When non-nil, indent each ITEM field according to its level.

‘:match’

    When set to a string, use this as a tags/property match filter.

‘:maxlevel’

    When set to a number, don’t capture headlines below this level.

‘:skip-empty-rows’

    When non-nil, skip rows where all specifiers other than ITEM
    are empty.

‘:vlines’

    When non-nil, make each column a column group to enforce
    vertical lines.

這裏比較重要的參數有

:id
這是最重要的參數. 它指定了column視圖的數據來源。
:maxlevel
若設置爲數字N,表示不捕捉層級在N級以下的條目
:skip-empty-rows
若設置爲`t`,則會跳過那些除了`ITEM`屬性列外,其他屬性列都是空值的行
:format
設置column視圖的格式。

其中 :format 是一個以多個列定義式組成的字符串,各定義式之間使用空格進行分隔。 column的定義式中可以包含有列的屬性. 一般來說列的定義式看起來是這樣做的

,%[width]property[(title)][{summary-type}]

除了百分號和屬性名之外,所有的都是可選的. 各部分的意思如下所示

width           整型,代表了列的寬度,如果忽略則由org自動決定

property        該列所表示的屬性,可以是上文提到的哪些特殊屬性

title           列的標題,如果忽略,則會使用屬性名代替

{summary-type}  總和的類型,如果指定了,那麼父節點的列值由其下子節點的值計算得到
                支持的總和類型包括:
                {+}       該列的累加值
                {+;%.1f}  指定了格式的列累加值
                {$}       貨幣格式,其實就是 ‘+;%.2f’.
                {:}       把列中的值作爲時間進行累加,格式爲HH[:MM]
                {X}       Checkbox 的狀態, 若所有子checkboxd都標記爲‘[X]’ 則顯示‘[X]’.
                {X/}      Checkbox 的狀態, 顯示格式爲‘[n/m]’.
                {X%}      Checkbox 的狀態, 顯示格式爲‘[n%]’.
                {min}     列中的最小值
                {max}     列中的最大值
                {mean}    列的算術平均值
                {:min}    列中的最小值(以時間爲單位)
                {:max}    列中的最大值(以時間爲單位)
                {:mean}   列中的算術平均值(以時間爲單位)
                {@min}    列中的最小值(以時間區間爲單位)
                {@max}    列中的最大值(以時間區間爲單位)
                {@mean}   列中的算術平均值(以時間區間爲單位)
                {est+}    耗時的範圍

我一般使用 columnview 來生成任務列表方便我對任務進度進行追蹤。下面是一個例子

* 任務分派

#+BEGIN: columnview :hlines 1 :id local :format "%ITEM(任務) %CHARGER(負責人) %DEADLINE(死線) %TODO(狀態)" :skip-empty-rows t
| 任務   | 負責人    | 死線            | 狀態  |
|--------+-----------+-----------------+-------|
| 任務一 | 甲xx      |                 | NEXT  |
| 任務二 | 乙xx      | <2020-05-12 二> | TODAY |
| 任務三 | 甲xx 乙xx |                 | TODO  |
#+END:

** NEXT 任務一
   :PROPERTIES:
   :CHARGER:  甲xx
   :END:
+ [ ] xxxx
+ [ ] yyyy
+ [ ] zzzz
+ [X] abcd
** TODAY [#A] 任務二
   DEADLINE: <2020-05-12 二>
   :PROPERTIES:
   :CHARGER:  乙xx
   :END:
+ [ ] 111111
+ [ ] 222222
** TODO [#C] 任務三
   :PROPERTIES:
   :CHARGER:  甲xx 乙xx
   :END:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章