From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Spiers Subject: org-dblock-write:count Date: Sun, 9 Feb 2014 13:03:51 +0000 Message-ID: <20140209130350.GC16519@pacific.linksys.moosehall> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCU3D-0002jM-MG for emacs-orgmode@gnu.org; Sun, 09 Feb 2014 08:04:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCU38-0006Cd-Pz for emacs-orgmode@gnu.org; Sun, 09 Feb 2014 08:03:59 -0500 Received: from coral.adamspiers.org ([85.119.82.20]:56011) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCU38-0006CO-Jv for emacs-orgmode@gnu.org; Sun, 09 Feb 2014 08:03:54 -0500 Received: from localhost (243.103.2.81.in-addr.arpa [81.2.103.243]) by coral.adamspiers.org (Postfix) with ESMTPSA id 89A972E313 for ; Sun, 9 Feb 2014 13:03:51 +0000 (GMT) Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: org-mode mailing list 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