Is there a way of accessing the value of something defined by a #name: statement as part of plain text, of within the definition of a macro?
Hi Erich,
Neuwirth Erich <erich.neuwirth@univie.ac.at> writes:
> Is there a way of accessing the value of something defined by a #name: statement as part of plain text,
> of within the definition of a macro?
This is a bit cryptic to me. Care to give an example?
Thanks,
--
Bastien
Here is an example of what I would like.
#+title: Macro test
Define a name with a value
#+name: myval
#+begin_src elisp :exports both
(+ 1 2)
#+end_src
The named value can be accessed in another code block
#+begin_src elisp :session *elisp* :var myval2=myval :exports both
(setq myval3 myval2)
myval2
#+end_src
I can also (with some trickery as shown above)
use the value in running text: value equals
src_elisp[:session *elisp*]{myval3}
One of the minor annoyances here is that output of the inline src
is always put between equals signs, and in some cases I would like the same
formatting as the surrounding text.
Macros create output without additional formatting.
#+macro: testmac this is plain macro text
Before macro expanded : {{{testmac}}} : after macro expanded
Macros with arguments work nicely:
#+macro: testmacarg the argument is $1
{{{testmacarg(my argument)}}}
I would like to get the value of the name =myval= into the argument of the macro.
I also would like to be able to say something like
=evalorg(myval)=
and get the value of myval into my running text without any
additional formatting.
What I would like to be able to do is put results of computations
into running text. A typical example would be something like
#+BEGIN_QUOTE
As the table above shows we hav 1217 cases in our analysis.
#+END_QUOTE
The number 1217 would come from a named code block, but it should
be typeset as running text, not as code text.
Since macros do the right kind of formatting,
being able to the value of org names in a macro would solve my problem.
On Sep 14, 2012, at 9:33 AM, Bastien <bzg@altern.org> wrote:
> Hi Erich,
>
> Neuwirth Erich <erich.neuwirth@univie.ac.at> writes:
>
>> Is there a way of accessing the value of something defined by a #name: statement as part of plain text,
>> of within the definition of a macro?
>
> This is a bit cryptic to me. Care to give an example?
>
> Thanks,
>
> --
> Bastien
Hi Erich,
Neuwirth Erich wrote:
> I also would like to be able to say something like
>
> =evalorg(myval)=
>
> and get the value of myval into my running text without any
> additional formatting.
For this bit, a call with raw results such as
call_evalorg(myval)[:results raw]
should not have quoted results.
Best regards,
Seb
--
Sebastien Vauban
Hi,
You could just call the named block from inline:
: value equals call_myval()[:results raw]
The `:results raw' argument should take care of the formatting.
No macros needed. But if you want to use macros, e.g. because the call
lines get very long, or you want to add fancy formatting around the
result of each calculation (not what you're looking for here, I
think), you could write a macro to expand to a call_<name>() expression.
Yours,
Christian
On 9/14/12 10:52 AM, Neuwirth Erich wrote:
> Define a name with a value
>
> #+name: myval
> #+begin_src elisp :exports both
> (+ 1 2)
> #+end_src
>
>
> The named value can be accessed in another code block
>
>
> #+begin_src elisp :session*elisp* :var myval2=myval :exports both
> (setq myval3 myval2)
> myval2
> #+end_src
>
>
> I can also (with some trickery as shown above)
> use the value in running text: value equals
> src_elisp[:session*elisp*]{myval3}
>
> One of the minor annoyances here is that output of the inline src
> is always put between equals signs, and in some cases I would like the same
> formatting as the surrounding text.