Tohiko
Tohiko

Reputation: 1982

org-mode: Number of items with a specific keyword

I am a bit new to org customization.

Is there a way to get the number of items with a TODO (or NEXT) keyword in an org document? I found this

https://metacpan.org/pod/distribution/App-OrgUtils/bin/count-org-todos

But I would rather have a solution that uses Emacs environment.

EDIT: This seems to do the trick. Not sure if there is a more elegant solution

(apply '+ (org-map-entries (lambda () 1) "/TODO|NEXT")) 

Upvotes: 1

Views: 272

Answers (1)

ebpa
ebpa

Reputation: 1259

You are right; org-map-entries is a great tool to accomplish what. You might try the alternate syntax per convention, but the form you have is nice and terse. I personally write that sort of query as:

(length (org-map-entries nil "+TODO=\"TODO\"|+TODO=\"NEXT\"" 'file))

Upvotes: 3

Related Questions