From f184c49d0b2017ace42c18dad1eafe0aaa624d91 Mon Sep 17 00:00:00 2001 From: Walheimat Date: Thu, 3 Oct 2024 12:08:31 +0200 Subject: [PATCH] Add: {not-}done option for :todo selector Users can now set `:todo {not-}done` to match to-do keywords that are part of `org-{not-}done-keywords` in that agenda item. This means that when using "TODO | ACHIEVED" in one item but "TODO | DONE" in another, `:todo done` will match both "ACHIEVED" and "DONE". --- README.org | 2 +- org-super-agenda.el | 29 +++++++++++++++++++---------- org-super-agenda.info | 7 +++++-- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/README.org b/README.org index da5310f..686918b 100644 --- a/README.org +++ b/README.org @@ -210,7 +210,7 @@ These selectors take one argument alone, or multiple arguments in a list. + =:scheduled= :: Group items that are scheduled. Argument can be ~t~ (to match items scheduled for any date), ~nil~ (to match items that are not schedule), ~past~ (to match items scheduled for the past), ~today~ (to match items scheduled for today), or ~future~ (to match items scheduled for the future). Argument may also be given like ~before DATE~ or ~after DATE~ where DATE is a date string that ~org-time-string-to-absolute~ can process. + =:tag= :: Group items that match any of the given tags. Argument may be a string or list of strings. + =:time-grid= :: Group items that appear on the time grid. -+ =:todo= :: Group items that match any of the given TODO keywords. Argument may be a string or list of strings, or ~t~ to match any keyword, or ~nil~ to match only non-todo items. ++ =:todo= :: Group items that match any of the given TODO keywords. Argument may be a string or list of strings, or ~t~ to match any keyword or ~nil~ to match only non-todo items. You can also use ~done~ (or ~not-done~) to match keywords that are (not) "done" according to the local value of ~org-done-keywords~ (or ~org-not-done-keywords~). ** Tips diff --git a/org-super-agenda.el b/org-super-agenda.el index 01223d3..e5509ce 100644 --- a/org-super-agenda.el +++ b/org-super-agenda.el @@ -766,17 +766,26 @@ keyword, or `nil' to match only non-todo items." "Any TODO keyword") ('nil ;; Test for not having a to-do keyword "Non-todo items") + ('done ;; Test for keyword matching done keywords + "Done items") + ('not-done ;; Test keyword matching not-done keywords + "Not-done items") (_ ;; Oops - (user-error "Argument to `:todo' must be a string, list of strings, t, or nil"))) - :test (pcase (car args) - ((pred stringp) ;; To-do keyword given - (cl-member (org-find-text-property-in-string 'todo-state item) args :test 'string=)) - ('t ;; Test for any to-do keyword - (org-find-text-property-in-string 'todo-state item)) - ('nil ;; Test for not having a to-do keyword - (not (org-find-text-property-in-string 'todo-state item))) - (_ ;; Oops - (user-error "Argument to `:todo' must be a string, list of strings, t, or nil")))) + (user-error "Argument to `:todo' must be a string, list of strings, t, done, not-done or nil"))) + :test (org-super-agenda--when-with-marker-buffer (org-super-agenda--get-marker item) + (pcase (car args) + ((pred stringp) ;; To-do keyword given + (cl-member (org-find-text-property-in-string 'todo-state item) args :test 'string=)) + ('t ;; Test for any to-do keyword + (org-find-text-property-in-string 'todo-state item)) + ('done ;; Test for done keyword + (cl-member (org-find-text-property-in-string 'todo-state item) org-done-keywords :test 'string=)) + ('not-done ;; Test for not-done keyword + (cl-member (org-find-text-property-in-string 'todo-state item) org-not-done-keywords :test 'string=)) + ('nil ;; Test for not having a to-do keyword + (not (org-find-text-property-in-string 'todo-state item))) + (_ ;; Oops + (user-error "Argument to `:todo' must be a string, list of strings, t, done, not-done or nil"))))) (org-super-agenda--defgroup ancestor-with-todo "their earliest ancestor having the to-do keyword" diff --git a/org-super-agenda.info b/org-super-agenda.info index 55128ff..81d8d25 100644 --- a/org-super-agenda.info +++ b/org-super-agenda.info @@ -482,8 +482,11 @@ list. Group items that appear on the time grid. ‘:todo’ Group items that match any of the given TODO keywords. Argument - may be a string or list of strings, or ‘t’ to match any keyword, or - ‘nil’ to match only non-todo items. + may be a string or list of strings, or ‘t’ to match any keyword or + ‘nil’ to match only non-todo items. You can also use ‘done’ (or + ‘not-done’) to match keywords that are (not) "done" according to + the local value of ‘org-done-keywords’ (or + ‘org-not-done-keywords’).  File: README.info, Node: Tips, Prev: Group selectors, Up: Usage