Add: (path) predicate
This commit is contained in:
parent
29c3cdd360
commit
ea2ed02c84
3 changed files with 25 additions and 0 deletions
|
|
@ -213,6 +213,7 @@ Arguments are listed next to predicate names, where applicable.
|
|||
+ ~habit~ :: Return non-nil if entry is a habit.
|
||||
+ ~heading (&rest regexps)~ :: Return non-nil if current entry's heading matches all ~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 ~>=~.
|
||||
+ =path (&rest regexps)= :: Return non-nil if current heading's buffer's filename path matches any of =REGEXPS= (regexp strings). Without arguments, return non-nil if buffer is file-backed.
|
||||
+ ~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)~.
|
||||
+ ~regexp (regexp)~ :: Return non-nil if current entry matches ~REGEXP~ (a regexp string). Matches against entire entry, from beginning of its heading to the next heading.
|
||||
|
|
@ -468,6 +469,7 @@ 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=.
|
||||
- =tags-all=, =tags&=: Matches all given tags using boolean =AND= (rather than boolean =OR=, which the =tags= predicate uses).
|
||||
+ Variable =org-ql-block-header=, which overrides the default header in =org-ql-block= agenda blocks.
|
||||
+ Predicate =(path)=.
|
||||
|
||||
*Changed*
|
||||
+ Predicate =heading= now accepts multiple regexps, which are matched with boolean =AND=.
|
||||
|
|
|
|||
|
|
@ -783,6 +783,15 @@ Or, when possible, fix the problem."
|
|||
(null t)
|
||||
(otherwise (member category categories)))))
|
||||
|
||||
(org-ql--defpred path (&rest regexps)
|
||||
"Return non-nil if current heading's buffer's filename path matches any of REGEXPS (regexp strings).
|
||||
Without arguments, return non-nil if buffer is file-backed."
|
||||
(when (buffer-file-name)
|
||||
(cl-typecase regexps
|
||||
(null t)
|
||||
(list (cl-loop for regexp in regexps
|
||||
thereis (string-match regexp (buffer-file-name)))))))
|
||||
|
||||
(org-ql--defpred todo (&rest keywords)
|
||||
"Return non-nil if current heading is a TODO item.
|
||||
With KEYWORDS, return non-nil if its keyword is one of KEYWORDS (a list of strings)."
|
||||
|
|
|
|||
|
|
@ -411,6 +411,20 @@ RESULTS should be a list of strings as returned by
|
|||
(org-ql-expect ((habit))
|
||||
'("Practice leaping tall buildings in a single bound")))
|
||||
|
||||
(describe "(path)"
|
||||
(org-ql-it "without arguments"
|
||||
(org-ql-expect ((path))
|
||||
'("Test data" "Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Practice leaping tall buildings in a single bound" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "Recurring" "/r/emacs" "Shop for groceries" "Sunrise/sunset" "Ideas" "Rewrite Emacs in Common Lisp" "Write a symphony" "Code" "Agenda examining" "Agenda censoring" "Auto grouping" "Auto categories" "Date" "Effort" "Misc" "let-plist" "Profiling")))
|
||||
(org-ql-it "with one argument"
|
||||
(org-ql-expect ((path "data"))
|
||||
'("Test data" "Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Practice leaping tall buildings in a single bound" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "Recurring" "/r/emacs" "Shop for groceries" "Sunrise/sunset" "Ideas" "Rewrite Emacs in Common Lisp" "Write a symphony" "Code" "Agenda examining" "Agenda censoring" "Auto grouping" "Auto categories" "Date" "Effort" "Misc" "let-plist" "Profiling")))
|
||||
(org-ql-it "with two matching arguments"
|
||||
(org-ql-expect ((path "data" "tests"))
|
||||
'("Test data" "Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Practice leaping tall buildings in a single bound" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "Recurring" "/r/emacs" "Shop for groceries" "Sunrise/sunset" "Ideas" "Rewrite Emacs in Common Lisp" "Write a symphony" "Code" "Agenda examining" "Agenda censoring" "Auto grouping" "Auto categories" "Date" "Effort" "Misc" "let-plist" "Profiling")))
|
||||
(org-ql-it "with two arguments, one matching"
|
||||
(org-ql-expect ((path "data" "nope"))
|
||||
'("Test data" "Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Practice leaping tall buildings in a single bound" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "Recurring" "/r/emacs" "Shop for groceries" "Sunrise/sunset" "Ideas" "Rewrite Emacs in Common Lisp" "Write a symphony" "Code" "Agenda examining" "Agenda censoring" "Auto grouping" "Auto categories" "Date" "Effort" "Misc" "let-plist" "Profiling"))))
|
||||
|
||||
(describe "(planning)"
|
||||
|
||||
(org-ql-it "without arguments"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue