diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-01-31 22:15:15 +0100 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-01-31 22:15:39 +0100 |
commit | 592dc2ee7e4c80b9b61efb77117c8dc22d6cefd1 (patch) | |
tree | 09c77a16edfbd966b0d549f75ea5c37ac1a13239 | |
parent | 4259ea9fe5ace9436a51fddd3734665c2c3f0732 (diff) |
org-element: Fix macro parsing with protected commas7.9.3e
* lisp/org-element.el (org-element-macro-parser): Fix error when last
argument ends with a protected comma.
* testing/lisp/test-org-element.el (test-org-element/macro-parser):
Add tests.
-rw-r--r-- | lisp/org-element.el | 7 | ||||
-rw-r--r-- | testing/lisp/test-org-element.el | 13 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el index f86c3660d..6a0b8eee4 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -2893,10 +2893,13 @@ Assume point is at the macro." (end (point)) (args (let ((args (org-match-string-no-properties 3)) args2) (when args - (setq args (org-split-string args ",")) + ;; Do not use `org-split-string' since empty + ;; strings are meaningful here. + (setq args (split-string args ",")) (while args (while (string-match "\\\\\\'" (car args)) - ;; Repair bad splits. + ;; Repair bad splits, when comma is protected, + ;; and thus not a real separator. (setcar (cdr args) (concat (substring (car args) 0 -1) "," (nth 1 args))) (pop args)) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 97d8533eb..29e1af8cd 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -1207,7 +1207,18 @@ e^{i\\pi}+1=0 ;; With arguments. (should (org-test-with-temp-text "{{{macro(arg1,arg2)}}}" - (org-element-map (org-element-parse-buffer) 'macro 'identity)))) + (org-element-map (org-element-parse-buffer) 'macro 'identity))) + ;; Properly handle protected commas in arguments... + (should + (= 2 + (length + (org-test-with-temp-text "{{{macro(arg1\\,arg1,arg2)}}}" + (org-element-property :args (org-element-context)))))) + ;; ... even when last argument ends with a protected comma. + (should + (equal '("C-,") + (org-test-with-temp-text "{{{macro(C-\\,)}}}" + (org-element-property :args (org-element-context)))))) ;;;; Paragraph |