0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 20:07:46 +00:00

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.
This commit is contained in:
Nicolas Goaziou 2021-10-23 11:18:10 +02:00
parent 6ca685c3c5
commit d3143feaf7
2 changed files with 6 additions and 1 deletions

View file

@ -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)

View file

@ -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