emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] How to add results to text inline?
@ 2011-02-23  5:55 Torsten Wagner
  2011-02-23  7:53 ` Andreas Leha
  0 siblings, 1 reply; 5+ messages in thread
From: Torsten Wagner @ 2011-02-23  5:55 UTC (permalink / raw)
  To: Emacs-orgmode

Hi,

guess this is a FAQ or at least a stupid question.
However, I read along worg and wasn't able to find a solution.

I would like to add the result of a source code block in some text 
paragraph.

---start--mini-example----

#+source:my_formula(my_parameter='1')
#+begin_src python :results value :exports code
y = 2
f = my_parameter * y
return f
#+end_src

In my long long paragraph after that I want to say that
my result is #+call: my_formula(my_parameter='5') for x=5 but it is
#+call: my_formula() for x=1

---end--mini-example----

Well I would replace the calls by the result of the source code block
I read about no-web but this seems to work only within code blocks. I 
read about inline source code blocks, however, more complex functions 
would make it difficult to read.

Thanks for pointing me to obvious solutions ;)

Torsten

CC. How about some C-like format string for number results like
#+call: my_formula(my_parameter='5') :exports results :format %i5
results in integer 5 digits
00010
and  #+call: my_formula(my_parameter='5') :exports results :format %s.3
could result in scientific notation with 3 digits after the comma
1.000*10^1

This would allow to format the result to the needs just in place.

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

* Re: [babel] How to add results to text inline?
  2011-02-23  5:55 [babel] How to add results to text inline? Torsten Wagner
@ 2011-02-23  7:53 ` Andreas Leha
  2011-02-23  8:14   ` Torsten Wagner
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Leha @ 2011-02-23  7:53 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1766 bytes --]

Hi Torsten,

Have a look at the 'src_<language>{<body>}' construct as described here:
http://orgmode.org/org.html#Structure-of-code-blocks

Hth,
Andreas


Am 23.02.2011 06:55, schrieb Torsten Wagner:
> Hi,
>
> guess this is a FAQ or at least a stupid question.
> However, I read along worg and wasn't able to find a solution.
>
> I would like to add the result of a source code block in some text
> paragraph.
>
> ---start--mini-example----
>
> #+source:my_formula(my_parameter='1')
> #+begin_src python :results value :exports code
> y = 2
> f = my_parameter * y
> return f
> #+end_src
>
> In my long long paragraph after that I want to say that
> my result is #+call: my_formula(my_parameter='5') for x=5 but it is
> #+call: my_formula() for x=1
>
> ---end--mini-example----
>
> Well I would replace the calls by the result of the source code block
> I read about no-web but this seems to work only within code blocks. I
> read about inline source code blocks, however, more complex functions
> would make it difficult to read.
>
> Thanks for pointing me to obvious solutions ;)
>
> Torsten
>
> CC. How about some C-like format string for number results like
> #+call: my_formula(my_parameter='5') :exports results :format %i5
> results in integer 5 digits
> 00010
> and  #+call: my_formula(my_parameter='5') :exports results :format %s.3
> could result in scientific notation with 3 digits after the comma
> 1.000*10^1
>
> This would allow to format the result to the needs just in place.
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode



[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 6432 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [babel] How to add results to text inline?
  2011-02-23  7:53 ` Andreas Leha
@ 2011-02-23  8:14   ` Torsten Wagner
  2011-02-23  8:34     ` Andreas Leha
  0 siblings, 1 reply; 5+ messages in thread
From: Torsten Wagner @ 2011-02-23  8:14 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Hi Andreas,

thanks for pointing to that. I guess it is the same like on worg.
As far as I understood this would help me to add the python code inside 
my paragraph which is indeed nice for small code-snippet. However, I 
would like to replace the result of a function call via
#+call aka #+lob aka #+function.

I will try he src_python{print f} and use a session...

However, I thought there might be a 'easier' way ;)

Thanks

Torsten



