From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Rettke Subject: Re: [RFC] [PATCH] Warn about unexpanded macros on export Date: Tue, 23 Sep 2014 11:59:49 -0500 Message-ID: References: <87k34zqv9r.fsf@gmail.com> <87bnqbv27b.fsf@nicolasgoaziou.fr> <87fvfjow6p.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]:53219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWTRZ-0001Pr-8N for emacs-orgmode@gnu.org; Tue, 23 Sep 2014 13:00:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWTRW-0004Nl-Uh for emacs-orgmode@gnu.org; Tue, 23 Sep 2014 13:00:01 -0400 Received: from mail-oa0-x22a.google.com ([2607:f8b0:4003:c02::22a]:56530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWTRW-0004NJ-Ok for emacs-orgmode@gnu.org; Tue, 23 Sep 2014 12:59:58 -0400 Received: by mail-oa0-f42.google.com with SMTP id i7so3641001oag.29 for ; Tue, 23 Sep 2014 09:59:49 -0700 (PDT) In-Reply-To: <87fvfjow6p.fsf@gmail.com> 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: Nicolas Goaziou , Org-mode Aaron may I trouble you to add a flag so that if such errors occur then the export fails? >From my perspective, if the document doesn't "compile", then nothing should succeed. Compile includes export from my perspective. On Mon, Sep 22, 2014 at 10:25 PM, Aaron Ecay wrote: > Hi Nicolas, > > 2014ko irailak 19an, Nicolas Goaziou-ek idatzi zuen: >> >> Certainly not a message, due to asynchronous export. > > Very good point. > >> >>> 2. Since this is a feature that many backends will want to use, should >>> we introduce a new =E2=80=9Cabstract=E2=80=9D backend from which other = backends can >>> inherit, which incorporates this feature, and others like it in the >>> future? The idea would be similar to prog-mode in emacs, the major >>> mode from which programming-language modes can derive. The >>> alternative is adding the (macro . org-export-macro-warn) entry >>> manually to all the relevant backends, and relying on future backend >>> authors to do the same. >>> >>> 3. Should this even be implemented as part of the backend=E2=80=99s >>> translate-alist, or at a lower level? >> >> Don't bother with export back-ends, they never get to see macros, which >> are expanded very early in the export process. This explains, for >> example, why there is no `macro' translator. > > Um...but the patch I sent works precisely by defining a macro translator, > which does get called for any unexpanded (because undefined) macros. I > guess you=E2=80=99re saying the code ought to block this at a lower/earli= er level. > >> >> You have two options. Either report an error, as you suggested, or >> insert an obnoxious message in the output, e.g., "UNKNOWN MACRO", =C3=A0= la >> "DEFINITION NOT FOUND." for footnote definitions. In any case, this >> should happen in "org-macro.el", not in the export framework. > > I think error is better than obnoxious message, because it=E2=80=99s poss= ible > for the latter to slip through into a =E2=80=9Cproduction=E2=80=9D docume= nt. (We ought > to proofread our documents carefully, of course...but no one=E2=80=99s pe= rfect). > > One issue is that the exporter does two macro expansion passes =E2=80=93 = one > for garden-variety macros, and the second for author, date, email, and > title. So, we can=E2=80=99t make the macro expansion unconditionally bar= f on > undefined macros (since for the first pass e.g. author is undefined). > I see three options: > 1. explicitly whitelist the few =E2=80=9Cblessed=E2=80=9D macros like aut= hor, and error > on any other undefined macro > 2. add an optional =E2=80=9Cfinal=E2=80=9D arg to org-macro-replace-all, = which will > activate the undefined checking only if non-nil, and pass this flag > in the exporter=E2=80=99s second (and last) call to org-macro-replace-= all > 3. in =E2=80=98org-export-as=E2=80=99, manually walk the parse tree after= expanding > macros, and make sure no 'macro type objects are left > > WDYT? > > -- > Aaron Ecay > --=20 Grant Rettke gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/ =E2=80=9CWisdom begins in wonder.=E2=80=9D --Socrates ((=CE=BB (x) (x x)) (=CE=BB (x) (x x))) =E2=80=9CLife has become immeasurably better since I have been forced to st= op taking it seriously.=E2=80=9D --Thompson