From f55fe7ef79899e03879f0a48874a4f179c65614b Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 11 Sep 2019 22:02:14 -0500 Subject: [PATCH] Fix: (heading) Only match against heading text It should not match against e.g. tags strings or to-do keywords. Note that the (regexp) predicate still matches against those, because it searches entire entries, from heading stars to the next entry. --- README.org | 3 +++ org-ql.el | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 0c32e91..0311a4e 100644 --- a/README.org +++ b/README.org @@ -488,6 +488,9 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience + Predicate =heading= now accepts multiple regexps, which are matched with boolean =AND=. + Predicate =regexp= now matches its regexp arguments with boolean =AND=. +*Fixed* ++ Predicate =heading= now matches only against heading text, i.e. not including tags at the end of the line, to-do keyword, etc. + ** 0.2.1 *Fixed* diff --git a/org-ql.el b/org-ql.el index a80a9d9..f3d611e 100644 --- a/org-ql.el +++ b/org-ql.el @@ -448,12 +448,14 @@ replace the clause with a preamble." nil) ;; Heading text. + ;; MAYBE: Adjust regexp to avoid matching in tag list. (`(heading ,regexp) - ;; Only one regexp: match with preamble only. + ;; Only one regexp: match with preamble, then let predicate confirm (because + ;; the match could be in e.g. the tags rather than the heading text). (setq org-ql-preamble (rx-to-string `(seq bol (1+ "*") (1+ blank) (0+ nonl) ,regexp) 'no-group)) - nil) + element) (`(heading . ,regexps) ;; Multiple regexps: use preamble to match against first ;; regexp, then let the predicate match the rest.