From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: Counting number of children under heading Date: Thu, 17 Apr 2014 18:55:27 +0800 Message-ID: <871tww444g.fsf@ericabrahamsen.net> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wajvz-0002bg-Tz for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 06:52:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wajvq-0000s9-Oh for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 06:52:47 -0400 Received: from plane.gmane.org ([80.91.229.3]:39636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wajvq-0000s4-IP for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 06:52:38 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Wajvp-0005We-7b for emacs-orgmode@gnu.org; Thu, 17 Apr 2014 12:52:37 +0200 Received: from 111.197.155.200 ([111.197.155.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 17 Apr 2014 12:52:37 +0200 Received: from eric by 111.197.155.200 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 17 Apr 2014 12:52:37 +0200 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: emacs-orgmode@gnu.org Marvin Doyley writes: > Hi there, > > I would like to automatically count the number of children under a given heading. For example, I would like to have > > * Cars (2) > ** BMW > ** Escort > > Putting [/] at the end of header (in this case Cars), then putting the TODO keyword before each sub-header give me a partial solution > > * Cars [/] > ** TODO BMW > ** TODO Escort > > > Is there way to do this without using the TODO keyword ? > > Thanks, > M I could have sworn someone posted a thing for this just a week or two ago, using `org-map-entries' and the identity function, and counting the results. Anyway look at the docstring for `org-map-entries', it takes a SCOPE argument you can set to 'tree to just map the headings under the current one. A stupid example might look like: (apply '+ (org-map-entries (lambda () 1) t 'tree)) Though that will count the top-level heading, as well. E