Hi all, I just had an awesome conversation with Sacha about more effective daily/weekly reviewing with org-mode :-) One of the things we talked about was quantifying the number of tasks (TODO keywords) in any given state, as a means of becoming more aware of your progress over time. I have had some success in the past using the "measure what you want to manage maxim"[1], and wanted to start applying this to my horribly massive TODO.org file.
Back in 2008, Carsten very generously implemented the `org-map-entries' API function at my request[2] in order to facilitate this kind of measurement, and I'm somewhat ashamed to say that I've only just started to take advantage of it: (defun org-count-matches (search) "Count the number of matches from the given tag search in the current buffer, respecting any scope restriction." (interactive "sMatch: ") (length (org-map-entries t search))) (defun org-dblock-write:count (params) "Write a table showing the number of occurrences of each of the specified keywords and tag searches. Example usage: #+BEGIN:dynamic block #+BEGIN: count :keywords (\"NEXT\" \"DONE\") :searches (\"@phone\" \"@home\") | NEXT | 522 | | DONE | 69 | | @phone | 77 | | @home | 182 | #+END: " (let ((keywords (plist-get params :keywords)) (searches (plist-get params :searches)) (format "| %-10s | %3d |\n")) (insert (concat (mapconcat (lambda (keyword) (format format keyword (org-count-matches (concat "/" keyword)))) keywords "") (mapconcat (lambda (search) (format format search (org-count-matches search))) searches ""))) (backward-delete-char 1))) Sacha deserves a lot of credit for reminding me how easy it would be to do this :-) I suppose the next step would be to automate appending counts to a CSV file or transmitting them to some kind of graphing service like https://tempo-db.com/ (or preferably some free alternative like quantifiedawesome ;-) via a REST API. [1] http://blog.adamspiers.org/2011/05/15/email-nirvana/ [2] http://lists.gnu.org/archive/html/emacs-orgmode/2008-06/msg00208.html