From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: [RFC] [PATCH] Warn about unexpanded macros on export Date: Fri, 19 Sep 2014 15:12:48 -0400 Message-ID: <87k34zqv9r.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XV3c9-0002Ap-RD for emacs-orgmode@gnu.org; Fri, 19 Sep 2014 15:13:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XV3c0-0002Ph-Pp for emacs-orgmode@gnu.org; Fri, 19 Sep 2014 15:13:05 -0400 Received: from mail-qc0-x230.google.com ([2607:f8b0:400d:c01::230]:62009) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XV3c0-0002P7-Kg for emacs-orgmode@gnu.org; Fri, 19 Sep 2014 15:12:56 -0400 Received: by mail-qc0-f176.google.com with SMTP id x3so3686657qcv.35 for ; Fri, 19 Sep 2014 12:12:50 -0700 (PDT) Received: from localhost (levyvlan538.1887.apn.wlan.wireless-pennnet.upenn.edu. [128.91.183.96]) by mx.google.com with ESMTPSA id w6sm2060403qas.26.2014.09.19.12.12.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Sep 2014 12:12:50 -0700 (PDT) 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: Org-mode --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello all, Currently, if a macro is not defined, it will silently produce an empty string while exporting. This situation could arise for example if a macro name is acidentally mistyped. I think it=E2=80=99s desirable to warn= the user in this case. The attached patch introduces a function to do so, and shows how it would be integrated in the latex backend. This raises several questions: 1. Should the warning be a =E2=80=9Cmessage=E2=80=9D (allows the export pro= cess to continue) or a =E2=80=9Cuser-error=E2=80=9D (stops the export process)? = Or, should this be configurable? 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 b= ackends 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? Thanks, --=20 Aaron Ecay --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-warn-if-unexpanded-macros-are-found-when-exportin.patch >From 1c9f85bcb93dbc56d01b138f5a4a11ad0933b5c6 Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Fri, 19 Sep 2014 14:46:37 -0400 Subject: [PATCH] ox: warn if unexpanded macros are found when exporting * lisp/ox.el (org-export-macro-warn): New function. * lisp/ox-latex.el: Use it. --- lisp/ox-latex.el | 1 + lisp/ox.el | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index f59d6b2..7670ccb 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -65,6 +65,7 @@ (latex-fragment . org-latex-latex-fragment) (line-break . org-latex-line-break) (link . org-latex-link) + (macro . org-export-macro-warn) (node-property . org-latex-node-property) (paragraph . org-latex-paragraph) (plain-list . org-latex-plain-list) diff --git a/lisp/ox.el b/lisp/ox.el index f01f951..a4988f4 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5619,6 +5619,11 @@ to `:default' encoding. If it fails, return S." (plist-get translations :default) s))) +(defun org-export-macro-warn (macro contents info) + ;; TODO: should this be a user-error? + (message "WARNING: undefined macro %s" (org-element-property :key macro)) + ;; Return empty string to avoid interfering with the export output. + "") ;;; Asynchronous Export -- 2.1.0 --=-=-=--