I have created a grouptag for my team as follows-
(setq org-tag-alist '((:startgrouptag)
("my_team")
(:grouptags)
("A")
("B")
(:endgrouptag))
Now, I have assigned some TODO tasks to my team members. Some tasks belong to A, some to B, and some to both A and B. I assign a tag related to A and/or B for each task. There are some other tags that are related to me. Now, I want to filter out the tasks of my_team
from my agenda TODO list. How can I do so?
I followed this link to filter out tasks based on tags of A or B. However, this does not filter based on groupgtags (my_team
for my case). How can I achieve this?
Here's two simple agenda custom commands that do what I thought you wanted (the j
command) and what you really wanted (the k
command):
("j" "my team"
((agenda "")
(tags-todo "my_team"))
)
;;
("k" "not my team"
((agenda "")
(tags-todo "-my_team"))
)
They're a simplification of the one from the linked question (which I don't think is as complicated as the question and the answers make it: instead of using skip functions and regexps, use tag inheritance - which is on by default, at least today - it might not have been a dozen years ago though).
Here's a test file:
#+TAGS: [ my_team : A B ]
* Tasks
** TODO one :A:
** TODO two :B:
** TODO three :A:B:
** TODO four :my_team:
** TODO five
** TODO six :me:
* Code
#+begin_src elisp
(add-to-list 'org-agenda-custom-commands
'("j" "my team"
((agenda "" )
(tags-todo "my_team"))
))
(add-to-list 'org-agenda-custom-commands
'("k" "not my team"
((agenda "")
(tags-todo "-my_team"))
))
#+end_src
Run the source block with C-c C-c
to add the commands to the agenda dispatcher, add the file to the agenda list with C-c [
, run M-x org-agenda
and select first the j
command. Here's the output for that:
Week-agenda (W51):
Monday 16 December 2024 W51
Tuesday 17 December 2024
Wednesday 18 December 2024
Thursday 19 December 2024
Friday 20 December 2024
Saturday 21 December 2024
Sunday 22 December 2024
─────────────────────────────────────────────────────────────────────────Headlines with TAGS match: my_team
foo8: TODO one :A:
foo8: TODO two :B:
foo8: TODO three :A:B:
foo8: TODO four :my_team:
That shows you all the TODO items, tagged with either or both members of the my_team
tag group, or tagged with the tag group itself.
Now run M-x org-agenda
again and select the k
command. Here's the output for that:
Week-agenda (W52):
Monday 23 December 2024 W52
Tuesday 24 December 2024
Wednesday 25 December 2024
Thursday 26 December 2024
Friday 27 December 2024
Saturday 28 December 2024
Sunday 29 December 2024
─────────────────────────────────────────────────────────────────
Headlines with TAGS match: -my_team
foo8: TODO five
foo8: TODO six :me:
That gives all the TODO items not tagged with members of the my_team
tag group. The only items on it are untagged items or items tagged with the tag me
.
This is one instance of a general search mechanism which you can also invoke interactively from the agenda dispatcher using the m
command. The search syntax is described in Matching tags and properties in the Org mode manual. There are also several more complicated examples in that section. One warning: you will have to reread the section several times and try several examples before you can get your head around it all.