emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to compute the number of headlines under the given headline?


From: Nicolas Goaziou
Subject: Re: [O] How to compute the number of headlines under the given headline?
Date: Sat, 31 Jan 2015 18:47:17 +0100

Hello,

John Kitchin <address@hidden> writes:

> What about:
>
> * Count headlines in current level
>
>
> #+BEGIN_SRC emacs-lisp
> (save-restriction
>   (org-narrow-to-subtree)
>   (1- (length
>    (org-element-map
>        (org-element-parse-buffer)
>        'headline
>      (lambda (x) 1)))))
> #+END_SRC
>
> #+RESULTS:
> : 5
>
> ** one
> ** two
> *** three
> **** four
> ** five
>
>
> This counts the headline you are in, so I subtract one from the total
> count.

Note that, in this case, 

  (org-element-parse-buffer 'headline)

is much more efficient.


Regards,

-- 
Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]