org-effectiveness.el: Add org-effectiveness-plot-ascii-dones, fix org-effectiveness-advice and fix org-effectiveness-dones-in-date.

This commit is contained in:
David Arroyo Menéndez 2016-01-25 15:24:25 +01:00
parent 0c3ea42a7c
commit 26fb4fa54e
1 changed files with 33 additions and 6 deletions

View File

@ -42,9 +42,10 @@ many TODO pending"
(defun org-effectiveness-advice()
"Advicing about a possible excess of TODOS"
(interactive)
(goto-char (point-min))
(if (< org-effectiveness-max-todo (count-matches "* TODO"))
(message "An excess of TODOS!")))
(save-excursion
(goto-char (point-min))
(if (< org-effectiveness-max-todo (count-matches "* TODO"))
(message "An excess of TODOS!"))))
;; Check advice starting an org file
(add-hook 'org-mode-hook 'org-effectiveness-advice)
@ -102,12 +103,14 @@ many TODO pending"
(setq count (count-matches (concat keyword ".*\n.*" date)))
(message (concat "%sS: %d" keyword count)))
(defun org-effectiveness-dones-in-date(date)
(defun org-effectiveness-dones-in-date(date &optional notmessage)
(interactive "sGive me a date: " date)
(save-excursion
(goto-char (point-min))
(setq count (count-matches (concat "DONE.*\n.*" date)))
(message "DONES: %d" count)))
(let ((count (count-matches (concat "DONE.*\n.*" date))))
(if (eq notmessage 1)
(message "%d" count)
(message "DONES: %d " count)))))
(defun org-effectiveness-todos-in-date(date)
(interactive "sGive me a date: " date)
@ -311,6 +314,30 @@ many TODO pending"
(setq month (+ 1 month)))))
(switch-to-buffer "*org-effectiveness*"))
(defun org-effectiveness-plot-ascii-dones (startdate enddate)
(interactive "sGive me the start date: \nsGive me the end date: " startdate enddate)
(setq dates (org-effectiveness-check-dates startdate enddate))
(let ((syear (cadr (assoc 'startyear dates)))
(smonth (cadr (assoc 'startmonth dates)))
(year (cadr (assoc 'startyear dates)))
(month (cadr (assoc 'startmonth dates)))
(emonth (cadr (assoc 'endmonth dates)))
(eyear (cadr (assoc 'endyear dates)))
(buffer (current-buffer))
(str ""))
(while (or (> eyear year) (and (= eyear year) (>= emonth month)))
(setq str (org-effectiveness-dones-in-date (concat (number-to-string year) "-" (org-effectiveness-month-to-string month)) 1))
(switch-to-buffer "*org-effectiveness*")
(org-effectiveness-ascii-bar (string-to-number str) (format "%s-%s" year month))
(switch-to-buffer buffer)
(if (eq month 12)
(progn
(setq year (+ 1 year))
(setq month 1))
(setq month (+ 1 month)))))
(switch-to-buffer "*org-effectiveness*"))
(defun org-effectiveness-plot-html (startdate enddate)
"Print html bars about the effectiveness in a buffer"
(interactive "sGive me the start date: \nsGive me the end date: " startdate enddate)