emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Adam Spiers <orgmode@adamspiers.org>
To: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: org-dblock-write:count
Date: Sun, 9 Feb 2014 13:03:51 +0000	[thread overview]
Message-ID: <20140209130350.GC16519@pacific.linksys.moosehall> (raw)

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

             reply	other threads:[~2014-02-09 13:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-09 13:03 Adam Spiers [this message]
2014-02-10  9:50 ` org-dblock-write:count Sebastien Vauban
2014-02-14 12:42   ` org-dblock-write:count Sebastien Vauban

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=20140209130350.GC16519@pacific.linksys.moosehall \
    --to=orgmode@adamspiers.org \
    --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).