From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Gross Subject: Re: Get counting of items Date: Thu, 3 Apr 2014 10:39:18 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVdBC-0007Sg-LW for emacs-orgmode@gnu.org; Thu, 03 Apr 2014 04:39:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVdBA-00077C-G3 for emacs-orgmode@gnu.org; Thu, 03 Apr 2014 04:39:22 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:51261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVdBA-00076w-8Q for emacs-orgmode@gnu.org; Thu, 03 Apr 2014 04:39:20 -0400 Received: by mail-wi0-f171.google.com with SMTP id q5so8649548wiv.16 for ; Thu, 03 Apr 2014 01:39:18 -0700 (PDT) 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" Dear Thorsten > 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 v org-map-entries for more info, its very powerfull. Use it > with M-: (count-org-items ...) or write a more sophisticated > (interactive) spec. > Very impressive. Thank you very much! Martin