Orgmode: Show number of children under heading

China☆狼群 提交于 2019-12-07 03:30:51

问题


I have a heading in my orgmode file. It is automatically updated periodically with new children. I want the heading line to show the number of children.

So if I have one child it would say something like (1)

* Heading (1)
** Subheading

After it gets updated with another subheading the number should automatically be changed to (2)

* Heading (2)
** Subheading
** A new added subheading

I want it to do this because the toplevel heading will normally be collapsed. I want to be able to see if any new children were added to it without having to expand it


回答1:


What's most similar to what you're searching are called statistics cookies. They're described at the end of this page in the manual. At first meant for lists, but that can also count headlines. Just put [/] at the end of your header, like so :

* Main header [/]
** sub-header 1
** sub-header 2
** sub-header 3

And press C-c C-c on the cookie to update it (make it update its count). What you do need to add to what you describe to be your use-case is TODO keywords to your headers, because what the cookie will count is how many are done over how many are to do. Therefore I suggest you mark them all as DONE, like so :

* Main header [3/3]
** DONE sub-header 1
** DONE sub-header 2
** DONE sub-header 3

Then, the counter will show you what you want.

You could probably adapt these cookies' code to meet your precise needs.



来源:https://stackoverflow.com/questions/13372550/orgmode-show-number-of-children-under-heading

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!