On 02/23/2011 04:53 PM, Andreas Leha wrote:
> Hi Torsten,
>
> Have a look at the 'src_<language>{<body>}' construct as described here:
> http://orgmode.org/org.html#Structure-of-code-blocks
>
> Hth,
> Andreas
>
>
> Am 23.02.2011 06:55, schrieb Torsten Wagner:
>> Hi,
>>
>> guess this is a FAQ or at least a stupid question.
>> However, I read along worg and wasn't able to find a solution.
>>
>> I would like to add the result of a source code block in some text
>> paragraph.
>>
>> ---start--mini-example----
>>
>> #+source:my_formula(my_parameter='1')
>> #+begin_src python :results value :exports code
>> y = 2
>> f = my_parameter * y
>> return f
>> #+end_src
>>
>> In my long long paragraph after that I want to say that
>> my result is #+call: my_formula(my_parameter='5') for x=5 but it is
>> #+call: my_formula() for x=1
>>
>> ---end--mini-example----
>>
>> Well I would replace the calls by the result of the source code block
>> I read about no-web but this seems to work only within code blocks. I
>> read about inline source code blocks, however, more complex functions
>> would make it difficult to read.
>>
>> Thanks for pointing me to obvious solutions ;)
>>
>> Torsten
>>
>> CC. How about some C-like format string for number results like
>> #+call: my_formula(my_parameter='5') :exports results :format %i5
>> results in integer 5 digits
>> 00010
>> and  #+call: my_formula(my_parameter='5') :exports results :format %s.3
>> could result in scientific notation with 3 digits after the comma
>> 1.000*10^1
>>
>> This would allow to format the result to the needs just in place.
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [babel] How to add results to text inline?
  2011-02-23  8:14   ` Torsten Wagner
@ 2011-02-23  8:34     ` Andreas Leha
  2011-02-23 13:03       ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Leha @ 2011-02-23  8:34 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 3672 bytes --]

Sorry.  I should have read your message properly.

How about:
In my long long paragraph after that I want to say that
my result is  src_python[:noweb yes :results value raw replace :exports
results]{return <<my_formula(my_parameter='5')>>} for x=5.

Regards,
Andreas

Am 23.02.2011 09:14, schrieb Torsten Wagner:
> Hi Andreas,
>
> thanks for pointing to that. I guess it is the same like on worg.
> As far as I understood this would help me to add the python code
> inside my paragraph which is indeed nice for small code-snippet.
> However, I would like to replace the result of a function call via
> #+call aka #+lob aka #+function.
>
> I will try he src_python{print f} and use a session...
>
> However, I thought there might be a 'easier' way ;)
>
> Thanks
>
> Torsten
>
>
>
> On 02/23/2011 04:53 PM, Andreas Leha wrote:
>> Hi Torsten,
>>
>> Have a look at the 'src_<language>{<body>}' construct as described here:
>> http://orgmode.org/org.html#Structure-of-code-blocks
>>
>> Hth,
>> Andreas
>>
>>
>> Am 23.02.2011 06:55, schrieb Torsten Wagner:
>>> Hi,
>>>
>>> guess this is a FAQ or at least a stupid question.
>>> However, I read along worg and wasn't able to find a solution.
>>>
>>> I would like to add the result of a source code block in some text
>>> paragraph.
>>>
>>> ---start--mini-example----
>>>
>>> #+source:my_formula(my_parameter='1')
>>> #+begin_src python :results value :exports code
>>> y = 2
>>> f = my_parameter * y
>>> return f
>>> #+end_src
>>>
>>> In my long long paragraph after that I want to say that
>>> my result is #+call: my_formula(my_parameter='5') for x=5 but it is
>>> #+call: my_formula() for x=1
>>>
>>> ---end--mini-example----
>>>
>>> Well I would replace the calls by the result of the source code block
>>> I read about no-web but this seems to work only within code blocks. I
>>> read about inline source code blocks, however, more complex functions
>>> would make it difficult to read.
>>>
>>> Thanks for pointing me to obvious solutions ;)
>>>
>>> Torsten
>>>
>>> CC. How about some C-like format string for number results like
>>> #+call: my_formula(my_parameter='5') :exports results :format %i5
>>> results in integer 5 digits
>>> 00010
>>> and  #+call: my_formula(my_parameter='5') :exports results :format %s.3
>>> could result in scientific notation with 3 digits after the comma
>>> 1.000*10^1
>>>
>>> This would allow to format the result to the needs just in place.
>>>
>>> _______________________________________________
>>> Emacs-orgmode mailing list
>>> Please use `Reply All' to send replies to the list.
>>> Emacs-orgmode@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>
>>
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

-- 
Andreas Leha

Universitätsmedizin Göttingen
Abteilung Medizinische Statistik
Humboldtallee 32
37073 Göttingen

Tel: +49 (0)551 39-10710
Fax: +49 (0)551 39-4995

http://www.ams.med.uni-goettingen.de/amsneu/leha.html



University Medical Center Göttingen
Department for Medical Statistics
Humboldtallee 32
37073 Göttingen
Germany

Phone: +49 (0) 551 39-10710
Fax: +49 (0) 551 39-4995

http://www.ams.med.uni-goettingen.de/amsneu/leha-en.html



[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 6432 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [babel] How to add results to text inline?
  2011-02-23  8:34     ` Andreas Leha
