Skip to content

Commit

Permalink
Add: {not-}done option for :todo selector
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
Walheimat committed Oct 3, 2024
1 parent c07e354 commit f184c49
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 19 additions & 10 deletions org-super-agenda.el
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions org-super-agenda.info
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f184c49

Please sign in to comment.