From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johannes Rainer Subject: macro expansion in source code Date: Thu, 29 Aug 2013 13:52:15 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=20cf307c9f90c1726604e514bce7 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF0lx-0000jM-EE for emacs-orgmode@gnu.org; Thu, 29 Aug 2013 07:52:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VF0ls-0007Vt-JH for emacs-orgmode@gnu.org; Thu, 29 Aug 2013 07:52:21 -0400 Received: from mail-vb0-x231.google.com ([2607:f8b0:400c:c02::231]:60230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF0ls-0007VQ-BI for emacs-orgmode@gnu.org; Thu, 29 Aug 2013 07:52:16 -0400 Received: by mail-vb0-f49.google.com with SMTP id w16so205235vbb.22 for ; Thu, 29 Aug 2013 04:52:15 -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: emacs-orgmode@gnu.org --20cf307c9f90c1726604e514bce7 Content-Type: text/plain; charset=ISO-8859-1 hi, I was just wondering if there is a way to use macro expansion also in source code blocks or headers. I tried this, but the macro was never expanded, but rather the {{{image_width}}} was exported. could the expansion be done by calling the macro expansion before export (e.g. using a hook)? something like this: #+MACRO: image_width 16 #+BEGIN_SRC R :results silent :exports code IMAGE <- "test.png" WIDTH <- {{{image_width}}} HEIGHT <- 6 png( file=IMAGE, width=WIDTH, height=HEIGHT, units="cm", res=600, pointsize=6 ) library( RColorBrewer ) display.brewer.all() dev.off() #+END_SRC or #+BEGIN_SRC R :results file :exports results :width {{{image_width}}} display.brewer.all() #+END_SRC cheers, jo --20cf307c9f90c1726604e514bce7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
hi,

I was just wondering if there is a w= ay to use macro expansion also in source code blocks or headers. I tried th= is, but the macro was never expanded, but rather the {{{image_width}}} was = exported. could the expansion be done by calling the macro expansion before= export (e.g. using a hook)?

something like this:

#+MACRO: image_width 1= 6

#+BEGIN_SRC R :results silent :exports code
=A0 IMAGE <- &qu= ot;test.png"
=A0 WIDTH <- {{{image_width}}}
=A0 HEIGHT <- = 6
=A0 png( file=3DIMAGE, width=3DWIDTH, height=3DHEIGHT, units=3D"cm&quo= t;, res=3D600, pointsize=3D6 )
=A0 library( RColorBrewer )
=A0 displa= y.brewer.all()
=A0 dev.off()
#+END_SRC


or
<= br>#+BEGIN_SRC R :results file :exports results :width {{{image_width}}} =A0 display.brewer.all()
#+END_SRC


cheers, jo
<= /div>

--20cf307c9f90c1726604e514bce7--