From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Lawrence Subject: Re: Get counting of items Date: Tue, 01 Apr 2014 15:55:30 -0700 Message-ID: <877g78mzh9.fsf@berkeley.edu> References: <87txadmnl2.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVhTN-0005G7-7u for emacs-orgmode@gnu.org; Thu, 03 Apr 2014 09:14:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVhTG-0001YR-2j for emacs-orgmode@gnu.org; Thu, 03 Apr 2014 09:14:25 -0400 Received: from plane.gmane.org ([80.91.229.3]:41198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVhTF-0001Y6-SU for emacs-orgmode@gnu.org; Thu, 03 Apr 2014 09:14:18 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WVgPM-0003P7-C3 for emacs-orgmode@gnu.org; Thu, 03 Apr 2014 14:06:12 +0200 Received: from c-67-164-45-159.hsd1.ca.comcast.net ([67.164.45.159]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Apr 2014 14:06:12 +0200 Received: from richard.lawrence by c-67-164-45-159.hsd1.ca.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Apr 2014 14:06:12 +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 Thorsten Jolitz writes: > #+begin_src emacs-lisp > (with-current-buffer "my.org" > (eval (append (list '+) > (org-map-entries > (lambda () (if (eq (org-outline-level) 1) 1 0)))))) > #+end_src Or, slightly more simply: #+begin_src emacs-lisp (with-current-buffer "my.org" (apply '+ (org-map-entries (lambda () (if (eq (org-outline-level) 1) 1 0))))) #+end_src which you could wrap into a function like: #+begin_src emacs-lisp (defun count-toplevel-headlines () "Count the top level headlines in the current buffer" (interactive) (message (format "Number of first level headlines: %s" (save-excursion (apply '+ (org-map-entries (lambda () (if (eq (org-outline-level) 1) 1 0)))))))) #+end_src Best, Richard (If possible, please encrypt your reply to me using my PGP key: Key ID: CF6FA646 Fingerprint: 9969 43E1 CF6F A646. See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)