From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: How to compute the number of headlines under the given headline? Date: Sat, 31 Jan 2015 09:37:34 -0500 Message-ID: References: <87d25vqfqt.fsf@wmi.amu.edu.pl> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHZB9-0001zN-D1 for emacs-orgmode@gnu.org; Sat, 31 Jan 2015 09:37:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YHZB4-00064O-Ab for emacs-orgmode@gnu.org; Sat, 31 Jan 2015 09:37:43 -0500 Received: from smtp.andrew.cmu.edu ([128.2.105.203]:37153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHZB4-00063t-6B for emacs-orgmode@gnu.org; Sat, 31 Jan 2015 09:37:38 -0500 In-reply-to: <87d25vqfqt.fsf@wmi.amu.edu.pl> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Marcin Borkowski Cc: Org-Mode mailing list 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. Marcin Borkowski writes: > Hello, > > I'd like to count the number of children (alternatively, number of all > descendants) of an Org headline. Is there a ready-made function for > that? If not, would using org-forward-heading-same-level and similar > functions in Lisp code be a good idea? > > TIA, -- 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