From 5d78665c8cf8ebf9bb2738a3106a24476491c38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Arroyo=20Men=C3=A9ndez?= Date: Mon, 18 Jan 2016 10:21:02 +0100 Subject: [PATCH] org-effectiveness.el: Add org-effectiveness-ntasks-in-date and org-effectiveness-plot-ascii-ntasks * contrib/lisp/org-effectiveness.el (org-effectiveness-ntasks-in-date, org-effectiveness-plot-ascii-ntasks): Add functions. --- contrib/lisp/org-effectiveness.el | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/contrib/lisp/org-effectiveness.el b/contrib/lisp/org-effectiveness.el index cbb984720..4dd4d94ca 100644 --- a/contrib/lisp/org-effectiveness.el +++ b/contrib/lisp/org-effectiveness.el @@ -116,6 +116,13 @@ many TODO pending" (setq count (count-matches (concat "CANCEL+ED.*\n.*" date))) (message "CANCELEDS: %d" count)) +(defun org-effectiveness-ntasks-in-date(date &optional notmessage) + (interactive "sGive me a date: " date) + (save-excursion + (goto-char (point-min)) + (let ((tasks (float (count-matches (concat "^*.*\n.*" date))))) + (message "%d" tasks)))) + (defun org-effectiveness-in-date(date &optional notmessage) (interactive "sGive me a date: " date) (save-excursion @@ -273,6 +280,30 @@ many TODO pending" (setq month (+ 1 month))))) (switch-to-buffer "*org-effectiveness*")) + +(defun org-effectiveness-plot-ascii-ntasks (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-ntasks-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)