From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: How to compute the number of headlines under the given headline? Date: Sat, 31 Jan 2015 18:47:17 +0100 Message-ID: <87mw4yona2.fsf@nicolasgoaziou.fr> 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]:38774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHc7h-0007sA-Jz for emacs-orgmode@gnu.org; Sat, 31 Jan 2015 12:46:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YHc7d-0008JA-Ez for emacs-orgmode@gnu.org; Sat, 31 Jan 2015 12:46:21 -0500 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:60953) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHc7d-0008IG-9k for emacs-orgmode@gnu.org; Sat, 31 Jan 2015 12:46:17 -0500 In-Reply-To: (John Kitchin's message of "Sat, 31 Jan 2015 09:37:34 -0500") 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: John Kitchin Cc: Org-Mode mailing list , Marcin Borkowski 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