Nice and compact! John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Sat, Jan 31, 2015 at 12:47 PM, Nicolas Goaziou wrote: > Hello, > > John Kitchin 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 >