Function: org-habit-get-faces

org-habit-get-faces is a byte-compiled function defined in org-habit.el.gz.

Signature

(org-habit-get-faces HABIT &optional NOW-DAYS SCHEDULED-DAYS DONEP)

Documentation

Return faces for HABIT relative to NOW-DAYS and SCHEDULED-DAYS.

NOW-DAYS defaults to the current time's days-past-the-epoch if nil. SCHEDULED-DAYS defaults to the habit's actual scheduled days if nil.

Habits are assigned colors on the following basis:
  Blue Task is before the scheduled date.
  Green Task is on or after scheduled date, but before the
end of the schedule's repeat period.
  Yellow If the task has a deadline, then it is after schedule's
repeat period, but before the deadline.
  Orange The task has reached the deadline day, or if there is
no deadline, the end of the schedule's repeat period.
  Red The task has gone beyond the deadline day or the
schedule's repeat period.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-habit.el.gz
(defun org-habit-get-faces (habit &optional now-days scheduled-days donep)
  "Return faces for HABIT relative to NOW-DAYS and SCHEDULED-DAYS.
NOW-DAYS defaults to the current time's days-past-the-epoch if nil.
SCHEDULED-DAYS defaults to the habit's actual scheduled days if nil.

Habits are assigned colors on the following basis:
  Blue      Task is before the scheduled date.
  Green     Task is on or after scheduled date, but before the
	    end of the schedule's repeat period.
  Yellow    If the task has a deadline, then it is after schedule's
	    repeat period, but before the deadline.
  Orange    The task has reached the deadline day, or if there is
	    no deadline, the end of the schedule's repeat period.
  Red       The task has gone beyond the deadline day or the
	    schedule's repeat period."
  (let* ((scheduled (or scheduled-days (org-habit-scheduled habit)))
	 (s-repeat (org-habit-scheduled-repeat habit))
	 (d-repeat (org-habit-deadline-repeat habit))
	 (deadline (if scheduled-days
		       (+ scheduled-days (- d-repeat s-repeat))
		     (org-habit-deadline habit)))
	 (m-days (or now-days (time-to-days nil))))
    (cond
     ((< m-days scheduled)
      '(org-habit-clear-face . org-habit-clear-future-face))
     ((< m-days deadline)
      '(org-habit-ready-face . org-habit-ready-future-face))
     ((= m-days deadline)
      (if donep
	  '(org-habit-ready-face . org-habit-ready-future-face)
	'(org-habit-alert-face . org-habit-alert-future-face)))
     ((and org-habit-show-done-always-green donep)
      '(org-habit-ready-face . org-habit-ready-future-face))
     (t '(org-habit-overdue-face . org-habit-overdue-future-face)))))