Add: tags-all, tags&

This commit is contained in:
Adam Porter 2019-09-05 13:21:59 -05:00
parent dcad551760
commit f55aae782c
3 changed files with 15 additions and 1 deletions

View file

@ -221,6 +221,8 @@ Arguments are listed next to predicate names, where applicable.
- Aliases: =inherited-tags=, =tags-i=, =itags=. - Aliases: =inherited-tags=, =tags-i=, =itags=.
+ =tags-local (&optional tags)= :: Return non-nil if current heading's local tags include one or more of =TAGS= (a list of strings). If TAGS is nil, return non-nil if heading has any local tags. + =tags-local (&optional tags)= :: Return non-nil if current heading's local tags include one or more of =TAGS= (a list of strings). If TAGS is nil, return non-nil if heading has any local tags.
- Aliases: =local-tags=, =tags-l=, =ltags=. - Aliases: =local-tags=, =tags-l=, =ltags=.
+ =tags-all (tags)= :: Return non-nil if current heading includes all of =TAGS=. Tests both inherited and local tags.
- Aliases: =tags&=.
+ ~todo (&optional 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). When called without arguments, only matches non-done tasks (i.e. does not match keywords in ~org-done-keywords~). + ~todo (&optional 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). When called without arguments, only matches non-done tasks (i.e. does not match keywords in ~org-done-keywords~).
*** Date/time predicates *** Date/time predicates
@ -461,6 +463,7 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience
+ More tags-related predicates and aliases: + More tags-related predicates and aliases:
- For inherited tags: =tags-inherited=, =inherited-tags=, =tags-i=, =itags=. - For inherited tags: =tags-inherited=, =inherited-tags=, =tags-i=, =itags=.
- 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).
** 0.2 ** 0.2
:PROPERTIES: :PROPERTIES:

View file

@ -330,7 +330,10 @@ Replaces bare strings with (regexp) selectors, and appropriate
;; Quote comparator. ;; Quote comparator.
`(priority ',comparator ,letter)) `(priority ',comparator ,letter))
;; Tags: inherited and local predicate aliases. ;; Tags.
(`(,(or 'tags-all 'tags&) . ,tags) `(and ,@(--map `(tags ,it) tags)))
;; MAYBE: -all versions for inherited and local.
;; Inherited and local predicate aliases.
(`(,(or 'tags-i 'itags 'inherited-tags) . ,tags) `(tags-inherited ,@tags)) (`(,(or 'tags-i 'itags 'inherited-tags) . ,tags) `(tags-inherited ,@tags))
(`(,(or 'tags-l 'ltags 'local-tags) . ,tags) `(tags-local ,@tags)) (`(,(or 'tags-l 'ltags 'local-tags) . ,tags) `(tags-local ,@tags))

View file

@ -631,6 +631,14 @@ RESULTS should be a list of strings as returned by
(org-ql-expect ((not (tags-local "personal" "world"))) (org-ql-expect ((not (tags-local "personal" "world")))
'("Test data" "Take over the universe" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "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")))) '("Test data" "Take over the universe" "Take over Mars" "Visit Mars" "Take over the moon" "Visit the moon" "Renew membership in supervillain club" "Learn universal sign language" "Order a pizza" "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 "(tags-all), (tags&)"
(org-ql-it "with 2 tags"
(org-ql-expect ((tags-all "universe" "personal"))
'("Practice leaping tall buildings in a single bound"))
(org-ql-expect ((tags& "ambition" "space"))
'("Visit Mars" "Visit the moon"))))
(describe "(ts)" (describe "(ts)"
(describe "active" (describe "active"