如何使清单计数器在组织模式下从子标题中累积结果?

Eps*_*tor 12 emacs org-mode

我想在 Emacs 的 Org-mode 中做这样的事情:

* headline [%]
** subheadline1 [%]
   - [ ] list item 1
   - [ ] list item 2
** subheadline2 [%]
   - [ ] list item 1
   - [ ] list item 2
Run Code Online (Sandbox Code Playgroud)

这里的目的是让标题中的百分比 cookie 显示根据其副标题的百分比 cookie 计算出的已完成任务的总百分比。

如果“subheadline1”占40 %,“subheadline2”占50 %,那么“headline”应该是(40 + 50) / 2 = 45 %(2是副标题的数量)。

是否可以?如果是这样,如何?

Jon*_*pin 4

我认为目前这完全不可能。默认情况下,复选框仅将其子项作为完整/不完整 cookie 进行处理。(请参阅复选框)。但是,可以选择使用org-checkbox-hierarchical-statistics并包含标题中的所有复选框,而不仅仅是直接子项。

所以通过添加或评估

(setq org-checkbox-hierarchical-statistics nil)
Run Code Online (Sandbox Code Playgroud)

您可以为所有组织文件设置此功能(递归地计算树中的所有复选框)。

如果您只想为特定的树设置它,文档字符串提供了答案:

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.
Run Code Online (Sandbox Code Playgroud)

在这种情况下,您的示例将变为:

* headline [%]
:PROPERTIES:
:COOKIE_DATA: recursive
:END:
** subheadline1 [%]
   - [ ] list item 1
   - [ ] list item 2
** subheadline2 [%]
   - [ ] list item 1
   - [ ] list item 2
Run Code Online (Sandbox Code Playgroud)

使用您的进一步示例:
副标题 1 = 2/4 = 50%
副标题 2 = 2/5 = 45%
标题 1 = 4/9 = 44.44%

  • 请注意,该变量已[莫名其妙地更改](https://code.orgmode.org/bzg/org-mode/commit/f373bca58b8fe665739815c2b7174dc91e2a9c0c) 为“org-checkbox-hierarchical-statistics”。然而,[文档](https://orgmode.org/manual/Checkboxes.html#DOCF51) 尚未更改。 (3认同)