From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: macros which expand to other macros Date: Thu, 3 Sep 2009 08:50:31 +0200 Message-ID: <0668E2B8-079C-4040-BD9B-ED84523C3A7E@gmail.com> References: <87ab1d6nnl.fsf@gmail.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mj69b-0005W2-Ve for emacs-orgmode@gnu.org; Thu, 03 Sep 2009 02:50:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mj69X-0005Tq-C3 for emacs-orgmode@gnu.org; Thu, 03 Sep 2009 02:50:43 -0400 Received: from [199.232.76.173] (port=40907 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mj69X-0005Tm-2a for emacs-orgmode@gnu.org; Thu, 03 Sep 2009 02:50:39 -0400 Received: from mx20.gnu.org ([199.232.41.8]:12827) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mj69W-0008PU-FV for emacs-orgmode@gnu.org; Thu, 03 Sep 2009 02:50:38 -0400 Received: from mail-ew0-f211.google.com ([209.85.219.211]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mj69V-0004Ta-P0 for emacs-orgmode@gnu.org; Thu, 03 Sep 2009 02:50:38 -0400 Received: by ewy7 with SMTP id 7so280396ewy.31 for ; Wed, 02 Sep 2009 23:50:36 -0700 (PDT) In-Reply-To: <87ab1d6nnl.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Daniel Clemente Cc: org-mode Mailinglist Hi Daniel, I have applied the patch, thanks. I used the more restrictive version =20= without allowing partial macros. Seems a bit wired to me. Or can someone come up with a compelling use case? - Carsten On Sep 2, 2009, at 11:29 PM, Daniel Clemente wrote: > > Hi. > > I want to include a note in several pages, therefore I created a #=20 > +MACRO for it. The macro must say =84This file is best viewed when you = =20 > open file {{{input-file}}} in org-mode (Emacs).=93, where {{{input-=20 > file}}} would be expanded to the name of the file being expanded. > Then I noticed that macros can't expand to other macros. This means: > > #+MACRO: uno 1 > #+MACRO: one {{{uno}}} > {{{uno}}} works (1) but {{{one}}} should also be 1, not {{=85uno}}} > > > I attach a patch [1] which adds support for macros which expand to =20= > other macros, so the previous examples would work. > > It would of course get locked if you wanted macros like #+MACRO: =20 > recu {{{recu}}}, but that's apparently the intended behaviour :-) > > It will even work for macros that create parts of other macros. > > #+MACRO: cc1 100001 > #+MACRO: cc2 100002 > #+MACRO: mycc-start {{{cc > #+MACRO: mycc-end 2}}} > Yes, it is {{{mycc-start}}}{{{mycc-end}}}. > And even: > #+MACRO: mycc {{{mycc-start}}}{{{mycc-end}}} > {{{mycc}}}. > > (100002 in both cases). > If this is too complex, this partial macro writing can be =20 > disallowed by changing the (beginning-of-line) to a (goto-char =20 > (match-beginning 0)). > > > -- Daniel > > > [1] > > diff --git a/lisp/org-exp.el b/lisp/org-exp.el > index 3e12e6a..3d2fad8 100644 > --- a/lisp/org-exp.el > +++ b/lisp/org-exp.el > @@ -2106,7 +2106,7 @@ TYPE must be a string, any of: > (if (and val (not (stringp val))) > (setq val (format "%s" val)))) > (and (stringp val) > - (replace-match val t t)))))) > + (prog1 (replace-match val t t) (beginning-of-line))))))) > > (defun org-export-apply-macros-in-string (s) > "Apply the macros in string S." > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode