emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Babel: interweaving code and results?
@ 2010-08-18 13:09 David Hajage
  2010-08-18 13:15 ` Erik Iverson
  0 siblings, 1 reply; 7+ messages in thread
From: David Hajage @ 2010-08-18 13:09 UTC (permalink / raw)
  To: emacs-orgmode


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

Hello,

I am back with babel and R with a new question. Is it possible to
interweave each line of code with its results?

An example to explain what I mean:

#+SRCNAME: foo
#+BEGIN_SRC R :results output :exports results
  2+2
  3+3
#+END_SRC

#+results: foo
: [1] 4
: [1] 6

When exporting (to html or latex), I would like to print what is going on in
the R console. So, I would like:

#+results: foo
:> 2+2
: [1] 4
:> 3+3
: [1] 6

Is it possible, or eventualy planned for the futur?

Thank you very much.
David

[-- Attachment #1.2: Type: text/html, Size: 3229 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] 7+ messages in thread

* Re: Babel: interweaving code and results?
  2010-08-18 13:09 Babel: interweaving code and results? David Hajage
@ 2010-08-18 13:15 ` Erik Iverson
  2010-08-18 13:28   ` David Hajage
  2010-08-18 14:49   ` Dan Davison
  0 siblings, 2 replies; 7+ messages in thread
From: Erik Iverson @ 2010-08-18 13:15 UTC (permalink / raw)
  To: David Hajage; +Cc: emacs-orgmode

David,

On 08/18/2010 08:09 AM, David Hajage wrote:
> Hello,
>
> I am back with babel and R with a new question. Is it possible to
> interweave each line of code with its results?
>
> An example to explain what I mean:
>
> #+SRCNAME: foo
> #+BEGIN_SRC R :results output :exports results
>    2+2
>    3+3
> #+END_SRC
>
> #+results: foo
> : [1] 4
> : [1] 6
>
> When exporting (to html or latex), I would like to print what is going
> on in the R console. So, I would like:
>
> #+results: foo
> :> 2+2
> : [1] 4
> :> 3+3
> : [1] 6
>
> Is it possible, or eventualy planned for the futur?

I think I put together a :results weave option a couple
months ago that did just this.

I'll have to look if I can find it, I'll
let you know.

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

* Re: Babel: interweaving code and results?
  2010-08-18 13:15 ` Erik Iverson
@ 2010-08-18 13:28   ` David Hajage
  2010-08-18 14:49   ` Dan Davison
  1 sibling, 0 replies; 7+ messages in thread
From: David Hajage @ 2010-08-18 13:28 UTC (permalink / raw)
  To: Erik Iverson; +Cc: emacs-orgmode


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

Thanks!
David


On Wed, Aug 18, 2010 at 15:15, Erik Iverson <eriki@ccbr.umn.edu> wrote:

> David,
>
>
> On 08/18/2010 08:09 AM, David Hajage wrote:
>
>> Hello,
>>
>> I am back with babel and R with a new question. Is it possible to
>> interweave each line of code with its results?
>>
>> An example to explain what I mean:
>>
>> #+SRCNAME: foo
>> #+BEGIN_SRC R :results output :exports results
>>   2+2
>>   3+3
>> #+END_SRC
>>
>> #+results: foo
>> : [1] 4
>> : [1] 6
>>
>> When exporting (to html or latex), I would like to print what is going
>> on in the R console. So, I would like:
>>
>> #+results: foo
>> :> 2+2
>> : [1] 4
>> :> 3+3
>> : [1] 6
>>
>> Is it possible, or eventualy planned for the futur?
>>
>
> I think I put together a :results weave option a couple
> months ago that did just this.
>
> I'll have to look if I can find it, I'll
> let you know.
>

[-- Attachment #1.2: Type: text/html, Size: 1382 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] 7+ messages in thread

* Re: Babel: interweaving code and results?
  2010-08-18 13:15 ` Erik Iverson
  2010-08-18 13:28   ` David Hajage
@ 2010-08-18 14:49   ` Dan Davison
  2010-08-18 14:57     ` David Hajage
  2010-08-18 15:03     ` Erik Iverson
  1 sibling, 2 replies; 7+ messages in thread
