summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-20 14:49:42 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-20 17:19:00 -0400
commit2f4aeae8f617f058b9a016406273c485aa682ed2 (patch)
tree7c35547300888f83a0acda5196df412661f018ba
parentf82986173e32432b869f5e9118a9525cf1693985 (diff)
downloadorg-mode-2f4aeae8f617f058b9a016406273c485aa682ed2.tar.gz
Start displaying colors from the first scheduled date
-rwxr-xr-xlisp/ChangeLog4
-rw-r--r--lisp/org-habit.el17
2 files changed, 15 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c9cd29b..99ec6d0 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
2009-10-20 John Wiegley <jwiegley@gmail.com>
+ * org-habit.el (org-habit-build-graph): Start displaying colors
+ from the first scheduled date, if that date is earlier than the
+ first completion date.
+
* org-habit.el: Changed all "color" variables to faces, and made
them appropriate for light and dark backgrounds.
diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index 42180ef..431b133 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -238,6 +238,7 @@ Habits are assigned colors on the following basis:
(defun org-habit-build-graph (habit &optional starting current ending)
"Build a color graph for the given HABIT, from STARTING to ENDING."
(let ((done-dates (sort (org-habit-done-dates habit) 'time-less-p))
+ (scheduled (org-habit-scheduled habit))
(s-repeat (org-habit-scheduled-repeat habit))
(day starting)
(current-days (time-to-days current))
@@ -255,12 +256,16 @@ Habits are assigned colors on the following basis:
(todayp (= now-days current-days))
(donep (and done-dates
(= now-days (time-to-days (car done-dates)))))
- (faces (if (and in-the-past-p (not last-done-date))
+ (faces (if (and in-the-past-p
+ (not last-done-date)
+ (not (time-less-p scheduled current)))
'(org-habit-clear-face . org-habit-clear-future-face)
(org-habit-get-faces
habit day (and in-the-past-p
- (time-add last-done-date
- (days-to-time s-repeat)))
+ (if last-done-date
+ (time-add last-done-date
+ (days-to-time s-repeat))
+ scheduled))
donep)))
markedp face)
(if donep
@@ -272,9 +277,9 @@ Habits are assigned colors on the following basis:
(if todayp
(aset graph index ?!)))
(setq face (if (or in-the-past-p
- todayp)
- (car faces)
- (cdr faces)))
+ todayp)
+ (car faces)
+ (cdr faces)))
(if (and in-the-past-p
(not (eq face 'org-habit-overdue-face))
(not markedp))