contrib: Use assq instead of assoc with quoted symbols
This commit is contained in:
parent
48e7f17bc6
commit
67129acdfe
|
@ -34,7 +34,7 @@
|
|||
(require 'org)
|
||||
|
||||
(defcustom org-effectiveness-max-todo 50
|
||||
"This variable is useful to advice to the user about
|
||||
"This variable is useful to advice to the user about
|
||||
many TODO pending"
|
||||
:type 'integer
|
||||
:group 'org-effectiveness)
|
||||
|
@ -60,10 +60,10 @@ many TODO pending"
|
|||
(defun org-effectiveness-count-todo()
|
||||
"Print a message with the number of todo tasks in the current buffer"
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(message "Number of TODO: %d" (count-matches "* TODO"))))
|
||||
|
||||
|
||||
(defun org-effectiveness-count-done()
|
||||
"Print a message with the number of done tasks in the current buffer"
|
||||
(interactive)
|
||||
|
@ -154,14 +154,14 @@ 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 (assoc 'startyear dates)))
|
||||
(setq smonth (cadr (assoc 'startmonth dates)))
|
||||
(setq eyear (cadr (assoc 'endyear dates)))
|
||||
(setq emonth (assoc 'endmonth dates))
|
||||
(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))
|
||||
(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))
|
||||
(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)
|
||||
|
@ -176,19 +176,19 @@ many TODO pending"
|
|||
(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
|
||||
;; Create a file
|
||||
(let ((month startmonth)
|
||||
(year startyear)
|
||||
(str ""))
|
||||
(while (or (> endyear year) (and (= endyear year) (>= endmonth month)))
|
||||
(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
|
||||
(progn
|
||||
(setq year (+ 1 year))
|
||||
(setq month 1))
|
||||
(setq month (+ 1 month))))
|
||||
(write-region str nil "/tmp/org-effectiveness"))
|
||||
;; Create the bar graph
|
||||
;; 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"))
|
||||
|
@ -245,9 +245,9 @@ many TODO pending"
|
|||
(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))
|
||||
(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))
|
||||
(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)
|
||||
|
@ -270,12 +270,12 @@ many TODO pending"
|
|||
(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 (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)))
|
||||
(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 ""))
|
||||
(while (or (> eyear year) (and (= eyear year) (>= emonth month)))
|
||||
|
@ -284,7 +284,7 @@ many TODO pending"
|
|||
(org-effectiveness-ascii-bar (string-to-number str) (format "%s-%s" year month))
|
||||
(switch-to-buffer buffer)
|
||||
(if (eq month 12)
|
||||
(progn
|
||||
(progn
|
||||
(setq year (+ 1 year))
|
||||
(setq month 1))
|
||||
(setq month (+ 1 month)))))
|
||||
|
@ -294,12 +294,12 @@ 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 (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)))
|
||||
(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 ""))
|
||||
(while (or (> eyear year) (and (= eyear year) (>= emonth month)))
|
||||
|
@ -308,7 +308,7 @@ many TODO pending"
|
|||
(org-effectiveness-ascii-bar (string-to-number str) (format "%s-%s" year month))
|
||||
(switch-to-buffer buffer)
|
||||
(if (eq month 12)
|
||||
(progn
|
||||
(progn
|
||||
(setq year (+ 1 year))
|
||||
(setq month 1))
|
||||
(setq month (+ 1 month)))))
|
||||
|
@ -317,12 +317,12 @@ 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 (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)))
|
||||
(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 ""))
|
||||
(while (or (> eyear year) (and (= eyear year) (>= emonth month)))
|
||||
|
@ -331,7 +331,7 @@ many TODO pending"
|
|||
(org-effectiveness-ascii-bar (string-to-number str) (format "%s-%s" year month))
|
||||
(switch-to-buffer buffer)
|
||||
(if (eq month 12)
|
||||
(progn
|
||||
(progn
|
||||
(setq year (+ 1 year))
|
||||
(setq month 1))
|
||||
(setq month (+ 1 month)))))
|
||||
|
@ -342,12 +342,12 @@ many TODO pending"
|
|||
"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 (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)))
|
||||
(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 ""))
|
||||
(switch-to-buffer "*org-effectiveness-html*")
|
||||
|
@ -359,7 +359,7 @@ many TODO pending"
|
|||
(switch-to-buffer buffer)
|
||||
(format "%s-%s" year month)
|
||||
(if (eq month 12)
|
||||
(progn
|
||||
(progn
|
||||
(setq year (+ 1 year))
|
||||
(setq month 1))
|
||||
(setq month (+ 1 month))))
|
||||
|
@ -367,4 +367,3 @@ many TODO pending"
|
|||
(insert "</body></html>")))
|
||||
|
||||
(provide 'org-effectiveness)
|
||||
|
||||
|
|
|
@ -176,8 +176,8 @@ looks like tree2, where the level is 2."
|
|||
"Return a list where the car is the min level, and the cdr the max."
|
||||
(let ((max 0) min level)
|
||||
(dolist (info ls)
|
||||
(when (cdr (assoc 'date info))
|
||||
(setq level (cdr (assoc 'level info)))
|
||||
(when (cdr (assq 'date info))
|
||||
(setq level (cdr (assq 'level info)))
|
||||
(when (or (not min) (< level min)) (setq min level))
|
||||
(when (> level max) (setq max level))))
|
||||
(cons (or min 0) max)))
|
||||
|
@ -186,11 +186,11 @@ looks like tree2, where the level is 2."
|
|||
"Reorganize the given list by dates."
|
||||
(let ((min-max (org-invoice-level-min-max ls)) new)
|
||||
(dolist (info ls)
|
||||
(let* ((date (cdr (assoc 'date info)))
|
||||
(work (cdr (assoc 'work info)))
|
||||
(price (cdr (assoc 'price info)))
|
||||
(long-date (cdr (assoc 'long-date info)))
|
||||
(level (cdr (assoc 'level info)))
|
||||
(let* ((date (cdr (assq 'date info)))
|
||||
(work (cdr (assq 'work info)))
|
||||
(price (cdr (assq 'price info)))
|
||||
(long-date (cdr (assq 'long-date info)))
|
||||
(level (cdr (assq 'level info)))
|
||||
(bucket (cdr (assoc date new))))
|
||||
(if (and (/= (car min-max) (cdr min-max))
|
||||
(= (car min-max) level)
|
||||
|
@ -208,19 +208,19 @@ looks like tree2, where the level is 2."
|
|||
(push (cons date bucket) new)
|
||||
(setq bucket (cdr (assoc date new))))
|
||||
(when (and date bucket)
|
||||
(setcdr (assoc 'total-work (car bucket))
|
||||
(+ work (cdr (assoc 'total-work (car bucket)))))
|
||||
(setcdr (assoc 'price (car bucket))
|
||||
(+ price (cdr (assoc 'price (car bucket)))))
|
||||
(setcdr (assq 'total-work (car bucket))
|
||||
(+ work (cdr (assq 'total-work (car bucket)))))
|
||||
(setcdr (assq 'price (car bucket))
|
||||
(+ price (cdr (assq 'price (car bucket)))))
|
||||
(nconc bucket (list info))))))
|
||||
(nreverse new)))
|
||||
|
||||
(defun org-invoice-info-to-table (info)
|
||||
"Create a single org table row from the given info alist."
|
||||
(let ((title (cdr (assoc 'title info)))
|
||||
(total (cdr (assoc 'total-work info)))
|
||||
(work (cdr (assoc 'work info)))
|
||||
(price (cdr (assoc 'price info)))
|
||||
(let ((title (cdr (assq 'title info)))
|
||||
(total (cdr (assq 'total-work info)))
|
||||
(work (cdr (assq 'work info)))
|
||||
(price (cdr (assq 'price info)))
|
||||
(with-price (plist-get org-invoice-table-params :price)))
|
||||
(unless total
|
||||
(setq
|
||||
|
|
Loading…
Reference in New Issue