From: Dan Davison @ 2010-08-18 14:49 UTC (permalink / raw)
  To: Erik Iverson; +Cc: David Hajage, emacs-orgmode

Erik Iverson <eriki@ccbr.umn.edu> writes:

> David,
>
> On 08/18/2010 08:09 AM, David Hajage wrote:
>> Hello,
>>
>> I am back with babel and R with a new question. Is it possible to
>> interweave each line of code with its results?
>>
>> An example to explain what I mean:
>>
>> #+SRCNAME: foo
>> #+BEGIN_SRC R :results output :exports results
>>    2+2
>>    3+3
>> #+END_SRC
>>
>> #+results: foo
>> : [1] 4
>> : [1] 6
>>
>> When exporting (to html or latex), I would like to print what is going
>> on in the R console. So, I would like:
>>
>> #+results: foo
>> :> 2+2
>> : [1] 4
>> :> 3+3
>> : [1] 6
>>
>> Is it possible, or eventualy planned for the futur?

Hi David,

This is actually quite easy, although I don't think anyone's flagged
this possibility up: just do

(setq org-babel-R-command "R --silent --no-save")

(Our default is --slave --no-save) There's an example session below. By
the way, can I just check that you're aware of the ':exports both'
option? That's the canonical Org way of exporting both code and
results. It doesn't interleave them: it's more geared towards 'one code
block <-> one result'. But I understand that there may be situations
where interleaved is desired.

Erik -- You might well be right that we should add an :interleave option
to modify :results output like this.

--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp
org-babel-R-command
#+end_src

#+results:
: R --slave --no-save

#+begin_src R :results output
2+2
3+3
#+end_src

#+results:
: [1] 4
: [1] 6

#+begin_src emacs-lisp
(setq org-babel-R-command "R --silent --no-save")
#+end_src

#+results:
: R --silent --no-save

#+begin_src R :results output
2+2
3+3
#+end_src

#+results:
: > 2+2
: [1] 4
: > 3+3
: [1] 6
: > 
--8<---------------cut here---------------end--------------->8---

[Maybe we can battle that trailing prompt character]

Dan

>
> I think I put together a :results weave option a couple
> months ago that did just this.
>
> I'll have to look if I can find it, I'll
> let you know.
>
> _______________________________________________
> 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] 7+ messages in thread

* Re: Babel: interweaving code and results?
  2010-08-18 14:49   ` Dan Davison
@ 2010-08-18 14:57     ` David Hajage
  2010-08-18 16:07       ` Dan Davison
  2010-08-18 15:03     ` Erik Iverson
  1 sibling, 1 reply; 7+ messages in thread
From: David Hajage @ 2010-08-18 14:57 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode


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

exactly what I want! But an new option would be greater...

Yes, I know about :exports both, but if code and results are interleaved, I
don't need to export the code (in my case). That's why I use :exports
results.

Thank you very much for this.

David


On Wed, Aug 18, 2010 at 16:49, Dan Davison <davison@stats.ox.ac.uk> wrote:

