emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Another tricky question: accessing named values
@ 2012-09-13 19:02 Neuwirth Erich
  2012-09-14  7:33 ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Neuwirth Erich @ 2012-09-13 19:02 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org emacs-orgmode@gnu.org

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?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Another tricky question: accessing named values
  2012-09-13 19:02 Another tricky question: accessing named values Neuwirth Erich
@ 2012-09-14  7:33 ` Bastien
  2012-09-14  8:52   ` Neuwirth Erich
  0 siblings, 1 reply; 5+ messages in thread
From: Bastien @ 2012-09-14  7:33 UTC (permalink / raw)
  To: Neuwirth Erich; +Cc: emacs-orgmode@gnu.org emacs-orgmode@gnu.org

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Another tricky question: accessing named values
  2012-09-14  7:33 ` Bastien
@ 2012-09-14  8:52   ` Neuwirth Erich
  2012-09-14  9:16     ` Sebastien Vauban
  2012-09-14  9:24     ` Christian Moe
  0 siblings, 2 replies; 5+ messages in thread
From: Neuwirth Erich @ 2012-09-14  8:52 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode@gnu.org emacs-orgmode@gnu.org

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Another tricky question: accessing named values
  2012-09-14  8:52   ` Neuwirth Erich
@ 2012-09-14  9:16     ` Sebastien Vauban
  2012-09-14  9:24     ` Christian Moe
  1 sibling, 0 replies; 5+ messages in thread
From: Sebastien Vauban @ 2012-09-14  9:16 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Another tricky question: accessing named values
  2012-09-14  8:52   ` Neuwirth Erich
  2012-09-14  9:16     ` Sebastien Vauban
@ 2012-09-14  9:24     ` Christian Moe
  1 sibling, 0 replies; 5+ messages in thread
From: Christian Moe @ 2012-09-14  9:24 UTC (permalink / raw)
  To: Neuwirth Erich; +Cc: Bastien, emacs-orgmode@gnu.org emacs-orgmode@gnu.org

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-09-14  9:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-13 19:02 Another tricky question: accessing named values Neuwirth Erich
2012-09-14  7:33 ` Bastien
2012-09-14  8:52   ` Neuwirth Erich
2012-09-14  9:16     ` Sebastien Vauban
2012-09-14  9:24     ` Christian Moe

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).