summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-02-22 17:12:56 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-02-22 17:12:56 +0100
commit6652baa39db26df8a8ac5dbbe40f3de91bf1a6b1 (patch)
tree5f8e1010156c7e7e8a8341e3d1c215a5867c6020
parent4eb4f47141a1ac582330b903bd779dccbcb1c154 (diff)
downloadorg-mode-6652baa39db26df8a8ac5dbbe40f3de91bf1a6b1.tar.gz
org-habit: Small refactoring
* lisp/org-habit.el (org-habit-parse-todo): Small refactoring.
-rw-r--r--lisp/org-habit.el39
1 files changed, 20 insertions, 19 deletions
diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index 0b6a1a9..abbbe62 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -197,26 +197,27 @@ This list represents a \"habit\" for the rest of this module."
(reversed org-log-states-order-reversed)
(search (if reversed 're-search-forward 're-search-backward))
(limit (if reversed end (point)))
- (count 0))
+ (count 0)
+ (re (format
+ "^[ \t]*-[ \t]+\\(?:%s\\)"
+ (mapconcat
+ (lambda (type)
+ (let ((value (cdr (assq type org-log-note-headings))))
+ (when value
+ (org-replace-escapes
+ (regexp-quote value)
+ `(("%d" . ,org-ts-regexp-inactive)
+ ("%D" . ,org-ts-regexp)
+ ("%s" . "\"\\S-+\"")
+ ("%S" . "\"\\S-+\"")
+ ("%t" . ,org-ts-regexp-inactive)
+ ("%T" . ,org-ts-regexp)
+ ("%u" . ".*?")
+ ("%U" . ".*?"))))))
+ '(state done)
+ "\\|"))))
(unless reversed (goto-char end))
- (while (and (< count maxdays)
- (funcall search
- (concat
- (format "- State \"%s\".*\\[\\([^]]+\\)\\]"
- (regexp-opt org-done-keywords))
- "\\|"
- (org-replace-escapes
- (regexp-quote
- (cdr (assq 'done org-log-note-headings)))
- `(("%d" . ,org-ts-regexp-inactive)
- ("%D" . ,org-ts-regexp)
- ("%s" . "\"\\S-+\"")
- ("%S" . "\"\\S-+\"")
- ("%t" . ,org-ts-regexp-inactive)
- ("%T" . ,org-ts-regexp)
- ("%u" . ".*?")
- ("%U" . ".*?"))))
- limit t))
+ (while (and (< count maxdays) (funcall search re limit t))
(push (time-to-days
(org-time-string-to-time
(or (org-match-string-no-properties 1)