4

I have tried to code my org-agenda-custom-commands to show only todo's which are either priority A or priority B. However, I am only able to do this indirectly, by filtering out todo's that are NOT priority C. Why doesn't the or-function | in my code below work the way I want? (alternative 2 and 3).

(setq org-agenda-custom-commands '(
  ("d" "Daily "(
    (tags-todo "+TODO=\"TODO\" -PRIORITY=\"C\" "  ( ; works
    (org-agenda-sorting-strategy '(priority-down))
    ))
  (tags-todo "+TODO=\"TODO\" +PRIORITY={\"B\"|\"A\"} "  ( ; works NOT
    (org-agenda-sorting-strategy '(priority-down))
    ))
  (tags-todo "+TODO=\"TODo\"  {+PRIORITY=\"B\"}|{+PRIORITY=\"A\"} "  ( ; works NOT
    (org-agenda-sorting-strategy '(priority-down))
    ))
  ))
))

Alternative 2 and 3 using the or-function | results in showing A, B and C, not only priority A and B, as was my intention.

What is wrong with my usage of the "|" function? How can I use | to show both priority A and B?

7

The contents of {} in an agenda command are regular expressions. So something like PRIORITY={\"B\"|\"A\"} will only match if PRIORITY is "A" or "B", including the quotes. You also need more escaping in you regex (\\| instead of |). A regex won't work if you don't pay the slash tax.

The correct search is +PRIORITY={A\\|B}. You can also simplify things a little by using the / syntax. Anything following a / is assumed to be a TODO keyword. So +PRIORITY={A\\|B}/TODO will find all entries with keyword TODO and priority A or B.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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