summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2021-10-23 11:18:10 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2021-10-23 11:18:10 +0200
commitd3143feaf7707f5b83def0723cc2130d9ecaaf59 (patch)
tree65f98fb1e3149b1ded0f26da85c3ab5e2bbcf1a8
parent6ca685c3c566ccdee917f8d620d1185fc3282646 (diff)
downloadorg-mode-d3143feaf7707f5b83def0723cc2130d9ecaaf59.tar.gz
Fix sloppiness when collecting keywords
* lisp/org.el (org--collect-keywords-1): Use an accurate function instead of an approximation. Accuracy trumps speed when parsing. * testing/lisp/test-org.el (test-org/collect-keywords): New test.
-rw-r--r--lisp/org.el2
-rw-r--r--testing/lisp/test-org.el5
2 files changed, 6 insertions, 1 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 474171b55..0a83c00fc 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4544,7 +4544,7 @@ directory."
(let ((case-fold-search t)
(regexp (org-make-options-regexp keywords)))
(while (and keywords (re-search-forward regexp nil t))
- (let ((element (org-with-point-at (match-beginning 0) (org-element-keyword-parser (line-end-position) (list (match-beginning 0))))))
+ (let ((element (org-element-at-point)))
(when (eq 'keyword (org-element-type element))
(let ((value (org-element-property :value element)))
(pcase (org-element-property :key element)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index f7c84ba1b..47a5f565f 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -2648,6 +2648,11 @@ SCHEDULED: <2014-03-04 tue.>"
(org-mode-restart)
(cdr (assoc "a" org-keyword-properties))))))
+(ert-deftest test-org/collect-keywords ()
+ "Test `org-collect-keywords'."
+ (should-not
+ (org-test-with-temp-text "#+begin_example\n#+foo: bar\n#+end_example"
+ (org-collect-keywords '("FOO")))))
;;; Links