Browse Source

org-element: Fix org-element-context on parsed keywords

* lisp/org-element.el (org-element-context): Fix org-element-context
  on parsed keywords.
* testing/lisp/test-org-element.el: Update test.
Nicolas Goaziou 5 years ago
parent
commit
2e8591783f
2 changed files with 6 additions and 2 deletions
  1. 5 1
      lisp/org-element.el
  2. 1 1
      testing/lisp/test-org-element.el

+ 5 - 1
lisp/org-element.el

@@ -4629,6 +4629,10 @@ and :post-blank properties."
 				(looking-at org-element--affiliated-re)
 				(member (upcase (match-string 1))
 					org-element-parsed-keywords))
+			 ;; We're at an affiliated keyword.  Change
+			 ;; type to retrieve correct restrictions.
+			 (setq type 'keyword)
+			 ;; Determine if we're at main or dual value.
 			 (if (and (match-end 2) (<= origin (match-end 2)))
 			     (progn (goto-char (match-beginning 2))
 				    (setq end (match-end 2)))
@@ -4667,7 +4671,7 @@ and :post-blank properties."
 				     (forward-char)
 				     (setq end (line-end-position))))))))
 	 element
-       (let ((restriction (org-element-restriction element))
+       (let ((restriction (org-element-restriction type))
 	     (parent element)
 	     candidates)
 	 (catch 'exit

+ 1 - 1
testing/lisp/test-org-element.el

@@ -2654,7 +2654,7 @@ Paragraph \\alpha."
   ;; Find objects in parsed affiliated keywords.
   (should
    (eq 'macro
-       (org-test-with-temp-text "#+CAPTION: {{{macro}}}\nParagraph."
+       (org-test-with-temp-text "#+CAPTION: {{{macro}}}\n| a | b |."
 	 (progn (search-forward "{")
 		(org-element-type (org-element-context))))))
   ;; Correctly set `:parent' property.