On Sat, 7 Nov 2015, Cook, Malcolm wrote:

Thanks Chuck for setting this through.

[...]

I've wondered if there is not a better way for Babel to share an interactive session with the user. For instance, if we wanted to support a new form of results processing on addition to value and output.... Namely, "transcript", wherein the results of evaluating a source block would be a transcript of the season with statements interwoven with their respective outputs.... I suspect that this would not be easy extension of the current approach since it would require parsing the source into statements that get evaluated sequentially with visible results echoed into the transcript.

You can do stuff like this using babel and some R code.

Here is a start:

--8<---------------cut here---------------start------------->8---
#+NAME: my-block
#+BEGIN_SRC R :eval no
ls()
a <- 1
sqrt(a+2)
ls()
#+END_SRC


#+BEGIN_SRC R :session :noweb yes :results value raw :wrap example
        capture.output(
            source(textConnection("
  <<my-block>>
  "),
  echo=T,print=T))
#+END_SRC

#+RESULTS:
#+BEGIN_example

ls()
[1] "a"

a <- 1

sqrt(a+2)
[1] 1.732051

ls()
[1] "a"
#+END_example


--8<---------------cut here---------------end--------------->8---

I suppose you would want `:exports results'.

Best,
Chuck

Reply via email to