org-element: Fix error when parsing lowercase keywords

* lisp/org-element.el (org-element-context): Fix error when parsing
  affiliated keywords, e.g. "caption".
* testing/lisp/test-org-element.el: Add test.
This commit is contained in:
Nicolas Goaziou 2013-11-03 17:47:55 +01:00
parent d61ce8edd1
commit 757f00811d
2 changed files with 8 additions and 2 deletions

View File

@ -4856,9 +4856,10 @@ Providing it allows for quicker computation."
((let ((post (org-element-property :post-affiliated element)))
(and post (< origin post)))
(beginning-of-line)
(looking-at org-element--affiliated-re)
(let ((case-fold-search t)) (looking-at org-element--affiliated-re))
(cond
((not (member (upcase (match-string 1)) org-element-parsed-keywords))
((not (member-ignore-case (match-string 1)
org-element-parsed-keywords))
(throw 'objects-forbidden element))
((< (match-end 0) origin)
(narrow-to-region (match-end 0) (line-end-position)))

View File

@ -2961,6 +2961,11 @@ Paragraph \\alpha."
(org-test-with-temp-text "#+CAPTION: {{{macro}}}\n| a | b |."
(progn (search-forward "{")
(org-element-type (org-element-context))))))
(should
(eq 'bold
(org-test-with-temp-text "#+caption: *bold*\nParagraph"
(progn (search-forward "*")
(org-element-type (org-element-context))))))
;; Correctly set `:parent' property.
(should
(eq 'paragraph