Change: (heading) Accept multiple regexps
This commit is contained in:
parent
8a812323fc
commit
8a624bdf0d
2 changed files with 9 additions and 4 deletions
|
|
@ -211,7 +211,7 @@ Arguments are listed next to predicate names, where applicable.
|
||||||
+ ~descendants (&optional query)~ :: Return non-nil if current heading has descendant headings. If ~QUERY~, test it against descendant headings. This selector may be nested (if you can grok the nesting!).
|
+ ~descendants (&optional query)~ :: Return non-nil if current heading has descendant headings. If ~QUERY~, test it against descendant headings. This selector may be nested (if you can grok the nesting!).
|
||||||
+ ~done~ :: Return non-nil if entry's ~TODO~ keyword is in ~org-done-keywords~.
|
+ ~done~ :: Return non-nil if entry's ~TODO~ keyword is in ~org-done-keywords~.
|
||||||
+ ~habit~ :: Return non-nil if entry is a habit.
|
+ ~habit~ :: Return non-nil if entry is a habit.
|
||||||
+ ~heading (regexp)~ :: Return non-nil if current entry's heading matches ~REGEXP~ (a regexp string).
|
+ ~heading (&rest regexps)~ :: Return non-nil if current entry's heading matches any of ~REGEXPS~ (regexp strings).
|
||||||
+ ~level (level-or-comparator &optional level)~ :: Return non-nil if current heading's outline level matches arguments. The following forms are accepted: ~(level NUMBER)~: Matches if heading level is ~NUMBER~. ~(level NUMBER NUMBER)~: Matches if heading level is equal to or between NUMBERs. ~(level COMPARATOR NUMBER)~: Matches if heading level compares to ~NUMBER~ with ~COMPARATOR~. ~COMPARATOR~ may be ~<~, ~<=~, ~>~, or ~>=~.
|
+ ~level (level-or-comparator &optional level)~ :: Return non-nil if current heading's outline level matches arguments. The following forms are accepted: ~(level NUMBER)~: Matches if heading level is ~NUMBER~. ~(level NUMBER NUMBER)~: Matches if heading level is equal to or between NUMBERs. ~(level COMPARATOR NUMBER)~: Matches if heading level compares to ~NUMBER~ with ~COMPARATOR~. ~COMPARATOR~ may be ~<~, ~<=~, ~>~, or ~>=~.
|
||||||
+ ~priority (&optional comparator-or-priority priority)~ :: Return non-nil if current heading has a certain priority. ~COMPARATOR-OR-PRIORITY~ should be either a comparator function, like ~<=~, or a priority string, like "A" (in which case (~=~ will be the comparator). If ~COMPARATOR-OR-PRIORITY~ is a comparator, ~PRIORITY~ should be a priority string. If both arguments are nil, return non-nil if heading has any defined priority.
|
+ ~priority (&optional comparator-or-priority priority)~ :: Return non-nil if current heading has a certain priority. ~COMPARATOR-OR-PRIORITY~ should be either a comparator function, like ~<=~, or a priority string, like "A" (in which case (~=~ will be the comparator). If ~COMPARATOR-OR-PRIORITY~ is a comparator, ~PRIORITY~ should be a priority string. If both arguments are nil, return non-nil if heading has any defined priority.
|
||||||
+ ~property (property &optional value)~ :: Return non-nil if current entry has ~PROPERTY~ (a string), and optionally ~VALUE~ (a string). Note that property inheritance is currently /not/ enabled for this predicate. If you need to test with inheritance, you could use a custom predicate form, like ~(org-entry-get (point) "PROPERTY" 'inherit)~.
|
+ ~property (property &optional value)~ :: Return non-nil if current entry has ~PROPERTY~ (a string), and optionally ~VALUE~ (a string). Note that property inheritance is currently /not/ enabled for this predicate. If you need to test with inheritance, you could use a custom predicate form, like ~(org-entry-get (point) "PROPERTY" 'inherit)~.
|
||||||
|
|
@ -465,6 +465,9 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience
|
||||||
- For heading-local tags: =tags-local=, =local-tags=, =tags-l=, =ltags=.
|
- For heading-local tags: =tags-local=, =local-tags=, =tags-l=, =ltags=.
|
||||||
- =tags-all=, =tags&=: Matches all given tags using boolean =AND= (rather than boolean =OR=, which the =tags= predicate uses).
|
- =tags-all=, =tags&=: Matches all given tags using boolean =AND= (rather than boolean =OR=, which the =tags= predicate uses).
|
||||||
|
|
||||||
|
*Changed*
|
||||||
|
+ Predicate =heading= now accepts multiple regexps.
|
||||||
|
|
||||||
** 0.2
|
** 0.2
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 67be09f9-e959-4333-9be2-93ad8f458fbe
|
:ID: 67be09f9-e959-4333-9be2-93ad8f458fbe
|
||||||
|
|
|
||||||
|
|
@ -897,9 +897,11 @@ priority."
|
||||||
thereis (save-excursion
|
thereis (save-excursion
|
||||||
(re-search-forward regexp end t))))))
|
(re-search-forward regexp end t))))))
|
||||||
|
|
||||||
(org-ql--defpred heading (regexp)
|
(org-ql--defpred heading (&rest regexps)
|
||||||
"Return non-nil if current entry's heading matches REGEXP (a regexp string)."
|
"Return non-nil if current entry's heading matches any of REGEXPS (regexp strings)."
|
||||||
(string-match regexp (org-get-heading 'no-tags 'no-todo)))
|
;; TODO: In Org 9.2+, `org-get-heading' takes 2 more arguments.
|
||||||
|
(let ((heading (org-get-heading 'no-tags 'no-todo)))
|
||||||
|
(--any (string-match it heading) regexps)))
|
||||||
|
|
||||||
(org-ql--defpred property (property &optional value)
|
(org-ql--defpred property (property &optional value)
|
||||||
"Return non-nil if current entry has PROPERTY (a string), and optionally VALUE (a string)."
|
"Return non-nil if current entry has PROPERTY (a string), and optionally VALUE (a string)."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue