emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Get total number of items
@ 2014-06-22  6:11 Chris Henderson
  2014-06-22  7:59 ` Thorsten Jolitz
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Henderson @ 2014-06-22  6:11 UTC (permalink / raw)
  To: org-mode

[-- Attachment #1: Type: text/plain, Size: 150 bytes --]

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.

Thanks.

[-- Attachment #2: Type: text/html, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Get total number of items
  2014-06-22  6:11 Get total number of items Chris Henderson
@ 2014-06-22  7:59 ` Thorsten Jolitz
  0 siblings, 0 replies; 2+ messages in thread
From: Thorsten Jolitz @ 2014-06-22  7:59 UTC (permalink / raw)
  To: emacs-orgmode

Chris Henderson <henders254@gmail.com> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-22  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-22  6:11 Get total number of items Chris Henderson
2014-06-22  7:59 ` Thorsten Jolitz

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).