From eb37560b9c94bed6e91d6834462173d0a6d7d44b Mon Sep 17 00:00:00 2001 From: Morgan Smith Date: Fri, 19 Apr 2024 10:46:28 -0400 Subject: [PATCH] test-org-element/cache-map: Add test for :from-pos * testing/lisp/test-org-element.el (test-org-element/cache-map): Add test for :from-pos. --- testing/lisp/test-org-element.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index ad4ff1ce9..a0dbc726e 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -4994,7 +4994,21 @@ Text (equal '(org-data headline section drawer paragraph) (org-test-with-temp-text "* headline\n:DRAWER:\nparagraph\n:END:" - (org-element-cache-map #'car :granularity 'element))))) + (org-element-cache-map #'car :granularity 'element)))) + (should + (equal + ;; This fails returning '(paragraph paragraph) because it returns + ;; the paragraph under "headline". This is because at + ;; org-element.el:8028 we travel up the parents of drawer trying + ;; to find a paragraph. + '(paragraph) + (org-test-with-temp-text "* headline\nparagraph\n** subheading\n:DRAWER:\nparagraph\n:END:\n" + (let ((subheading (org-element-at-point))) + (org-element-cache-map + #'car + :granularity 'element + :restrict-elements '(paragraph) + :from-pos (org-element-contents-begin subheading))))))) (ert-deftest test-org-element/cache () "Test basic expectations and common pitfalls for cache." -- 2.41.0