From a879760d52cdaa235dcb3ef3ee601643ae8d4fe2 Mon Sep 17 00:00:00 2001 From: chasberry Date: Sun, 18 Jan 2015 16:27:31 -0800 Subject: [PATCH 5/5] org-macro.el: Implement an `identity' macro * lisp/org-macro.el (org-macro-expand): The "as-is" template returns the macro element :value stripped of the leading "{{{(" and the trailing "[\n]?)}}}". The template allows macros that mark text - possibly including commas - but do not modify it. --- lisp/org-macro.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/org-macro.el b/lisp/org-macro.el index 923e377..8e8614b 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -150,10 +150,15 @@ default value. Return nil if no template was found." "")) template nil 'literal))) ;; VALUE starts with "(eval": it is a s-exp, `eval' it. - (when (string-match "\\`(eval\\>" value) + (cond + ((string-match "\\`(eval\\>" value) (setq value (eval (read value)))) + ((string= "as-is" value) + (setq value (replace-regexp-in-string + "^{{{[[:alpha:]]+(\\(.*\\)\n?)}}}$" "\\1" + (org-element-property :value macro))))) ;; Return string. - (format "%s" (or value "")))))) + (format "%s" (or value "")))))) (defun org-macro-replace-all (templates &optional finalize) "Replace all macros in current buffer by their expansion. -- 1.9.3 (Apple Git-50)