summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-10-28 22:43:50 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2012-10-28 22:45:34 +0100
commit98d5666bac8cdaadcb692ba5dabb342641bd2319 (patch)
tree08bc5f36ae087bf9ce676a2e9d1444a02f955d51
parentf6e936c2b9197689afd2b347d381a80612e0b545 (diff)
downloadorg-mode-98d5666bac8cdaadcb692ba5dabb342641bd2319.tar.gz
org-element: Allow duals keywords with only secondary value
* lisp/org-element.el (org-element--collect-affiliated-keywords): Allow duals keywords with only secondary value. * testing/lisp/test-org-element.el: Add test. This patch allows to parse correctly the following: #+CAPTION[short caption]: #+CAPTION: Very long caption Some paragraph.
-rw-r--r--lisp/org-element.el3
-rw-r--r--testing/lisp/test-org-element.el5
2 files changed, 7 insertions, 1 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 44449d5..d03548c 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3822,7 +3822,8 @@ position of point and CDR is nil."
;; Now set final shape for VALUE.
(when parsedp
(setq value (org-element-parse-secondary-string value restrict)))
- (when dualp (setq value (and value (cons value dual-value))))
+ (when dualp
+ (setq value (and (or value dual-value) (cons value dual-value))))
(when (or (member kwd org-element-multiple-keywords)
;; Attributes can always appear on multiple lines.
(string-match "^ATTR_" kwd))
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 768f3d3..20fa76b 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -208,6 +208,11 @@ Some other text
(equal
'((("l2") "s2") (("l1") "s1"))
(org-test-with-temp-text "#+CAPTION[s1]: l1\n#+CAPTION[s2]: l2\nParagraph"
+ (org-element-property :caption (org-element-at-point)))))
+ (should
+ (equal
+ '((("l1")) (nil "s1"))
+ (org-test-with-temp-text "#+CAPTION[s1]:\n#+CAPTION: l1\nParagraph"
(org-element-property :caption (org-element-at-point))))))