#+TITLE: New Tag Query Parser: A Few Illuminating Examples This post is structured as an org file with the example commands listed within. Copy this to a buffer and try the commands below on that buffer. * Preliminaries Point 207 The Point # labels on the headings give the point values for the beginning of the heading. To make this accurate, we need to standardize tag placemnet. Using M-: or equivalent means, execute the following in this buffer: #+begin_src emacs-lisp (set (make-local-variable 'org-tags-column) -80) (set (make-local-variable 'org-todo-keywords) '((sequence "TODO" "WAIT" "DONE"))) #+end_src If necessary, do C-u C-c on a headline to realign the tags. * Parenthesized Expressions Point 714 :feature: Fully parenthesized expressions are allowed in the tag query strings. A - selector before the parenthesized expression acts as a logical not. These expressions can include an old-style /!? todo-query string as well, which extends to the closing paren. ** TODO Paren Examples Point 1057 :example:paren: + (org-map-entries 'point "(example&HEADING={^Paren}/TODO)") + (org-map-entries 'point "HEADING={Paren} & -(extra | LEVEL = 1)") + (org-map-entries 'point "(feature | LEVEL == 2)({^p}/WAIT|TODO)") The first two should give 1057, the third (1057 1492). * Another Point 1411 :extra: ** WAIT This is not a feature example Point 1492 :pretend: ** We can manipulate and combine whole expressions Point 1573 + (org-map-entries 'point "-(feature&LEVEL=2)") + (org-map-entries 'point "-(feature|LEVEL==2)|{^$}") Note that inheritance can affects the tag matches; it might be nice to be able to distinguish this in searches. Note also that the original matcher fails silently here. * Braces and Spaces AAA Point 1921 :feature: ** DONE Just a marker AAAAAA Point 2002 ** TODO Simple Examples AAAA Point 2042 :example:syntax: + (org-map-entries 'point "example & TODO <> \"DONE\") + (org-map-entries 'point "example/!") + (org-map-entries 'point "example | HEADING = { A\\{{3,4\\}}[^A]}") + Allows = or == for equality operator. ** [#A] Ok Point 2338 ** [#B] This is fast Point 2360 + (org-map-entries 'point "PRIORITY=\"B\"") Many more examples are available in the test suite. Do C-u M-x run-tag-query-tests to see them.