summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Mikhanosha <max@openchat.com>2012-05-28 14:55:32 -0400
committerMax Mikhanosha <max@openchat.com>2012-05-28 14:56:23 -0400
commite67734fe8e10d24ee3dcfcc33299f8b7cbb60e08 (patch)
tree2cf7281cd54b25d16f54da8444b57d9b8fd2f041
parent4aa8693c2c07a21833fa86156a753646f4fb2c96 (diff)
downloadorg-mode-e67734fe8e10d24ee3dcfcc33299f8b7cbb60e08.tar.gz
Add ability to show all (even unscheduled) habits on today agenda, by
setting `org-habit-show-all-today' to t. * lisp/org-agenda.el (defvar org-habit-show-all-today): new variable (org-agenda-get-scheduled): show all habits if user wants it * lisp/org-habit.el (defcustom org-habit-show-all-today): new variable
-rw-r--r--lisp/org-agenda.el19
-rw-r--r--lisp/org-habit.el6
2 files changed, 21 insertions, 4 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index cfd3e25..3b0b6d8 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -86,6 +86,7 @@
(defvar org-mobile-force-id-on-agenda-items) ; defined in org-mobile.el
(defvar org-habit-show-habits)
(defvar org-habit-show-habits-only-for-today)
+(defvar org-habit-show-all-today)
;; Defined somewhere in this file, but used before definition.
(defvar org-agenda-buffer-name)
@@ -5538,7 +5539,8 @@ FRACTION is what fraction of the head-warning time has passed."
(cons (marker-position mm) a)))
deadline-results))
d2 diff pos pos1 category org-category-pos tags donep
- ee txt head pastschedp todo-state face timestr s habitp show-all)
+ ee txt head pastschedp todo-state face timestr s habitp show-all
+ did-habit-check-p)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
(catch :skip
@@ -5555,12 +5557,20 @@ FRACTION is what fraction of the head-warning time has passed."
(current-buffer) pos)
diff (- d2 d1))
(setq pastschedp (and todayp (< diff 0)))
+ (setq did-habit-check-p nil)
;; When to show a scheduled item in the calendar:
;; If it is on or past the date.
(when (or (and (< diff 0)
(< (abs diff) org-scheduled-past-days)
(and todayp (not org-agenda-only-exact-dates)))
- (= diff 0))
+ (= diff 0)
+ ;; org-is-habit-p uses org-entry-get, which is expansive
+ ;; so we go extra mile to only call it once
+ (and todayp
+ org-habit-show-all-today
+ (setq did-habit-check-p t)
+ (setq habitp (and (functionp 'org-is-habit-p)
+ (org-is-habit-p)))))
(save-excursion
(setq donep (member todo-state org-done-keywords))
(if (and donep
@@ -5569,8 +5579,9 @@ FRACTION is what fraction of the head-warning time has passed."
(and (functionp 'org-is-habit-p)
(org-is-habit-p))))
(setq txt nil)
- (setq habitp (and (functionp 'org-is-habit-p)
- (org-is-habit-p)))
+ (setq habitp (if did-habit-check-p habitp
+ (and (functionp 'org-is-habit-p)
+ (org-is-habit-p))))
(setq category (org-get-category)
org-category-pos (get-text-property (point) 'org-category-position))
(if (not (re-search-backward "^\\*+[ \t]+" nil t))
diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index 6b47766..06b42e9 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -67,6 +67,12 @@ relative to the current effective date."
:group 'org-habit
:type 'boolean)
+(defcustom org-habit-show-all-today nil
+ "If non-nil, will show the consistency graph of all habits on
+today's agenda, even if they are not scheduled."
+ :group 'org-habit
+ :type 'boolean)
+
(defcustom org-habit-today-glyph ?!
"Glyph character used to identify today."
:group 'org-habit