From 515b4960c40e6ed6dd5ab404c2bc133fa1225ec7 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 13 Aug 2019 13:57:34 -0500 Subject: [PATCH] Change: (todo) Don't match done tasks --- README.org | 3 ++- org-ql.el | 2 +- tests/test-org-ql.el | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index e7cd729..ad6d25f 100644 --- a/README.org +++ b/README.org @@ -150,7 +150,7 @@ Arguments are listed next to predicate names, where applicable. + ~regexp (regexp)~ :: Return non-nil if current entry matches ~REGEXP~ (a regexp string). + ~scheduled (&optional comparator target-date)~ :: Return non-nil if entry's scheduled date compares with ~TARGET-DATE~ using ~COMPARATOR~. ~TARGET-DATE~ should be a string parseable by ~date-to-day~. ~COMPARATOR~ should be a function (like ~<=~). + ~tags (&optional tags)~ :: Return non-nil if current heading has one or more of ~TAGS~ (a list of strings). -+ ~todo (&optional keywords)~ :: Return non-nil if current heading is a ~TODO~ item. With ~KEYWORDS~, return non-nil if its keyword is one of ~KEYWORDS~ (a list of strings). ++ ~todo (&optional keywords)~ :: Return non-nil if current heading is a ~TODO~ item. With ~KEYWORDS~, return non-nil if its keyword is one of ~KEYWORDS~ (a list of strings). When called without arguments, only matches non-done tasks (i.e. does not match keywords in ~org-done-keywords~). + ~ts (&key from to on type)~ :: Return non-nil if current entry has a timestamp in given period. If no arguments are specified, return non-nil if entry has any timestamp. If ~FROM~, return non-nil if entry has a timestamp on or after ~FROM~. If ~TO~, return non-nil if entry has a timestamp on or before ~TO~. If ~ON~, return non-nil if entry has a timestamp on date ~ON~. ~FROM~, ~TO~, and ~ON~ should be strings parseable by ~parse-time-string~ but may omit the time value. ~TYPE~ may be ~active~ to match active timestamps, ~inactive~ to match inactive ones, or ~both~ / nil to match both types. + ~ts-active~ :: Like ~ts~ called with ~:type active~. + ~ts-a~ :: Like ~ts~ called with ~:type active~. @@ -370,6 +370,7 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience *Changed* + Function ~org-ql-query~ renamed to ~org-ql-select~. ~org-ql-query~ now refers to a new function. + Macro ~org-ql~ no longer accepts a ~:markers~ argument. Instead, use argument ~:action element-with-markers~. See function ~org-ql-select~, which ~org-ql~ calls. ++ Selector ~(todo)~ no longer matches "done" keywords when used without arguments (i.e. the ones in variable ~org-done-keywords~). *Fixed* + Handle date ranges in date-based selectors. (Thanks to [[https://github.com/codygman][Cody Goodman]], [[https://github.com/swflint][Samuel W. Flint]], and [[https://github.com/vikasrawal][Vikas Rawal]].) diff --git a/org-ql.el b/org-ql.el index 49dfc8e..591031e 100644 --- a/org-ql.el +++ b/org-ql.el @@ -600,7 +600,7 @@ ignored." With KEYWORDS, return non-nil if its keyword is one of KEYWORDS (a list of strings)." (when-let ((state (org-get-todo-state))) (cl-typecase keywords - (null t) + (null (not (member state org-done-keywords))) (list (member state keywords)) (symbol (member state (symbol-value keywords))) (otherwise (user-error "Invalid todo keywords: %s" keywords))))) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 13f7d97..a97d875 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -382,10 +382,9 @@ RESULTS should be a list of strings as returned by (describe "(todo)" (org-ql-it "without arguments" - ;; FIXME: This returns an item that is done, which is incorrect. (org-ql-expect ((todo) :sort todo) - '("Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Practice leaping tall buildings in a single bound" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp" "Write a symphony"))) + '("Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Practice leaping tall buildings in a single bound" "Renew membership in supervillain club" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp" "Write a symphony"))) (org-ql-it "with 1 argument" ;; FIXME: Figure out why this takes >10x longer than the other (todo)