> Erik Iverson <eriki@ccbr.umn.edu> writes:
>
> > David,
> >
> > On 08/18/2010 08:09 AM, David Hajage wrote:
> >> Hello,
> >>
> >> I am back with babel and R with a new question. Is it possible to
> >> interweave each line of code with its results?
> >>
> >> An example to explain what I mean:
> >>
> >> #+SRCNAME: foo
> >> #+BEGIN_SRC R :results output :exports results
> >>    2+2
> >>    3+3
> >> #+END_SRC
> >>
> >> #+results: foo
> >> : [1] 4
> >> : [1] 6
> >>
> >> When exporting (to html or latex), I would like to print what is going
> >> on in the R console. So, I would like:
> >>
> >> #+results: foo
> >> :> 2+2
> >> : [1] 4
> >> :> 3+3
> >> : [1] 6
> >>
> >> Is it possible, or eventualy planned for the futur?
>
> Hi David,
>
> This is actually quite easy, although I don't think anyone's flagged
> this possibility up: just do
>
> (setq org-babel-R-command "R --silent --no-save")
>
> (Our default is --slave --no-save) There's an example session below. By
> the way, can I just check that you're aware of the ':exports both'
> option? That's the canonical Org way of exporting both code and
> results. It doesn't interleave them: it's more geared towards 'one code
> block <-> one result'. But I understand that there may be situations
> where interleaved is desired.
>
> Erik -- You might well be right that we should add an :interleave option
> to modify :results output like this.
>
> --8<---------------cut here---------------start------------->8---
> #+begin_src emacs-lisp
> org-babel-R-command
> #+end_src
>
> #+results:
> : R --slave --no-save
>
> #+begin_src R :results output
> 2+2
> 3+3
> #+end_src
>
> #+results:
> : [1] 4
> : [1] 6
>
> #+begin_src emacs-lisp
> (setq org-babel-R-command "R --silent --no-save")
> #+end_src
>
> #+results:
> : R --silent --no-save
>
> #+begin_src R :results output
> 2+2
> 3+3
> #+end_src
>
> #+results:
> : > 2+2
> : [1] 4
> : > 3+3
> : [1] 6
> : >
> --8<---------------cut here---------------end--------------->8---
>
> [Maybe we can battle that trailing prompt character]
>
> Dan
>
> >
> > I think I put together a :results weave option a couple
> > months ago that did just this.
> >
> > I'll have to look if I can find it, I'll
> > let you know.
> >
> > _______________________________________________
> > 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: Type: text/html, Size: 3974 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] 7+ messages in thread

* Re: Babel: interweaving code and results?
  2010-08-18 14:49   ` Dan Davison
  2010-08-18 14:57     ` David Hajage
@ 2010-08-18 15:03     ` Erik Iverson
  1 sibling, 0 replies; 7+ messages in thread
From: Erik Iverson @ 2010-08-18 15:03 UTC (permalink / raw)
  To: Dan Davison; +Cc: David Hajage, emacs-orgmode



Dan Davison wrote:
> Erik Iverson <eriki@ccbr.umn.edu> writes:
> 
>> David,
>>
>> On 08/18/2010 08:09 AM, David Hajage wrote:
>>> Hello,
>>>
>>> I am back with babel and R with a new question. Is it possible to
>>> interweave each line of code with its results?
>>>
>>> An example to explain what I mean:
>>>
>>> #+SRCNAME: foo
>>> #+BEGIN_SRC R :results output :exports results
>>>    2+2
>>>    3+3
>>> #+END_SRC
>>>
>>> #+results: foo
>>> : [1] 4
>>> : [1] 6
>>>
>>> When exporting (to html or latex), I would like to print what is going
>>> on in the R console. So, I would like:
>>>
>>> #+results: foo
>>> :> 2+2
>>> : [1] 4
>>> :> 3+3
>>> : [1] 6
>>>
>>> Is it possible, or eventualy planned for the futur?
> 
> Hi David,
> 
> This is actually quite easy, although I don't think anyone's flagged
> this possibility up: just do
> 
> (setq org-babel-R-command "R --silent --no-save")

Yes, that's essentially what I ended up doing it appears. I
never actually wrote code to process an option for it though.

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

* Re: Babel: interweaving code and results?
  2010-08-18 14:57     ` David Hajage
