|
@@ -1442,6 +1442,96 @@
|
|
|
">>>>>>>>>>")
|
|
|
">>>>>>>>..")))
|
|
|
|
|
|
+(ert-deftest test-org/map-entries ()
|
|
|
+ "Test `org-map-entries' specifications."
|
|
|
+ ;; Full match.
|
|
|
+ (should
|
|
|
+ (equal '(1 11)
|
|
|
+ (org-test-with-temp-text "* Level 1\n** Level 2"
|
|
|
+ (org-map-entries #'point))))
|
|
|
+ ;; Level match.
|
|
|
+ (should
|
|
|
+ (equal '(1)
|
|
|
+ (org-test-with-temp-text "* Level 1\n** Level 2"
|
|
|
+ (let (org-odd-levels-only) (org-map-entries #'point "LEVEL=1")))))
|
|
|
+ (should
|
|
|
+ (equal '(11)
|
|
|
+ (org-test-with-temp-text "* Level 1\n** Level 2"
|
|
|
+ (let (org-odd-levels-only) (org-map-entries #'point "LEVEL>1")))))
|
|
|
+ ;; Tag match.
|
|
|
+ (should
|
|
|
+ (equal '(11)
|
|
|
+ (org-test-with-temp-text "* H1 :no:\n* H2 :yes:"
|
|
|
+ (org-map-entries #'point "yes"))))
|
|
|
+ (should
|
|
|
+ (equal '(14)
|
|
|
+ (org-test-with-temp-text "* H1 :yes:a:\n* H2 :yes:b:"
|
|
|
+ (org-map-entries #'point "+yes-a"))))
|
|
|
+ (should
|
|
|
+ (equal '(11 23)
|
|
|
+ (org-test-with-temp-text "* H1 :no:\n* H2 :yes1:\n* H3 :yes2:"
|
|
|
+ (org-map-entries #'point "{yes?}"))))
|
|
|
+ ;; Priority match.
|
|
|
+ (should
|
|
|
+ (equal '(1)
|
|
|
+ (org-test-with-temp-text "* [#A] H1\n* [#B] H2"
|
|
|
+ (org-map-entries #'point "PRIORITY=\"A\""))))
|
|
|
+ ;; Date match.
|
|
|
+ (should
|
|
|
+ (equal '(36)
|
|
|
+ (org-test-with-temp-text "
|
|
|
+* H1
|
|
|
+SCHEDULED: <2012-03-29 thu.>
|
|
|
+* H2
|
|
|
+SCHEDULED: <2014-03-04 tue.>"
|
|
|
+ (org-map-entries #'point "SCHEDULED=\"<2014-03-04 tue.>\""))))
|
|
|
+ (should
|
|
|
+ (equal '(2)
|
|
|
+ (org-test-with-temp-text "
|
|
|
+* H1
|
|
|
+SCHEDULED: <2012-03-29 thu.>
|
|
|
+* H2
|
|
|
+SCHEDULED: <2014-03-04 tue.>"
|
|
|
+ (org-map-entries #'point "SCHEDULED<\"<2013-01-01>\""))))
|
|
|
+ ;; Regular property match.
|
|
|
+ (should
|
|
|
+ (equal '(2)
|
|
|
+ (org-test-with-temp-text "
|
|
|
+* H1
|
|
|
+:PROPERTIES:
|
|
|
+:TEST: 1
|
|
|
+:END:
|
|
|
+* H2
|
|
|
+:PROPERTIES:
|
|
|
+:TEST: 2
|
|
|
+:END:"
|
|
|
+ (org-map-entries #'point "TEST=1"))))
|
|
|
+ ;; Multiple criteria.
|
|
|
+ (should
|
|
|
+ (equal '(23)
|
|
|
+ (org-test-with-temp-text "* H1 :no:\n** H2 :yes:\n* H3 :yes:"
|
|
|
+ (let (org-odd-levels-only
|
|
|
+ (org-use-tag-inheritance nil))
|
|
|
+ (org-map-entries #'point "yes+LEVEL=1")))))
|
|
|
+ ;; "or" criteria.
|
|
|
+ (should
|
|
|
+ (equal '(12 24)
|
|
|
+ (org-test-with-temp-text "* H1 :yes:\n** H2 :yes:\n** H3 :no:"
|
|
|
+ (let (org-odd-levels-only)
|
|
|
+ (org-map-entries #'point "LEVEL=2|no")))))
|
|
|
+ (should
|
|
|
+ (equal '(1 12)
|
|
|
+ (org-test-with-temp-text "* H1 :yes:\n* H2 :no:\n* H3 :maybe:"
|
|
|
+ (let (org-odd-levels-only)
|
|
|
+ (org-map-entries #'point "yes|no")))))
|
|
|
+ ;; "and" criteria.
|
|
|
+ (should
|
|
|
+ (equal '(22)
|
|
|
+ (org-test-with-temp-text "* H1 :yes:\n* H2 :no:\n* H3 :yes:no:"
|
|
|
+ (let (org-odd-levels-only)
|
|
|
+ (org-map-entries #'point "yes&no"))))))
|
|
|
+
|
|
|
+
|
|
|
|
|
|
;;; Keywords
|
|
|
|