diff --git a/org-ql.el b/org-ql.el index 7bf4462..bb3e3c7 100644 --- a/org-ql.el +++ b/org-ql.el @@ -1003,12 +1003,10 @@ contiguous segment of the outline path: `(outline-path-segment ,@(mapcar #'regexp-quote strings)))) :predicate (org-ql--infix-p regexps (org-ql--value-at (point) #'org-ql--outline-path))) -(org-ql-define-predicate (tags tags-all tags&) (&rest tags) - ;; NOTE: tags-all and tags& are "virtual" predicates that are handled by query pre-processing. +(org-ql-define-predicate (tags) (&rest tags) "Return non-nil if current heading has one or more of TAGS (a list of strings). Tests both inherited and local tags." ;; MAYBE: -all versions for inherited and local. - :normalizers ((`(,predicate-names . ,tags) `(and ,@(--map `(tags ,it) tags)))) :predicate (cl-macrolet ((tags-p (tags) `(and ,tags (not (eq 'org-ql-nil ,tags))))) @@ -1021,11 +1019,21 @@ Tests both inherited and local tags." (when (tags-p local) (seq-intersection tags local)))))))) -(org-ql-define-predicate (tags-inherited tags-i itags) (&rest tags) +(org-ql-define-predicate (tags-all tags&) (&rest tags) + "Return non-nil if current heading has all of TAGS (a list of strings). +Tests both inherited and local tags." + ;; MAYBE: -all versions for inherited and local. + :normalizers ((`(,predicate-names) `(tags)) + (`(,predicate-names . ,tags) `(and ,@(--map `(tags ,it) tags)))) + :predicate #'org-ql--predicate-tags) + +(org-ql-define-predicate (tags-inherited inherited-tags tags-i itags) (&rest tags) "Return non-nil if current heading's inherited tags include one or more of TAGS (a list of strings). If TAGS is nil, return non-nil if heading has any inherited tags." :normalizers ((`(,predicate-names . ,tags) - `(tags-inherited ,@tags))) + `(tags-inherited ,@tags)) + (`(,predicate-names) + `(tags-inherited))) :predicate (cl-macrolet ((tags-p (tags) `(and ,tags (not (eq 'org-ql-nil ,tags))))) @@ -1035,16 +1043,18 @@ If TAGS is nil, return non-nil if heading has any inherited tags." (otherwise (when (tags-p inherited) (seq-intersection tags inherited))))))) -(org-ql-define-predicate (tags-local tags-l ltags) (&rest tags) +(org-ql-define-predicate (tags-local local-tags tags-l ltags) (&rest 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." - :normalizers ((`(,predicate-names . ,tags) `(tags-local ,@tags))) - :preambles ((`(,predicate-names . ,tags) + :normalizers ((`(,predicate-names) `(tags-local)) + (`(,predicate-names . ,tags) `(tags-local ,@tags))) + :preambles ((`(,predicate-names . ,(and tags (guard tags))) ;; When searching for local, non-inherited tags, we can ;; search directly to headings containing one of the tags. (list :regexp (rx-to-string `(seq bol (1+ "*") (1+ space) (1+ not-newline) ":" (or ,@tags) ":") - t)))) + t) + :query t))) :predicate (cl-macrolet ((tags-p (tags) `(and ,tags (not (eq 'org-ql-nil ,tags))))) diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index c0406f6..0ee3a1e 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -858,152 +858,152 @@ RESULTS should be a list of strings as returned by ;; ;; TODO: Test (src) predicate. That will require modifying test data, which will be a ;; ;; significant hassle. Manual testing shows that the predicate appears to work properly. ;; - ;; (describe "(todo)" - ;; - ;; (org-ql-it "without arguments" - ;; (org-ql-expect ((todo) - ;; :sort todo) - ;; '("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" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp" "Write a symphony"))) - ;; - ;; (org-ql-it "with 1 argument" - ;; (org-ql-expect ((todo "WAITING") - ;; :sort todo) - ;; '("Visit the moon"))) - ;; - ;; (org-ql-it "with 2 arguments" - ;; (org-ql-expect ((todo "WAITING" "SOMEDAY") - ;; :sort todo) - ;; '("Visit the moon" "Rewrite Emacs in Common Lisp" "Write a symphony")))) - ;; - ;; (describe "(tags)" - ;; - ;; (org-ql-it "without arguments" - ;; (org-ql-expect ((tags)) - ;; '("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" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp" "Write a symphony")) - ;; (org-ql-expect ((not (tags))) - ;; '("Recurring" "Sunrise/sunset" "Ideas"))) - ;; - ;; (org-ql-it "with a tag" - ;; (org-ql-expect ((tags "Emacs")) - ;; '("/r/emacs" "Rewrite Emacs in Common Lisp")) - ;; (org-ql-expect ((not (tags "Emacs"))) - ;; '("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" "Shop for groceries" "Sunrise/sunset" "Ideas" "Write a symphony"))) - ;; - ;; (org-ql-it "with 2 tags" - ;; (org-ql-expect ((tags "Emacs" "space")) - ;; '("Visit Mars" "Visit the moon" "/r/emacs" "Rewrite Emacs in Common Lisp")) - ;; (org-ql-expect ((not (tags "Emacs" "space"))) - ;; '("Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Take over 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" "Shop for groceries" "Sunrise/sunset" "Ideas" "Write a symphony"))) - ;; - ;; (org-ql-it "with file tags" - ;; (org-ql-expect ((tags "food")) - ;; '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") - ;; :buffer (org-ql-test-data-buffer "data2.org")) - ;; (org-ql-expect ((tags "fruit")) - ;; '("Fruit" "Blueberry" "Strawberry") - ;; :buffer (org-ql-test-data-buffer "data2.org")))) - ;; - ;; (describe "(tags-inherited)" - ;; - ;; (org-ql-it "without arguments" - ;; (org-ql-expect ((tags-inherited)) - ;; '("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")) - ;; (org-ql-expect ((not (inherited-tags))) - ;; '("Take over the universe" "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"))) - ;; - ;; (org-ql-it "with a tag" - ;; (org-ql-expect ((tags-inherited "Emacs")) - ;; nil) - ;; (org-ql-expect ((itags "ambition")) - ;; '("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")) - ;; (org-ql-expect ((not (tags-i "ambition"))) - ;; '("Take over the universe" "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"))) - ;; - ;; (org-ql-it "with 2 tags" - ;; (org-ql-expect ((itags "personal" "world")) - ;; '("Skype with president of Antarctica")) - ;; (org-ql-expect ((not (tags-inherited "personal" "world"))) - ;; ;; Note that this correctly includes the task "Practice leaping...", which has the LOCAL tag "personal". - ;; '("Take over the universe" "Take over the world" "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"))) - ;; - ;; (org-ql-it "with file tags" - ;; (org-ql-expect ((tags-inherited "food")) - ;; '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") - ;; :buffer (org-ql-test-data-buffer "data2.org")) - ;; (org-ql-expect ((tags-inherited "fruit")) - ;; '("Blueberry" "Strawberry") - ;; :buffer (org-ql-test-data-buffer "data2.org")))) - ;; - ;; (describe "(tags-local)" - ;; - ;; (org-ql-it "without arguments" - ;; (org-ql-expect ((tags-local)) - ;; '("Take over the universe" "Take over the world" "Skype with president of Antarctica" "Visit Mars" "Visit the moon" "Practice leaping tall buildings in a single bound" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp" "Write a symphony")) - ;; (org-ql-expect ((not (local-tags))) - ;; '("Take over Mars" "Take over the moon" "Renew membership in supervillain club" "Learn universal sign language" "Recurring" "Sunrise/sunset" "Ideas"))) - ;; - ;; (org-ql-it "with a tag" - ;; (org-ql-expect ((tags-local "world")) - ;; '("Take over the world" "Skype with president of Antarctica")) - ;; (org-ql-expect ((ltags "ambition")) - ;; '("Take over the universe")) - ;; (org-ql-expect ((not (tags-l "ambition"))) - ;; '("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"))) - ;; - ;; (org-ql-it "with 2 tags" - ;; (org-ql-expect ((ltags "personal" "world")) - ;; '("Take over the world" "Skype with president of Antarctica" "Practice leaping tall buildings in a single bound" "Get haircut")) - ;; (org-ql-expect ((not (tags-local "personal" "world"))) - ;; '("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"))) - ;; - ;; (org-ql-it "with file tags" - ;; (org-ql-expect ((tags-local "food")) - ;; nil - ;; :buffer (org-ql-test-data-buffer "data2.org")) - ;; (org-ql-expect ((tags-local "fruit")) - ;; '("Fruit") - ;; :buffer (org-ql-test-data-buffer "data2.org")))) - ;; - ;; (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"))) - ;; - ;; (org-ql-it "with file tags" - ;; (org-ql-expect ((tags-all "food" "fruit")) - ;; '("Fruit" "Blueberry" "Strawberry") - ;; :buffer (org-ql-test-data-buffer "data2.org")))) - ;; - ;; (describe "(tags-regexp), (tags*)" - ;; - ;; (org-ql-it "without arguments" - ;; (org-ql-expect ((tags-regexp)) - ;; '("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" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp" "Write a symphony")) - ;; (org-ql-expect ((not (tags*))) - ;; '("Recurring" "Sunrise/sunset" "Ideas"))) - ;; - ;; (org-ql-it "with a tag regexp" - ;; (org-ql-expect ((tags-regexp "Emac")) - ;; '("/r/emacs" "Rewrite Emacs in Common Lisp")) - ;; (org-ql-expect ((not (tags* "Emac"))) - ;; '("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" "Shop for groceries" "Sunrise/sunset" "Ideas" "Write a symphony"))) - ;; - ;; (org-ql-it "with 2 tag regexps" - ;; (org-ql-expect ((tags-regexp "Emac" "spac")) - ;; '("Visit Mars" "Visit the moon" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Rewrite Emacs in Common Lisp")) - ;; (org-ql-expect ((not (tags* "Emac" "spac"))) - ;; '("Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Take over 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" "Recurring" "Shop for groceries" "Sunrise/sunset" "Ideas" "Write a symphony"))) - ;; - ;; (org-ql-it "with regexp matching file tags" - ;; (org-ql-expect ((tags-regexp "foo")) - ;; '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") - ;; :buffer (org-ql-test-data-buffer "data2.org")) - ;; (org-ql-expect ((tags* "frui")) - ;; '("Fruit" "Blueberry" "Strawberry") - ;; :buffer (org-ql-test-data-buffer "data2.org")))) + (describe "(todo)" + + (org-ql-it "without arguments" + (org-ql-expect ((todo) + :sort todo) + '("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" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp" "Write a symphony"))) + + (org-ql-it "with 1 argument" + (org-ql-expect ((todo "WAITING") + :sort todo) + '("Visit the moon"))) + + (org-ql-it "with 2 arguments" + (org-ql-expect ((todo "WAITING" "SOMEDAY") + :sort todo) + '("Visit the moon" "Rewrite Emacs in Common Lisp" "Write a symphony")))) + + (describe "(tags)" + + (org-ql-it "without arguments" + (org-ql-expect ((tags)) + '("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" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp" "Write a symphony")) + (org-ql-expect ((not (tags))) + '("Recurring" "Sunrise/sunset" "Ideas"))) + + (org-ql-it "with a tag" + (org-ql-expect ((tags "Emacs")) + '("/r/emacs" "Rewrite Emacs in Common Lisp")) + (org-ql-expect ((not (tags "Emacs"))) + '("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" "Shop for groceries" "Sunrise/sunset" "Ideas" "Write a symphony"))) + + (org-ql-it "with 2 tags" + (org-ql-expect ((tags "Emacs" "space")) + '("Visit Mars" "Visit the moon" "/r/emacs" "Rewrite Emacs in Common Lisp")) + (org-ql-expect ((not (tags "Emacs" "space"))) + '("Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Take over 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" "Shop for groceries" "Sunrise/sunset" "Ideas" "Write a symphony"))) + + (org-ql-it "with file tags" + (org-ql-expect ((tags "food")) + '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") + :buffer (org-ql-test-data-buffer "data2.org")) + (org-ql-expect ((tags "fruit")) + '("Fruit" "Blueberry" "Strawberry") + :buffer (org-ql-test-data-buffer "data2.org")))) + + (describe "(tags-inherited)" + + (org-ql-it "without arguments" + (org-ql-expect ((tags-inherited)) + '("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")) + (org-ql-expect ((not (inherited-tags))) + '("Take over the universe" "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"))) + + (org-ql-it "with a tag" + (org-ql-expect ((tags-inherited "Emacs")) + nil) + (org-ql-expect ((itags "ambition")) + '("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")) + (org-ql-expect ((not (tags-i "ambition"))) + '("Take over the universe" "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"))) + + (org-ql-it "with 2 tags" + (org-ql-expect ((itags "personal" "world")) + '("Skype with president of Antarctica")) + (org-ql-expect ((not (tags-inherited "personal" "world"))) + ;; Note that this correctly includes the task "Practice leaping...", which has the LOCAL tag "personal". + '("Take over the universe" "Take over the world" "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"))) + + (org-ql-it "with file tags" + (org-ql-expect ((tags-inherited "food")) + '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") + :buffer (org-ql-test-data-buffer "data2.org")) + (org-ql-expect ((tags-inherited "fruit")) + '("Blueberry" "Strawberry") + :buffer (org-ql-test-data-buffer "data2.org")))) + + (describe "(tags-local)" + + (org-ql-it "without arguments" + (org-ql-expect ((tags-local)) + '("Take over the universe" "Take over the world" "Skype with president of Antarctica" "Visit Mars" "Visit the moon" "Practice leaping tall buildings in a single bound" "Order a pizza" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp" "Write a symphony")) + (org-ql-expect ((not (local-tags))) + '("Take over Mars" "Take over the moon" "Renew membership in supervillain club" "Learn universal sign language" "Recurring" "Sunrise/sunset" "Ideas"))) + + (org-ql-it "with a tag" + (org-ql-expect ((tags-local "world")) + '("Take over the world" "Skype with president of Antarctica")) + (org-ql-expect ((ltags "ambition")) + '("Take over the universe")) + (org-ql-expect ((not (tags-l "ambition"))) + '("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"))) + + (org-ql-it "with 2 tags" + (org-ql-expect ((ltags "personal" "world")) + '("Take over the world" "Skype with president of Antarctica" "Practice leaping tall buildings in a single bound" "Get haircut")) + (org-ql-expect ((not (tags-local "personal" "world"))) + '("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"))) + + (org-ql-it "with file tags" + (org-ql-expect ((tags-local "food")) + nil + :buffer (org-ql-test-data-buffer "data2.org")) + (org-ql-expect ((tags-local "fruit")) + '("Fruit") + :buffer (org-ql-test-data-buffer "data2.org")))) + + (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"))) + + (org-ql-it "with file tags" + (org-ql-expect ((tags-all "food" "fruit")) + '("Fruit" "Blueberry" "Strawberry") + :buffer (org-ql-test-data-buffer "data2.org")))) + + (describe "(tags-regexp), (tags*)" + + (org-ql-it "without arguments" + (org-ql-expect ((tags-regexp)) + '("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" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp" "Write a symphony")) + (org-ql-expect ((not (tags*))) + '("Recurring" "Sunrise/sunset" "Ideas"))) + + (org-ql-it "with a tag regexp" + (org-ql-expect ((tags-regexp "Emac")) + '("/r/emacs" "Rewrite Emacs in Common Lisp")) + (org-ql-expect ((not (tags* "Emac"))) + '("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" "Shop for groceries" "Sunrise/sunset" "Ideas" "Write a symphony"))) + + (org-ql-it "with 2 tag regexps" + (org-ql-expect ((tags-regexp "Emac" "spac")) + '("Visit Mars" "Visit the moon" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Rewrite Emacs in Common Lisp")) + (org-ql-expect ((not (tags* "Emac" "spac"))) + '("Take over the universe" "Take over the world" "Skype with president of Antarctica" "Take over Mars" "Take over 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" "Recurring" "Shop for groceries" "Sunrise/sunset" "Ideas" "Write a symphony"))) + + (org-ql-it "with regexp matching file tags" + (org-ql-expect ((tags-regexp "foo")) + '("Fruit" "Blueberry" "Strawberry" "Vegetable" "Broccoli" "Potato") + :buffer (org-ql-test-data-buffer "data2.org")) + (org-ql-expect ((tags* "frui")) + '("Fruit" "Blueberry" "Strawberry") + :buffer (org-ql-test-data-buffer "data2.org")))) ;; ;; (describe "(ts)" ;;