mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-25 15:32:52 +00:00
org-element--current-element: Fix edge case with affiliated keywords
* lisp/org-element.el (org-element--collect-affiliated-keywords): Fix edge case when a keyword matching affiliated keyword is preceding an element that is not allowed to have such. We need to handle this case specially here rather than in `org-element--current-element' to avoid the default paragraph fallback. (org-element--current-element): Add a comment describing the pitfall. * testing/lisp/test-org-element.el (test-org-element/affiliated-keywords-parser): Add more tests. Reported-by: Tom Alexander <tom@fizz.buzz> Link: https://orgmode.org/list/e2be976d-1bcf-4136-9968-33212dcd1f83@app.fastmail.com
This commit is contained in:
parent
f3de4c3e04
commit
0d214ef008
|
@ -4610,6 +4610,10 @@ element it has to parse."
|
|||
;; Inlinetask.
|
||||
(at-task? (org-element-inlinetask-parser limit raw-secondary-p))
|
||||
;; From there, elements can have affiliated keywords.
|
||||
;; Note an edge case with a keyword followed by element that
|
||||
;; cannot have affiliated keywords attached (the above).
|
||||
;; `org-element--collect-affiliated-keywords' must have a
|
||||
;; special check to fall back to parsing proper keyword.
|
||||
(t (let ((affiliated (org-element--collect-affiliated-keywords
|
||||
limit (memq granularity '(nil object)))))
|
||||
(cond
|
||||
|
@ -4792,7 +4796,11 @@ When PARSE is non-nil, values from keywords belonging to
|
|||
;; They will be parsed as a paragraph.
|
||||
(when (or (looking-at-p "[ \t]*$")
|
||||
;; Affiliated keywords are not allowed before comments.
|
||||
(looking-at-p org-comment-regexp))
|
||||
(looking-at-p org-comment-regexp)
|
||||
;; Clock lines are also not allowed.
|
||||
(looking-at-p org-clock-line-re)
|
||||
;; Inlinetasks not allowed.
|
||||
(looking-at-p "^\\*+ "))
|
||||
(goto-char origin) (setq output nil))
|
||||
;; Return value.
|
||||
(cons origin output))))
|
||||
|
|
|
@ -878,7 +878,22 @@ Some other text
|
|||
(should-not
|
||||
(org-test-with-temp-text "#+name: foo\n# bar"
|
||||
(progn (search-forward "bar")
|
||||
(org-element-property :name (org-element-at-point))))))
|
||||
(org-element-property :name (org-element-at-point)))))
|
||||
;; Headlines cannot have affiliated keywords.
|
||||
(should
|
||||
(org-test-with-temp-text "<point>#+name: foo\n* Heading"
|
||||
(org-element-type-p (org-element-at-point) 'keyword)))
|
||||
;; Clocks cannot have affiliated keywords.
|
||||
(should
|
||||
(org-test-with-temp-text "<point>#+name: foo
|
||||
CLOCK: [2023-10-13 Fri 14:40]--[2023-10-13 Fri 14:51] => 0:11"
|
||||
(org-element-type-p (org-element-at-point) 'keyword)))
|
||||
;; Inlinetasks cannot have affiliated keywords.
|
||||
(should
|
||||
(let ((org-inlinetask-min-level 4))
|
||||
(org-test-with-temp-text "<point>#+name: foo
|
||||
**** Inlinetask"
|
||||
(org-element-type-p (org-element-at-point) 'keyword)))))
|
||||
|
||||
|
||||
;;;; Babel Call
|
||||
|
|
Loading…
Reference in a new issue