emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] macro expansion in source code


From: Johannes Rainer
Subject: Re: [O] macro expansion in source code
Date: Thu, 29 Aug 2013 21:22:59 +0200

thanks for that solution! I will give it a try!


On Thu, Aug 29, 2013 at 5:15 PM, Charles Berry <address@hidden> wrote:
Johannes Rainer <johannes.rainer <at> 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 <-
  <<imwide()>>
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:  address@hidden
            address@hidden
URL:   http://bioinfo.i-med.ac.at



reply via email to

[Prev in Thread] Current Thread [Next in Thread]