Hello,

Aaron Ecay <aarone...@gmail.com> writes:

> Currently, eval macros need to quote their arguments:
>
> #+macro: identity (eval "$1")
>
> This means:
> 1. Users need to remember to put quotes around $n all the time
> 2. It’s impossible to pass arguments with a " character to a macro

This can be fixed by removing the `literal' optional argument from
`replace-regexp-in-string' call in `org-macro-expand'.

> The attached patch changes the behavior of eval macro arguments so that
> $1 etc. expand to the argument with quotation marks.  That is, the
> following is now the correct way to write a macro (note lack of "s):
>
> #+macro: identity (eval $1)

I'm not totally opposed to it but it introduces a limitation: all
arguments must be strings. This is not strictly required, actually. As
a consequence, I slightly prefer fixing the current situation instead.

Is there any strong reason to force string?

> * lisp/org-macro.el (org-macro-expand): Automatically quote the
> arguments to an eval macro.

You would also need to update `org-macro-initialize-templates' and
`org-export-as'.

> +                     (cond
> +                      (evalp (format "%S" arg-val))
> +                      (arg-val arg-val)

Nitpick: this is equivalent to (arg-val)


Regards,

-- 
Nicolas Goaziou

Reply via email to