From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: Get total number of items Date: Sun, 22 Jun 2014 09:59:45 +0200 Message-ID: <878uopnzm6.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wych7-0002TO-DD for emacs-orgmode@gnu.org; Sun, 22 Jun 2014 04:00:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wycgz-00062p-Tv for emacs-orgmode@gnu.org; Sun, 22 Jun 2014 04:00:09 -0400 Received: from plane.gmane.org ([80.91.229.3]:48135) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wycgz-00062D-OL for emacs-orgmode@gnu.org; Sun, 22 Jun 2014 04:00:01 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Wycgx-0006MH-If for emacs-orgmode@gnu.org; Sun, 22 Jun 2014 09:59:59 +0200 Received: from g231234245.adsl.alicedsl.de ([92.231.234.245]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 22 Jun 2014 09:59:59 +0200 Received: from tjolitz by g231234245.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 22 Jun 2014 09:59:59 +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 Chris Henderson writes: > Is there a way to get the total number of items at the parent level? I > have lots of ** under a * and I'd like to see the number at a glance. that was asked before, here is what I came up with [using (apply '+ ...) instead of (eval (append (list '+ ...) ...)) would even be better]: > Here is a generalised form: > > #+begin_src emacs-lisp > (defun count-org-items (&optional level operator match scope skip) > "Print a counting of outline items." > (interactive) > (let ((headline-level (or level 1)) ; 1-8 > (op (or operator '=))) ; '>= '<= '> '< > (save-excursion > (message "Counting of level%s%d outline items (match=%s, scope=%s, skip=%s): %d" > op headline-level match scope skip > (eval (append (list '+) > (org-map-entries > `(lambda () (if (,op (org-outline-level) ,headline-level) 1 0)) > match scope skip))))))) > #+end_src > > usage: > > ,---------------------------------------- > | (count-org-items 2 '<= "WAITING" 'file) > `---------------------------------------- > > result: > > ,------------------------------------------------------------------------------ > | "Counting of level<=2 outline items (match=WAITING, scope=file, > | skip=nil): 3" > `------------------------------------------------------------------------------ > > see C-h f org-map-entries for more info, its very powerful. Use it > with M-: (count-org-items ...) or write a more sophisticated > (interactive) spec. -- cheers, Thorsten