From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [RFC] [PATCH] Warn about unexpanded macros on export Date: Sun, 28 Sep 2014 08:59:08 +0200 Message-ID: <874mvsxmbn.fsf@nicolasgoaziou.fr> References: <87k34zqv9r.fsf@gmail.com> <87bnqbv27b.fsf@nicolasgoaziou.fr> <87fvfjow6p.fsf@gmail.com> <87lhpaf5lq.fsf@nicolasgoaziou.fr> <8738bcmme5.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XY8RL-0003Qk-SX for emacs-orgmode@gnu.org; Sun, 28 Sep 2014 02:58:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XY8RB-00065R-MF for emacs-orgmode@gnu.org; Sun, 28 Sep 2014 02:58:39 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:54155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XY8RB-00062r-G8 for emacs-orgmode@gnu.org; Sun, 28 Sep 2014 02:58:29 -0400 Received: from mfilter16-d.gandi.net (mfilter16-d.gandi.net [217.70.178.144]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 454F1A80B0 for ; Sun, 28 Sep 2014 08:58:23 +0200 (CEST) Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by mfilter16-d.gandi.net (mfilter16-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 8jZvLVXwsbpI for ; Sun, 28 Sep 2014 08:58:21 +0200 (CEST) Received: from selenimh (unknown [91.224.148.150]) (Authenticated sender: mail@nicolasgoaziou.fr) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id D1D14A80AF for ; Sun, 28 Sep 2014 08:58:21 +0200 (CEST) In-Reply-To: <8738bcmme5.fsf@gmail.com> (Aaron Ecay's message of "Sat, 27 Sep 2014 23:53:06 -0400") 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 Hello, Aaron Ecay writes: > Attached is a revised patch. WDYT? Looks good. Some small comments follow. > + (if value > + (progn > + (push signature record) > + (delete-region > + begin > + ;; Preserve white spaces after the macro. > + (progn (goto-char (org-element-property :end object)) > + (skip-chars-backward " \t") > + (point))) > + ;; Leave point before replacement in case of recursive > + ;; expansions. > + (save-excursion (insert value))) > + (when finalize > + (error "Macro %s was undefined at line %s" > + (org-element-property :key object) > + (line-number-at-pos)))))))))))) Nitpick: I find the following more readable (cond (value (push signature record) ...) (finalize (error ...))) Also, don't provide error line as macro are replaced after include keywords are expanded. IOW, in some cases, the line number will be misleading. The key is sufficient, e.g., (error "Undefined Org macro: %s. Aborting" (org-element-property :key object)) You can commit it once this is fixed. Thank you for the patch. Regards, -- Nicolas Goaziou