Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Orgmode: Show number of children under heading

Tags:

org-mode

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

like image 585
Sean Lynch Avatar asked Nov 14 '12 03:11

Sean Lynch


1 Answers

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.

like image 171
Nikana Reklawyks Avatar answered Jan 03 '23 13:01

Nikana Reklawyks