From 6652baa39db26df8a8ac5dbbe40f3de91bf1a6b1 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 22 Feb 2015 17:12:56 +0100 Subject: [PATCH] org-habit: Small refactoring * lisp/org-habit.el (org-habit-parse-todo): Small refactoring. --- lisp/org-habit.el | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lisp/org-habit.el b/lisp/org-habit.el index 0b6a1a90f..abbbe62c9 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) -- 2.11.4.GIT