@ 2011-02-23 13:03       ` Eric Schulte
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Schulte @ 2011-02-23 13:03 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Sorry.  I should have read your message properly.
>
> How about:
> In my long long paragraph after that I want to say that
> my result is  src_python[:noweb yes :results value raw replace :exports
> results]{return <<my_formula(my_parameter='5')>>} for x=5.
>

Also, src_sh[:var it=my_formula(my_parameter=5)]{echo $it} should work.

Best -- Eric

>
> Regards,
> Andreas
>
> Am 23.02.2011 09:14, schrieb Torsten Wagner:
>> Hi Andreas,
>>
>> thanks for pointing to that. I guess it is the same like on worg.
>> As far as I understood this would help me to add the python code
>> inside my paragraph which is indeed nice for small code-snippet.
>> However, I would like to replace the result of a function call via
>> #+call aka #+lob aka #+function.
>>
>> I will try he src_python{print f} and use a session...
>>
>> However, I thought there might be a 'easier' way ;)
>>
>> Thanks
>>
>> Torsten
>>
>>
>>
>> On 02/23/2011 04:53 PM, Andreas Leha wrote:
>>> Hi Torsten,
>>>
>>> Have a look at the 'src_<language>{<body>}' construct as described here:
>>> http://orgmode.org/org.html#Structure-of-code-blocks
>>>
>>> Hth,
>>> Andreas
>>>
>>>
>>> Am 23.02.2011 06:55, schrieb Torsten Wagner:
>>>> Hi,
>>>>
>>>> guess this is a FAQ or at least a stupid question.
>>>> However, I read along worg and wasn't able to find a solution.
>>>>
>>>> I would like to add the result of a source code block in some text
>>>> paragraph.
>>>>
>>>> ---start--mini-example----
>>>>
>>>> #+source:my_formula(my_parameter='1')
>>>> #+begin_src python :results value :exports code
>>>> y = 2
>>>> f = my_parameter * y
>>>> return f
>>>> #+end_src
>>>>
>>>> In my long long paragraph after that I want to say that
>>>> my result is #+call: my_formula(my_parameter='5') for x=5 but it is
>>>> #+call: my_formula() for x=1
>>>>
>>>> ---end--mini-example----
>>>>
>>>> Well I would replace the calls by the result of the source code block
>>>> I read about no-web but this seems to work only within code blocks. I
>>>> read about inline source code blocks, however, more complex functions
>>>> would make it difficult to read.
>>>>
>>>> Thanks for pointing me to obvious solutions ;)
>>>>
>>>> Torsten
>>>>
>>>> CC. How about some C-like format string for number results like
>>>> #+call: my_formula(my_parameter='5') :exports results :format %i5
>>>> results in integer 5 digits
>>>> 00010
>>>> and  #+call: my_formula(my_parameter='5') :exports results :format %s.3
>>>> could result in scientific notation with 3 digits after the comma
>>>> 1.000*10^1
>>>>
>>>> This would allow to format the result to the needs just in place.
>>>>
>>>> _______________________________________________
>>>> Emacs-orgmode mailing list
>>>> Please use `Reply All' to send replies to the list.
>>>> Emacs-orgmode@gnu.org
>>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Emacs-orgmode mailing list
>>> Please use `Reply All' to send replies to the list.
>>> Emacs-orgmode@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2011-02-23 13:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-23  5:55 [babel] How to add results to text inline? Torsten Wagner
2011-02-23  7:53 ` Andreas Leha
2011-02-23  8:14   ` Torsten Wagner
2011-02-23  8:34     ` Andreas Leha
2011-02-23 13:03       ` Eric Schulte

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).