2

This is probably pretty simple, but for some reason I can't seem to get this to work.

I have a block agenda that should list all the headlines with NEXT as well as DONE and DROPPED todo states. I want one block to show Done and Dropped, and another one to show NEXT.

I currently have this in org-agenda-custom-commands:

("n" "Next"
  ((tags-todo "/+DONE|+DROPPED" ((org-agenda-overriding-header "Done/Dropped:")))
  (todo "NEXT" ((org-agenda-overriding-header "Next:")))))

The NEXT block works, but the "Done/Dropped" block is blank. When I use this match syntax in the Agenda's actual match/search (C-c a m), it works, but for some reason it doesn't work in custom commands.

Perhaps some of the characters need to be escaped? I've tried various combinations of escaping with \, but no success so far.

3
  • Should it be todo instead of tags-todo?
    – Dan
    Sep 23, 2016 at 20:30
  • Hm... I thought that there should be a way to accomplish this with tags-todo as well, but I just tried it with todo "DONE|DROPPED" and it seems to work. If you post an answer, I'll accept it.
    – wiuah
    Sep 23, 2016 at 21:29
  • Go ahead and post that as an answer and then accept it once the system lets you. I'm limited to my phone for a few days and won't remember to post anyway.
    – Dan
    Sep 23, 2016 at 21:58

2 Answers 2

5

You can to this with a plain tags query just by dropping the + from the search:

("n" "Next"
  ((tags "/DONE|DROPPED" ((org-agenda-overriding-header "Done/Dropped:")))
  (todo "NEXT" ((org-agenda-overriding-header "Next:")))))

The + operator on a keyword or tag makes entries require the tag to match. So +DONE|+DROPPED requires both DONE and DROPPED, which is impossible since an entries can have only one todo keyword. + is essential the AND operator.

An alternate way to do the same thing is to use the regular expression syntax: TODO={DONE\\|DROPPED}. This is the only way to avoid a set of keywords since the search syntax doesn't allow grouping.

4
  • The issue I've had with using tags-todo is that it seems to only include active TODO keywords. Idk what's causing it since that should only happen with "/!DONE|DROPPED". Did you not have that issue?
    – kfoley
    Mar 5, 2017 at 18:20
  • @cfmg It didn't occur to me that tags-todo wouldn't match inactive states. I'm editing the answer to use a tags query instead, which shouldn't have that issue.
    – erikstokes
    Mar 5, 2017 at 23:54
  • Did you find it documented somewhere that this is the expexted behavior? I tried to find something about it but was unable
    – kfoley
    Mar 6, 2017 at 1:19
  • 1
    I don't see it documented, but org-agenda calls org-tags-view , which calls org-search-view which buried in its source adds org-not-done-regexp to the search. So this is the designed behavior. The docstrings all seem to feel that "TODO entry" means "not-done TODO entry"
    – erikstokes
    Mar 6, 2017 at 4:28
3

You can use the following (per the comments above and my own testing) to do this:

("n" "Next"
  ((todo "DONE|DROPPED" ((org-agenda-overriding-header "Done/Dropped:")))
  (todo "NEXT" ((org-agenda-overriding-header "Next:")))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.