Skip to content

Instantly share code, notes, and snippets.

@sachac
Created January 4, 2015 22:24
Show Gist options
  • Save sachac/3559caa2770ae63ec437 to your computer and use it in GitHub Desktop.
Save sachac/3559caa2770ae63ec437 to your computer and use it in GitHub Desktop.
(defun sacha/org-count-tasks-by-status ()
(interactive)
(let ((counts (make-hash-table :test 'equal))
(today (format-time-string "%Y-%m-%d" (current-time)))
values)
(org-map-entries
(lambda ()
(let* ((status (elt (org-heading-components) 2)))
(when status
(puthash status (1+ (or (gethash status counts) 0)) counts))))
nil
'agenda)
(setq values (mapcar (lambda (x)
(or (gethash x counts) 0))
'("DONE" "STARTED" "TODO" "WAITING" "DELEGATED" "CANCELLED" "SOMEDAY")))
(insert "| " today " | "
(mapconcat 'number-to-string values " | ")
" | "
(number-to-string (apply '+ values))
" | "
(number-to-string
(round (/ (* 100.0 (car values)) (apply '+ values))))
"% |\n")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment