update packages
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
;;; org-effectiveness.el --- Measuring the personal effectiveness
|
||||
;;; org-effectiveness.el --- Measuring the personal effectiveness -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2013-2021 Free Software Foundation, Inc.
|
||||
|
||||
@@ -91,7 +91,8 @@ many TODO pending"
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(let ((done (float (count-matches "* DONE.*\n.*")))
|
||||
(canc (float (count-matches "* CANCEL+ED.*\n.*"))))
|
||||
(canc (float (count-matches "* CANCEL+ED.*\n.*")))
|
||||
effectiveness)
|
||||
(if (and (= done canc) (zerop done))
|
||||
(setq effectiveness 0)
|
||||
(setq effectiveness (* 100 (/ done (+ done canc)))))
|
||||
@@ -100,8 +101,8 @@ many TODO pending"
|
||||
|
||||
(defun org-effectiveness-keywords-in-date(keyword date)
|
||||
(interactive "sKeyword: \nsDate: " keyword date)
|
||||
(setq count (count-matches (concat keyword ".*\n.*" date)))
|
||||
(message (concat "%sS: %d" keyword count)))
|
||||
(let ((count (count-matches (concat keyword ".*\n.*" date))))
|
||||
(message (concat "%sS: %d" keyword count))))
|
||||
|
||||
(defun org-effectiveness-dones-in-date(date &optional notmessage)
|
||||
(interactive "sGive me a date: " date)
|
||||
@@ -116,17 +117,17 @@ many TODO pending"
|
||||
(interactive "sGive me a date: " date)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(setq count (count-matches (concat "TODO.*\n.*" date)))
|
||||
(message "TODOS: %d" count)))
|
||||
(let ((count (count-matches (concat "TODO.*\n.*" date))))
|
||||
(message "TODOS: %d" count))))
|
||||
|
||||
(defun org-effectiveness-canceled-in-date(date)
|
||||
(interactive "sGive me a date: " date)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(setq count (count-matches (concat "CANCEL+ED.*\n.*" date)))
|
||||
(message "CANCELEDS: %d" count)))
|
||||
(let ((count (count-matches (concat "CANCEL+ED.*\n.*" date))))
|
||||
(message "CANCELEDS: %d" count))))
|
||||
|
||||
(defun org-effectiveness-ntasks-in-date(date &optional notmessage)
|
||||
(defun org-effectiveness-ntasks-in-date(date &optional _)
|
||||
(interactive "sGive me a date: " date)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
@@ -138,7 +139,8 @@ many TODO pending"
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(let ((done (float (count-matches (concat "* DONE.*\n.*" date))))
|
||||
(canc (float (count-matches (concat "* CANCEL+ED.*\n.*" date)))))
|
||||
(canc (float (count-matches (concat "* CANCEL+ED.*\n.*" date))))
|
||||
effectiveness)
|
||||
(if (and (= done canc) (zerop done))
|
||||
(setq effectiveness 0)
|
||||
(setq effectiveness (* 100 (/ done (+ done canc)))))
|
||||
@@ -153,50 +155,51 @@ many TODO pending"
|
||||
|
||||
(defun org-effectiveness-plot(startdate enddate &optional save)
|
||||
(interactive "sGive me the start date: \nsGive me the end date: " startdate enddate)
|
||||
(setq dates (org-effectiveness-check-dates startdate enddate))
|
||||
(setq syear (cadr (assq 'startyear dates)))
|
||||
(setq smonth (cadr (assq 'startmonth dates)))
|
||||
(setq eyear (cadr (assq 'endyear dates)))
|
||||
(setq emonth (assq 'endmonth dates))
|
||||
;; Checking the format of the dates
|
||||
(if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" startdate))
|
||||
(message "The start date must have the next format YYYY-MM"))
|
||||
(if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" enddate))
|
||||
(message "The end date must have the next format YYYY-MM"))
|
||||
;; Checking if startdate < enddate
|
||||
(if (string-match "^[0-9][0-9][0-9][0-9]" startdate)
|
||||
(setq startyear (string-to-number (match-string 0 startdate))))
|
||||
(if (string-match "[0-9][0-9]$" startdate)
|
||||
(setq startmonth (string-to-number (match-string 0 startdate))))
|
||||
(if (string-match "^[0-9][0-9][0-9][0-9]" enddate)
|
||||
(setq endyear (string-to-number (match-string 0 enddate))))
|
||||
(if (string-match "[0-9][0-9]$" enddate)
|
||||
(setq endmonth (string-to-number (match-string 0 enddate))))
|
||||
(if (> startyear endyear)
|
||||
(message "The start date must be before that end date"))
|
||||
(if (and (= startyear endyear) (> startmonth endmonth))
|
||||
(message "The start date must be before that end date"))
|
||||
;; Create a file
|
||||
(let ((month startmonth)
|
||||
(year startyear)
|
||||
(str ""))
|
||||
(while (or (> endyear year) (and (= endyear year) (>= endmonth month)))
|
||||
(setq str (concat str (number-to-string year) "-" (org-effectiveness-month-to-string month) " " (org-effectiveness-in-date (concat (number-to-string year) "-" (org-effectiveness-month-to-string month)) 1) "\n"))
|
||||
(if (= month 12)
|
||||
(progn
|
||||
(setq year (+ 1 year))
|
||||
(setq month 1))
|
||||
(setq month (+ 1 month))))
|
||||
(let* (;; (dates (org-effectiveness-check-dates startdate enddate))
|
||||
;; (syear (cadr (assq 'startyear dates)))
|
||||
;; (smonth (cadr (assq 'startmonth dates)))
|
||||
;; (eyear (cadr (assq 'endyear dates)))
|
||||
;; (emonth (assq 'endmonth dates))
|
||||
startyear startmonth endyear endmonth strplot)
|
||||
;; Checking the format of the dates
|
||||
(if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" startdate))
|
||||
(message "The start date must have the next format YYYY-MM"))
|
||||
(if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" enddate))
|
||||
(message "The end date must have the next format YYYY-MM"))
|
||||
;; Checking if startdate < enddate
|
||||
(if (string-match "^[0-9][0-9][0-9][0-9]" startdate)
|
||||
(setq startyear (string-to-number (match-string 0 startdate))))
|
||||
(if (string-match "[0-9][0-9]$" startdate)
|
||||
(setq startmonth (string-to-number (match-string 0 startdate))))
|
||||
(if (string-match "^[0-9][0-9][0-9][0-9]" enddate)
|
||||
(setq endyear (string-to-number (match-string 0 enddate))))
|
||||
(if (string-match "[0-9][0-9]$" enddate)
|
||||
(setq endmonth (string-to-number (match-string 0 enddate))))
|
||||
(if (> startyear endyear)
|
||||
(message "The start date must be before that end date"))
|
||||
(if (and (= startyear endyear) (> startmonth endmonth))
|
||||
(message "The start date must be before that end date"))
|
||||
;; Create a file
|
||||
(let ((month startmonth)
|
||||
(year startyear)
|
||||
(str ""))
|
||||
(while (or (> endyear year) (and (= endyear year) (>= endmonth month)))
|
||||
(setq str (concat str (number-to-string year) "-" (org-effectiveness-month-to-string month) " " (org-effectiveness-in-date (concat (number-to-string year) "-" (org-effectiveness-month-to-string month)) 1) "\n"))
|
||||
(if (= month 12)
|
||||
(progn
|
||||
(setq year (+ 1 year))
|
||||
(setq month 1))
|
||||
(setq month (+ 1 month))))
|
||||
(write-region str nil "/tmp/org-effectiveness"))
|
||||
;; Create the bar graph
|
||||
(if (eq save t)
|
||||
(setq strplot "/usr/bin/gnuplot -e 'set term png; set output \"/tmp/org-effectiveness.png\"; plot \"/tmp/org-effectiveness\" using 2:xticlabels(1) with histograms' -p")
|
||||
(setq strplot "/usr/bin/gnuplot -e 'plot \"/tmp/org-effectiveness\" using 2:xticlabels(1) with histograms' -p"))
|
||||
(if (file-exists-p "/usr/bin/gnuplot")
|
||||
(call-process "/bin/bash" nil t nil "-c" strplot)
|
||||
(message "gnuplot is not installed")))
|
||||
;; Create the bar graph
|
||||
(if (eq save t)
|
||||
(setq strplot "/usr/bin/gnuplot -e 'set term png; set output \"/tmp/org-effectiveness.png\"; plot \"/tmp/org-effectiveness\" using 2:xticlabels(1) with histograms' -p")
|
||||
(setq strplot "/usr/bin/gnuplot -e 'plot \"/tmp/org-effectiveness\" using 2:xticlabels(1) with histograms' -p"))
|
||||
(if (file-exists-p "/usr/bin/gnuplot")
|
||||
(call-process "/bin/bash" nil t nil "-c" strplot)
|
||||
(message "gnuplot is not installed"))))
|
||||
|
||||
(defun org-effectiveness-plot-save(startdate enddate &optional save)
|
||||
(defun org-effectiveness-plot-save(startdate enddate &optional _)
|
||||
(interactive "sGive me the start date: \nsGive me the end date: " startdate enddate)
|
||||
(org-effectiveness-plot startdate enddate t))
|
||||
|
||||
@@ -230,54 +233,57 @@ many TODO pending"
|
||||
(setq z (+ z 1)))
|
||||
(insert "+"))))
|
||||
|
||||
(defun org-effectiveness-html-bar(n &optional label)
|
||||
(defun org-effectiveness-html-bar(n &optional _)
|
||||
"Print a bar with the percentage from 0 to 100 printed in html"
|
||||
(interactive "nPercentage: \nsLabel: ")
|
||||
(if (or (< n 0) (> n 100))
|
||||
(message "The percentage must be between 0 to 100")
|
||||
(let ((x 0)
|
||||
(y 0)
|
||||
(z 0))
|
||||
(insert (format "\n<div class='percentage-%d'>%d</div>" n n))
|
||||
)))
|
||||
(insert (format "\n<div class='percentage-%d'>%d</div>" n n))
|
||||
;; FIXME: What are x,y,z for?
|
||||
;; (let ((x 0)
|
||||
;; (y 0)
|
||||
;; (z 0))
|
||||
;; (insert (format "\n<div class='percentage-%d'>%d</div>" n n))
|
||||
;; )
|
||||
))
|
||||
|
||||
|
||||
(defun org-effectiveness-check-dates (startdate enddate)
|
||||
"Generate a list with ((startyear startmonth) (endyear endmonth))"
|
||||
(setq str nil)
|
||||
(if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" startdate))
|
||||
(setq str "The start date must have the next format YYYY-MM"))
|
||||
(if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" enddate))
|
||||
(setq str "The end date must have the next format YYYY-MM"))
|
||||
;; Checking if startdate < enddate
|
||||
(if (string-match "^[0-9][0-9][0-9][0-9]" startdate)
|
||||
(setq startyear (string-to-number (match-string 0 startdate))))
|
||||
(if (string-match "[0-9][0-9]$" startdate)
|
||||
(setq startmonth (string-to-number (match-string 0 startdate))))
|
||||
(if (string-match "^[0-9][0-9][0-9][0-9]" enddate)
|
||||
(setq endyear (string-to-number (match-string 0 enddate))))
|
||||
(if (string-match "[0-9][0-9]$" enddate)
|
||||
(setq endmonth (string-to-number (match-string 0 enddate))))
|
||||
(if (> startyear endyear)
|
||||
(setq str "The start date must be before that end date"))
|
||||
(if (and (= startyear endyear) (> startmonth endmonth))
|
||||
(setq str "The start date must be before that end date"))
|
||||
(if str
|
||||
(message str)
|
||||
;; (list (list startyear startmonth) (list endyear endmonth))))
|
||||
(list (list 'startyear startyear) (list 'startmonth startmonth) (list 'endyear endyear) (list 'endmonth endmonth))))
|
||||
(let (str startmonth startyear endmonth endyear)
|
||||
(if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" startdate))
|
||||
(setq str "The start date must have the next format YYYY-MM"))
|
||||
(if (not (string-match "[0-9][0-9][0-9][0-9]-[0-9][0-9]" enddate))
|
||||
(setq str "The end date must have the next format YYYY-MM"))
|
||||
;; Checking if startdate < enddate
|
||||
(if (string-match "^[0-9][0-9][0-9][0-9]" startdate)
|
||||
(setq startyear (string-to-number (match-string 0 startdate))))
|
||||
(if (string-match "[0-9][0-9]$" startdate)
|
||||
(setq startmonth (string-to-number (match-string 0 startdate))))
|
||||
(if (string-match "^[0-9][0-9][0-9][0-9]" enddate)
|
||||
(setq endyear (string-to-number (match-string 0 enddate))))
|
||||
(if (string-match "[0-9][0-9]$" enddate)
|
||||
(setq endmonth (string-to-number (match-string 0 enddate))))
|
||||
(if (> startyear endyear)
|
||||
(setq str "The start date must be before that end date"))
|
||||
(if (and (= startyear endyear) (> startmonth endmonth))
|
||||
(setq str "The start date must be before that end date"))
|
||||
(if str
|
||||
(message str)
|
||||
;; (list (list startyear startmonth) (list endyear endmonth))))
|
||||
(list (list 'startyear startyear) (list 'startmonth startmonth) (list 'endyear endyear) (list 'endmonth endmonth)))))
|
||||
|
||||
(defun org-effectiveness-plot-ascii (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 (assq 'startyear dates)))
|
||||
(smonth (cadr (assq 'startmonth dates)))
|
||||
(year (cadr (assq 'startyear dates)))
|
||||
(month (cadr (assq 'startmonth dates)))
|
||||
(emonth (cadr (assq 'endmonth dates)))
|
||||
(eyear (cadr (assq 'endyear dates)))
|
||||
(buffer (current-buffer))
|
||||
(str ""))
|
||||
(let* ((dates (org-effectiveness-check-dates startdate enddate))
|
||||
;; (syear (cadr (assq 'startyear dates)))
|
||||
;; (smonth (cadr (assq 'startmonth dates)))
|
||||
(year (cadr (assq 'startyear dates)))
|
||||
(month (cadr (assq 'startmonth dates)))
|
||||
(emonth (cadr (assq 'endmonth dates)))
|
||||
(eyear (cadr (assq 'endyear dates)))
|
||||
(buffer (current-buffer))
|
||||
(str ""))
|
||||
(while (or (> eyear year) (and (= eyear year) (>= emonth month)))
|
||||
(setq str (org-effectiveness-in-date (concat (number-to-string year) "-" (org-effectiveness-month-to-string month)) 1))
|
||||
(switch-to-buffer "*org-effectiveness*")
|
||||
@@ -293,15 +299,15 @@ many TODO pending"
|
||||
|
||||
(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 (assq 'startyear dates)))
|
||||
(smonth (cadr (assq 'startmonth dates)))
|
||||
(year (cadr (assq 'startyear dates)))
|
||||
(month (cadr (assq 'startmonth dates)))
|
||||
(emonth (cadr (assq 'endmonth dates)))
|
||||
(eyear (cadr (assq 'endyear dates)))
|
||||
(buffer (current-buffer))
|
||||
(str ""))
|
||||
(let* ((dates (org-effectiveness-check-dates startdate enddate))
|
||||
;; (syear (cadr (assq 'startyear dates)))
|
||||
;; (smonth (cadr (assq 'startmonth dates)))
|
||||
(year (cadr (assq 'startyear dates)))
|
||||
(month (cadr (assq 'startmonth dates)))
|
||||
(emonth (cadr (assq 'endmonth dates)))
|
||||
(eyear (cadr (assq '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*")
|
||||
@@ -316,15 +322,15 @@ many TODO pending"
|
||||
|
||||
(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 (assq 'startyear dates)))
|
||||
(smonth (cadr (assq 'startmonth dates)))
|
||||
(year (cadr (assq 'startyear dates)))
|
||||
(month (cadr (assq 'startmonth dates)))
|
||||
(emonth (cadr (assq 'endmonth dates)))
|
||||
(eyear (cadr (assq 'endyear dates)))
|
||||
(buffer (current-buffer))
|
||||
(str ""))
|
||||
(let* ((dates (org-effectiveness-check-dates startdate enddate))
|
||||
;; (syear (cadr (assq 'startyear dates)))
|
||||
;; (smonth (cadr (assq 'startmonth dates)))
|
||||
(year (cadr (assq 'startyear dates)))
|
||||
(month (cadr (assq 'startmonth dates)))
|
||||
(emonth (cadr (assq 'endmonth dates)))
|
||||
(eyear (cadr (assq '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*")
|
||||
@@ -341,15 +347,15 @@ many TODO pending"
|
||||
(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)
|
||||
(setq dates (org-effectiveness-check-dates startdate enddate))
|
||||
(let ((syear (cadr (assq 'startyear dates)))
|
||||
(smonth (cadr (assq 'startmonth dates)))
|
||||
(year (cadr (assq 'startyear dates)))
|
||||
(month (cadr (assq 'startmonth dates)))
|
||||
(emonth (cadr (assq 'endmonth dates)))
|
||||
(eyear (cadr (assq 'endyear dates)))
|
||||
(buffer (current-buffer))
|
||||
(str ""))
|
||||
(let* ((dates (org-effectiveness-check-dates startdate enddate))
|
||||
;; (syear (cadr (assq 'startyear dates)))
|
||||
;; (smonth (cadr (assq 'startmonth dates)))
|
||||
(year (cadr (assq 'startyear dates)))
|
||||
(month (cadr (assq 'startmonth dates)))
|
||||
(emonth (cadr (assq 'endmonth dates)))
|
||||
(eyear (cadr (assq 'endyear dates)))
|
||||
(buffer (current-buffer))
|
||||
(str ""))
|
||||
(switch-to-buffer "*org-effectiveness-html*")
|
||||
(insert "<html><head><title>Graphbar</title><meta http-equiv='Content-type' content='text/html; charset=utf-8'><link rel='stylesheet' type='text/css' href='graphbar.css' title='graphbar'></head><body>")
|
||||
(while (or (> eyear year) (and (= eyear year) (>= emonth month)))
|
||||
@@ -357,7 +363,8 @@ many TODO pending"
|
||||
(switch-to-buffer "*org-effectiveness-html*")
|
||||
(org-effectiveness-html-bar (string-to-number str) (format "%s-%s" year month))
|
||||
(switch-to-buffer buffer)
|
||||
(format "%s-%s" year month)
|
||||
;; FIXME: Value is unused.
|
||||
;; (format "%s-%s" year month)
|
||||
(if (eq month 12)
|
||||
(progn
|
||||
(setq year (+ 1 year))
|
||||
|
||||
Reference in New Issue
Block a user