I'm trying to define queries for sparse trees that combine different conditions, for instance.

  • (DEADLINE or SCHEDULED closer to one year), and
  • (TODO keyword is NEXT or TODO or WAITING, or tagged as unplanned) and
  • ...

This is in a normal buffer, not the agenda buffer. I do not need this in the agenda buffer.

This would be very easy to do if parenthesis were allowed in sparse tree queries, but they are not implemented.

I need to do this with many conditions. If I distribute conditions over, the number of combinations I'd need to write grows far too quickly and it becomes impractical.

A "solution" would be to apply an org-match-sparse-tree on the result of another, somehow nesting conditions.

Is this possible? If not, are there alternatives to solve the problem I'm trying to solve?

How much effort would it take to implement parenthesis in search, or cummulative filtering and searching in sparse trees?

EDIT: bounty, hence changing the "goal" of the question.

  • The problem with org-make-tags-matcher is that it is not a proper parser-interpreter pair. For an instance it splits MATCH at | and afterwards repairs such splits if the | is actually escaped by \ . Something like that should not be necessary with a proper parser. If the parser and the code generator/interpreter would be built with wisent then the addition of parenthesis to the syntax would be no problem. That would mean a re-write of org-make-tags-matcher. – Tobias May 10 '18 at 22:32
  • Thanks for the info. Roughly, how much work would that take? – Ivan Perez May 12 '18 at 1:36
  • One (hacky) approach would be (1st) to parse the MATCH (extended with parentheses) into an abstract syntax tree AST with the help of a wisent-generated parser (should be relatively simple), (2nd) to apply the distribution law to the AST, and (3rd) to print the transformed AST out into a string that is used as argument to org-make-tags-matcher. The string does not have any parenthesis anymore and is therefore suitable for org-make-tags-matcher. – Tobias May 12 '18 at 23:21
  • All those tasks I described in my previous comment should be relatively simple experience with wisent and elisp assumed. – Tobias May 13 '18 at 4:21
  • Note that my experience with Wisent is limited but I think that wisent-calc.wy would be a good starting point for that adventure. – Tobias May 13 '18 at 4:28

Your Answer

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

Browse other questions tagged or ask your own question.