diff --git a/README.org b/README.org index a5a6dbd..b2693f6 100644 --- a/README.org +++ b/README.org @@ -233,7 +233,8 @@ If ~MARKERS~ is non-nil, ~org-agenda-ng--add-markers~ is used to add markers to ** 0.2-pre -Nothing new yet. +*Changed* ++ ~(regexp)~ selector accepts multiple regexps to test. ** 0.1 diff --git a/org-ql.el b/org-ql.el index 13420ad..fc59f14 100644 --- a/org-ql.el +++ b/org-ql.el @@ -461,14 +461,16 @@ comparator, PRIORITY should be a priority string." "Return non-nil if entry is a habit." (org-is-habit-p)) -(org-ql--defpredicate regexp (regexp) - "Return non-nil if current entry matches REGEXP (a regexp string)." +(org-ql--defpredicate regexp (&rest regexps) + "Return non-nil if current entry matches one of REGEXPS (regexp strings)." (let ((end (or (save-excursion (outline-next-heading)) (point-max)))) (save-excursion (goto-char (line-beginning-position)) - (re-search-forward regexp end t)))) + (cl-loop for regexp in regexps + thereis (save-excursion + (re-search-forward regexp end t)))))) (org-ql--defpredicate heading (regexp) "Return non-nil if current entry's heading matches REGEXP (a regexp string)." diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index a718f9f..aa9807a 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -255,6 +255,18 @@ :action (org-ql-test-org-get-heading)) :to-equal '("Learn universal sign language"))) + (describe "(regexp)" + (it "with 1 argument" + (expect (org-ql test-buffer + (regexp "Take over") + :sort todo + :action (org-ql-test-org-get-heading)) :to-equal '("Take over the universe" "Take over the world" "Take over Mars" "Take over the moon" "Get haircut"))) + (it "with 2 arguments" + (expect (org-ql test-buffer + (regexp "Take over" "pizza") + :sort todo + :action (org-ql-test-org-get-heading)) :to-equal '("Take over the universe" "Take over the world" "Take over Mars" "Take over the moon" "Order a pizza" "Get haircut")))) + (describe "(ts)" (it "without arguments" (expect (org-ql test-buffer