@ 2010-08-18 16:07       ` Dan Davison
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Davison @ 2010-08-18 16:07 UTC (permalink / raw)
  To: David Hajage; +Cc: emacs-orgmode

David Hajage <dhajage@gmail.com> writes:

> exactly what I want! But an new option would be greater...

It wouldn't be hard to add an ":interleave" (or ":echo") option that has
this effect for external R processes. But we should really address a
couple of other issues:

- implementation for :session

  (in principle sounds not hard, as it involves *not* doing something
  (i.e. not removing commands from comint output)).

- implementation for other external interpreter processes

  If anyone has instructions for other interpreters then that would
  help. For bash, it's somewhat similar to 'bash -x'. I looked at man
  python and didn't see anything; perhaps it is accomplished by
  modifying the output stream when python is running rather than as a
  command line option to the interpreter. ruby? etc.

Dan

>
> Yes, I know about :exports both, but if code and results are interleaved, I
> don't need to export the code (in my case). That's why I use :exports
> results.
>
> Thank you very much for this.
>
> David
>
>
> On Wed, Aug 18, 2010 at 16:49, Dan Davison <davison@stats.ox.ac.uk> wrote:
>
>> Erik Iverson <eriki@ccbr.umn.edu> writes:
>>
>> > David,
>> >
>> > On 08/18/2010 08:09 AM, David Hajage wrote:
>> >> Hello,
>> >>
>> >> I am back with babel and R with a new question. Is it possible to
>> >> interweave each line of code with its results?
>> >>
>> >> An example to explain what I mean:
>> >>
>> >> #+SRCNAME: foo
>> >> #+BEGIN_SRC R :results output :exports results
>> >>    2+2
>> >>    3+3
>> >> #+END_SRC
>> >>
>> >> #+results: foo
>> >> : [1] 4
>> >> : [1] 6
>> >>
>> >> When exporting (to html or latex), I would like to print what is going
>> >> on in the R console. So, I would like:
>> >>
>> >> #+results: foo
>> >> :> 2+2
>> >> : [1] 4
>> >> :> 3+3
>> >> : [1] 6
>> >>
>> >> Is it possible, or eventualy planned for the futur?
>>
>> Hi David,
>>
>> This is actually quite easy, although I don't think anyone's flagged
>> this possibility up: just do
>>
>> (setq org-babel-R-command "R --silent --no-save")
>>
>> (Our default is --slave --no-save) There's an example session below. By
>> the way, can I just check that you're aware of the ':exports both'
>> option? That's the canonical Org way of exporting both code and
>> results. It doesn't interleave them: it's more geared towards 'one code
>> block <-> one result'. But I understand that there may be situations
>> where interleaved is desired.
>>
>> Erik -- You might well be right that we should add an :interleave option
>> to modify :results output like this.
>>
>> --8<---------------cut here---------------start------------->8---
>> #+begin_src emacs-lisp
>> org-babel-R-command
>> #+end_src
>>
>> #+results:
>> : R --slave --no-save
>>
>> #+begin_src R :results output
>> 2+2
>> 3+3
>> #+end_src
>>
>> #+results:
>> : [1] 4
>> : [1] 6
>>
>> #+begin_src emacs-lisp
>> (setq org-babel-R-command "R --silent --no-save")
>> #+end_src
>>
>> #+results:
>> : R --silent --no-save
>>
>> #+begin_src R :results output
>> 2+2
>> 3+3
>> #+end_src
>>
>> #+results:
>> : > 2+2
>> : [1] 4
>> : > 3+3
>> : [1] 6
>> : >
>> --8<---------------cut here---------------end--------------->8---
>>
>> [Maybe we can battle that trailing prompt character]
>>
>> Dan
>>
>> >
>> > I think I put together a :results weave option a couple
>> > months ago that did just this.
>> >
>> > I'll have to look if I can find it, I'll
>> > let you know.
>> >
>> > _______________________________________________
>> > 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] 7+ messages in thread

end of thread, other threads:[~2010-08-18 16:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-18 13:09 Babel: interweaving code and results? David Hajage
2010-08-18 13:15 ` Erik Iverson
2010-08-18 13:28   ` David Hajage
2010-08-18 14:49   ` Dan Davison
2010-08-18 14:57     ` David Hajage
2010-08-18 16:07       ` Dan Davison
2010-08-18 15:03     ` Erik Iverson

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