Eric Abrahamsen <e...@ericabrahamsen.net> writes: > 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.
Ups, that was me ... forgot about it ;) #+begin_quote From: Martin Gross <m-gr...@gmx.net> Subject: Re: Get counting of items Newsgroups: gmane.emacs.orgmode To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org> Date: Thu, 3 Apr 2014 10:39:18 +0200 (2 weeks, 3 hours, 19 minutes ago) 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 f org-map-entries for more info, its very powerfull. Use it > with M-: (count-org-items ...) or write a more sophisticated > (interactive) spec. #+end_quote -- cheers, Thorsten