mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-25 14:32:52 +00:00
org-element--collect-affiliated-keywords: Fix keywords before comment
* lisp/org-element.el (org-element--collect-affiliated-keywords): Disallow affiliated keywords before a comment. * testing/lisp/test-org-element.el (test-org-element/affiliated-keywords-parser): Add new test. * testing/lisp/test-org-element.el (test-org-element/cache-affiliated): Fix test. Reported-by: Tom Alexander <tom@fizz.buzz> Link: https://orgmode.org/list/87c20267-d12e-4641-a1eb-3a7ac8181069@app.fastmail.com
This commit is contained in:
parent
07ae6ba58d
commit
0e3d0e3d19
|
@ -4790,7 +4790,10 @@ When PARSE is non-nil, values from keywords belonging to
|
|||
(forward-line)))
|
||||
;; If affiliated keywords are orphaned: move back to first one.
|
||||
;; They will be parsed as a paragraph.
|
||||
(when (looking-at-p "[ \t]*$") (goto-char origin) (setq output nil))
|
||||
(when (or (looking-at-p "[ \t]*$")
|
||||
;; Affiliated keywords are not allowed before comments.
|
||||
(looking-at-p org-comment-regexp))
|
||||
(goto-char origin) (setq output nil))
|
||||
;; Return value.
|
||||
(cons origin output))))
|
||||
|
||||
|
|
|
@ -872,6 +872,12 @@ Some other text
|
|||
(should-not
|
||||
(org-test-with-temp-text "- item\n #+name: name\nSome paragraph"
|
||||
(progn (search-forward "Some")
|
||||
(org-element-property :name (org-element-at-point)))))
|
||||
;; Corner case: orphaned keyword before comment.
|
||||
;; Comments cannot have affiliated keywords.
|
||||
(should-not
|
||||
(org-test-with-temp-text "#+name: foo\n# bar"
|
||||
(progn (search-forward "bar")
|
||||
(org-element-property :name (org-element-at-point))))))
|
||||
|
||||
|
||||
|
@ -5077,7 +5083,7 @@ Text
|
|||
line"
|
||||
(org-element-cache-map #'ignore :granularity 'element)
|
||||
(should (eq 'keyword (org-element-type (org-element-at-point))))
|
||||
(insert "#")
|
||||
(insert "1")
|
||||
(should (eq 2 (org-element-property :begin (org-element-at-point)))))))
|
||||
|
||||
(ert-deftest test-org-element/cache-table ()
|
||||
|
|
Loading…
Reference in a new issue