X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/18ab493650d648ab8dca651ea2698861f926e895..d9088290efb49a352c3c23da25a734ed3e269923:/lisp/org/org-habit.el diff --git a/lisp/org/org-habit.el b/lisp/org/org-habit.el index ebdfa0c773..8848ac48b7 100644 --- a/lisp/org/org-habit.el +++ b/lisp/org/org-habit.el @@ -1,11 +1,10 @@ ;;; org-habit.el --- The habit tracking code for Org-mode -;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 2009-2016 Free Software Foundation, Inc. ;; Author: John Wiegley ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org -;; Version: 7.7 ;; ;; This file is part of GNU Emacs. ;; @@ -68,6 +67,30 @@ 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 + :version "24.1" + :type 'character) + +(defcustom org-habit-completed-glyph ?* + "Glyph character used to show completed days on which a task was done." + :group 'org-habit + :version "24.1" + :type 'character) + +(defcustom org-habit-show-done-always-green nil + "Non-nil means DONE days will always be green in the consistency graph. +It will be green even if it was done after the deadline." + :group 'org-habit + :type 'boolean) + (defface org-habit-clear-face '((((background light)) (:background "#8270f9")) (((background dark)) (:background "blue"))) @@ -157,7 +180,7 @@ This list represents a \"habit\" for the rest of this module." (error "Habit %s has no scheduled date" habit-entry)) (unless scheduled-repeat (error - "Habit '%s' has no scheduled repeat period or has an incorrect one" + "Habit `%s' has no scheduled repeat period or has an incorrect one" habit-entry)) (setq sr-days (org-habit-duration-to-days scheduled-repeat)) (unless (> sr-days 0) @@ -177,7 +200,9 @@ This list represents a \"habit\" for the rest of this module." (count 0)) (unless reversed (goto-char end)) (while (and (< count maxdays) - (funcall search "- State \"DONE\".*\\[\\([^]]+\\)\\]" limit t)) + (funcall search (format "- State \"%s\".*\\[\\([^]]+\\)\\]" + (regexp-opt org-done-keywords)) + limit t)) (push (time-to-days (org-time-string-to-time (match-string-no-properties 1))) closed-dates) @@ -255,8 +280,9 @@ Habits are assigned colors on the following basis: (if donep '(org-habit-ready-face . org-habit-ready-future-face) '(org-habit-alert-face . org-habit-alert-future-face))) - (t - '(org-habit-overdue-face . org-habit-overdue-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))))) (defun org-habit-build-graph (habit starting current ending) "Build a graph for the given HABIT, from STARTING to ENDING. @@ -297,7 +323,7 @@ current time." (days-to-time (- start (time-to-days starting)))))) - (aset graph index ?*) + (aset graph index org-habit-completed-glyph) (setq markedp t) (put-text-property index (1+ index) 'help-echo @@ -307,7 +333,7 @@ current time." (setq last-done-date (car done-dates) done-dates (cdr done-dates)))) (if todayp - (aset graph index ?!))) + (aset graph index org-habit-today-glyph))) (setq face (if (or in-the-past-p todayp) (car faces) (cdr faces))) @@ -335,13 +361,12 @@ current time." (delete-char (min (+ 1 org-habit-preceding-days org-habit-following-days) (- (line-end-position) (point)))) - (insert (org-habit-build-graph - habit - (time-subtract moment - (days-to-time org-habit-preceding-days)) - moment - (time-add moment - (days-to-time org-habit-following-days)))))) + (insert-before-markers + (org-habit-build-graph + habit + (time-subtract moment (days-to-time org-habit-preceding-days)) + moment + (time-add moment (days-to-time org-habit-following-days)))))) (forward-line))))) (defun org-habit-toggle-habits () @@ -358,6 +383,4 @@ current time." (provide 'org-habit) -;; arch-tag: 64e070d9-bd09-4917-bd44-44465f5ed348 - ;;; org-habit.el ends here