diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-01-29 15:17:37 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-01-29 15:17:37 +0100 |
commit | 04bf4189221114c9cc8f996d47108cd89660d92b (patch) | |
tree | c7f60b24fa47d4a49b23bf568f10951a4be0af71 | |
parent | 55e8c6f9c3d19fe290f4f6102b57396ccc19581f (diff) | |
download | org-mode-04bf4189221114c9cc8f996d47108cd89660d92b.tar.gz |
org-element: Ignore contiguous spaces in macro arguments
* lisp/org-element.el (org-element-macro-parser): Ignore
non-meaningful spaces (e.g., indentation).
(org-element-macro-interpreter): Do not interpret macro from its raw
value. Instead, build it again from its parsed contents.
-rw-r--r-- | lisp/org-element.el | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el index 3e56ce4..6bd0091 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -3247,15 +3247,18 @@ a plist with `:key', `:args', `:begin', `:end', `:value' and Assume point is at the macro." (save-excursion - (when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\(([ \t\n]*\\([^\000]*?\\))\\)?}}}") + (when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\((\\([^\000]*?\\))\\)?}}}") (let ((begin (point)) (key (downcase (match-string-no-properties 1))) (value (match-string-no-properties 0)) (post-blank (progn (goto-char (match-end 0)) (skip-chars-forward " \t"))) (end (point)) - (args (let ((args (match-string-no-properties 3))) - (and args (org-macro-extract-arguments args))))) + (args (pcase (match-string-no-properties 3) + (`nil nil) + (a (org-macro-extract-arguments + (replace-regexp-in-string + "[ \t\r\n]+" " " (org-trim a))))))) (list 'macro (list :key key :value value @@ -3266,7 +3269,11 @@ Assume point is at the macro." (defun org-element-macro-interpreter (macro _) "Interpret MACRO object as Org syntax." - (org-element-property :value macro)) + (format "{{{%s%s}}}" + (org-element-property :key macro) + (pcase (org-element-property :args macro) + (`nil "") + (args (format "(%s)" (apply #'org-macro-escape-arguments args)))))) ;;;; Radio-target |