From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Counting number of children under heading
Date: Thu, 17 Apr 2014 14:02:46 +0200 [thread overview]
Message-ID: <87d2ggduzd.fsf@gmail.com> (raw)
In-Reply-To: 871tww444g.fsf@ericabrahamsen.net
Eric Abrahamsen <eric@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-gross@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
next prev parent reply other threads:[~2014-04-17 12:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-17 9:15 Counting number of children under heading Marvin Doyley
2014-04-17 9:21 ` Bastien
2014-04-17 9:42 ` Thorsten Jolitz
2014-04-18 13:54 ` Sebastien Vauban
2014-04-18 14:50 ` Sacha Chua
2014-04-20 17:28 ` Sebastien Vauban
2014-04-21 2:55 ` Sacha Chua
2014-04-17 10:55 ` Eric Abrahamsen
2014-04-17 12:02 ` Thorsten Jolitz [this message]
2014-04-17 13:10 ` Eric Abrahamsen
-- strict thread matches above, loose matches on Subject: below --
2014-04-17 13:44 Marvin Doyley
2014-04-17 14:43 ` Thorsten Jolitz
2014-04-17 16:21 Doyley, Marvin M.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d2ggduzd.fsf@gmail.com \
--to=tjolitz@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).