From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johannes Rainer Subject: Re: macro expansion in source code Date: Thu, 29 Aug 2013 21:22:59 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e0160cb10acf4ea04e51b0830 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF7o5-000603-Qm for emacs-orgmode@gnu.org; Thu, 29 Aug 2013 15:23:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VF7o4-0000rz-5z for emacs-orgmode@gnu.org; Thu, 29 Aug 2013 15:23:01 -0400 Received: from mail-vb0-x22c.google.com ([2607:f8b0:400c:c02::22c]:63801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF7o3-0000rt-Vk for emacs-orgmode@gnu.org; Thu, 29 Aug 2013 15:23:00 -0400 Received: by mail-vb0-f44.google.com with SMTP id e13so642242vbg.31 for ; Thu, 29 Aug 2013 12:22:59 -0700 (PDT) In-Reply-To: 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: Charles Berry Cc: emacs-orgmode@gnu.org --089e0160cb10acf4ea04e51b0830 Content-Type: text/plain; charset=ISO-8859-1 thanks for that solution! I will give it a try! On Thu, Aug 29, 2013 at 5:15 PM, Charles Berry wrote: > Johannes Rainer gmail.com> writes: > > > > > > > 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: > > [snip] > > I think the answer is no. But you can accomplish much the same thing with > properties and/or noweb references. Like this > > * header > :PROPERTIES: > :image_width: 16 > :END: > > #+NAME: imwide > #+HEADER: :var iw=(org-entry-get (point) "image_width") > #+BEGIN_SRC R :results value > iw > #+END_SRC > > #+RESULTS: imwide > : 16 > > > #+BEGIN_SRC R :noweb yes :results output > image.width <- > <> > image.width > #+END_SRC > > #+RESULTS: > : [1] 16 > > > > > -- Johannes Rainer, PhD Applied Bioinformatics Group, Division Molecular Pathophysiology, Biocenter, Medical University Innsbruck, Innrain 80/82 II, 6020 Innsbruck, Austria and Tyrolean Cancer Research Institute Innrain 66, 6020 Innsbruck, Austria Tel.: +43 (0)512 9003 70961 Email: johannes.rainer@i-med.ac.at johannes.rainer@tcri.at URL: http://bioinfo.i-med.ac.at --089e0160cb10acf4ea04e51b0830 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
thanks for that solution! I will give it a try!
<= div class=3D"gmail_extra">

On Thu, Aug 29= , 2013 at 5:15 PM, Charles Berry <ccberry@ucsd.edu> wrote:
Johannes Rainer <johann= es.rainer <at> gmail.c= om> writes:

>
>
> hi,
> I was just wondering if there is a way to use macro expansion also in<= br> > 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:

[snip]

I think the answer is no. But you can accomplish much the same thing with properties and/or noweb references. Like this

* header
=A0 :PROPERTIES:
=A0 :image_width: 16
=A0 :END:

#+NAME: imwide
#+HEADER: :var iw=3D(org-entry-get (point) "image_width")
#+BEGIN_SRC R :results value
iw
#+END_SRC

#+RESULTS: imwide
: 16


#+BEGIN_SRC R :noweb yes :results output
image.width <-
=A0 <<imwide()>>
image.width
#+END_SRC

#+RESULTS:
: [1] 16







--
Johannes Rainer, PhDApplied Bioinformatics Group,
Division Molecular Pathophysiology,
Bi= ocenter, Medical University Innsbruck,
Innrain 80/82 II, 6020 Innsbruck,= Austria
and
Tyrolean Cancer Research Institute
Innrain 66, 6020 Innsbruck, Au= stria

Tel.:=A0 =A0=A0 +43 (0)512 9003 70961
Email:=A0 johannes.rainer@i-med= .ac.at
=A0 =A0 =A0 =A0 =A0 =A0 johannes.rainer@tcri.at
URL:=A0=A0 http://bioinfo.i-med.ac.at

<= br> --089e0160cb10acf4ea04e51b0830--