From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [RFC] [PATCH] Automatically quote the arguments to an eval macro Date: Thu, 05 Nov 2015 09:40:32 +0100 Message-ID: <874mh0q1of.fsf@nicolasgoaziou.fr> References: <874mh1x2eu.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuG4G-0000Qj-JQ for emacs-orgmode@gnu.org; Thu, 05 Nov 2015 03:38:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuG4F-0007ac-Nc for emacs-orgmode@gnu.org; Thu, 05 Nov 2015 03:38:48 -0500 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:44408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuG4F-0007aS-H2 for emacs-orgmode@gnu.org; Thu, 05 Nov 2015 03:38:47 -0500 Received: from selenimh (unknown [IPv6:2a01:6600:8080:9601::2de]) (Authenticated sender: mail@nicolasgoaziou.fr) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 6DD29172067 for ; Thu, 5 Nov 2015 09:38:46 +0100 (CET) In-Reply-To: <874mh1x2eu.fsf@gmail.com> (Aaron Ecay's message of "Wed, 04 Nov 2015 14:30:33 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: orgmode Hello, Aaron Ecay 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=E2=80=99s 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, --=20 Nicolas Goaziou