如何使清單計數器在組織模式下累積子標題的結果?

如何使清單計數器在組織模式下累積子標題的結果?

我想在 Emacs 的 Org 模式下做這樣的事情:

* headline [%]
** subheadline1 [%]
   - [ ] list item 1
   - [ ] list item 2
** subheadline2 [%]
   - [ ] list item 1
   - [ ] list item 2

這裡的目的是讓標題中的百分比 cookie 顯示根據其副標題的百分比 cookie 計算出的已完成任務的總百分比。

如果「subheadline1」位於40%,「副標題2」位於50%,那麼「標題」應該位於(40 + 50) / 2 = 45%(2是副標題的數量)。

是否可以?如果是這樣,怎麼辦?

答案1

我認為目前這完全不可能。預設情況下,複選框僅將其子項作為完整/不完整 cookie 進行處理。 (看複選框)。但是,可以選擇使用org-checkbox-hierarchical-statistics並包含標題中的所有複選框,而不僅僅是直接子項。

所以透過添加或評估

(setq org-checkbox-hierarchical-statistics nil)

您可以為所有組織文件設定此功能(遞歸地計算樹中的所有核取方塊)。

如果您只想為特定的樹設置它,文檔字串提供了答案:

org-checkbox-hierarchical-statistics is a variable defined in `org-list.el'.
Its value is t

Documentation:
Non-nil means checkbox statistics counts only the state of direct children.
When nil, all boxes below the cookie are counted.
This can be set to nil on a per-node basis using a COOKIE_DATA property
with the word "recursive" in the value.

在這種情況下,您的範例將變為:

* headline [%]
:PROPERTIES:
:COOKIE_DATA: recursive
:END:
** subheadline1 [%]
   - [ ] list item 1
   - [ ] list item 2
** subheadline2 [%]
   - [ ] list item 1
   - [ ] list item 2

使用您的進一步範例:
副標題 1 = 2/4 = 50%
副標題 2 = 2/5 = 45%
標題 1 = 4/9 = 44.44%

相關內容