diff --git a/README.org b/README.org index 988a13c..5a79fe2 100644 --- a/README.org +++ b/README.org @@ -221,6 +221,8 @@ Arguments are listed next to predicate names, where applicable. - 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. - 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~). *** 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: - For inherited tags: =tags-inherited=, =inherited-tags=, =tags-i=, =itags=. - 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 :PROPERTIES: diff --git a/org-ql.el b/org-ql.el index 80aa4b8..2f94581 100644 --- a/org-ql.el +++ b/org-ql.el @@ -330,7 +330,10 @@ Replaces bare strings with (regexp) selectors, and appropriate ;; Quote comparator. `(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-l 'ltags 'local-tags) . ,tags) `(tags-local ,@tags)) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index ed2e46c..99e0906 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -631,6 +631,14 @@ RESULTS should be a list of strings as returned by (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")))) + (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 "active"