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.
This commit is contained in:
Adam Porter 2019-09-11 22:02:14 -05:00
parent 5574f33682
commit f55fe7ef79
2 changed files with 7 additions and 2 deletions

View file

@ -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 =heading= now accepts multiple regexps, which are matched with boolean =AND=.
+ Predicate =regexp= now matches its regexp arguments 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 ** 0.2.1
*Fixed* *Fixed*

View file

@ -448,12 +448,14 @@ replace the clause with a preamble."
nil) nil)
;; Heading text. ;; Heading text.
;; MAYBE: Adjust regexp to avoid matching in tag list.
(`(heading ,regexp) (`(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) (setq org-ql-preamble (rx-to-string `(seq bol (1+ "*") (1+ blank) (0+ nonl)
,regexp) ,regexp)
'no-group)) 'no-group))
nil) element)
(`(heading . ,regexps) (`(heading . ,regexps)
;; Multiple regexps: use preamble to match against first ;; Multiple regexps: use preamble to match against first
;; regexp, then let the predicate match the rest. ;; regexp, then let the predicate match the rest.