emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Cook, Malcolm" <MEC@stowers.org>
To: "'Charles C. Berry'" <ccberry@ucsd.edu>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: BUG: emacs orgmode ob-R.el function org-babel-R-evaluate-session over aggressively performs "; ; cleanup extra prompts left in output" and a possible workaround
Date: Mon, 9 Nov 2015 20:04:38 +0000	[thread overview]
Message-ID: <39f0e21eec95434b95514837a7ccb71f@exchsrv2.sgc.loc> (raw)
In-Reply-To: <alpine.OSX.2.20.1511071612320.3906@charles-berrys-macbook.local>


 > -----Original Message-----
 > From: Charles C. Berry [mailto:ccberry@ucsd.edu]
 > Sent: Saturday, November 07, 2015 6:33 PM
 > To: Cook, Malcolm <MEC@stowers.org>
 > Cc: emacs-orgmode@gnu.org
 > Subject: Re: BUG: emacs orgmode ob-R.el function org-babel-R-evaluate-
 > session over aggressively performs "; ; cleanup extra prompts left in output"
 > and a possible workaround
 > 
 > 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'.

Hi Chuck,

Sourcing a textConnection on a :noweb interpolated block will not handle embedded quotes in the source block correctly.  Adding an assignment of a string to a variable in my-block reveals this (i.e. `b<-"asdf"`)

Nor does it extend to my underspecified conception of what :transcript output would be.  I  intended that :transcript would generate a colorized source blocks separated by results for statements which generated visible results.  You implementation makes the source and results undifferentiated.   My mistake for underspecifying my intention.  I think I might be able to cobble what I want using the 'evaluate' package (https://cran.rstudio.com/web/packages/evaluate/evaluate.pdf) with an output handler to format source as an R code block and results as R results block.  Probably not worth the effort.  Or rather, probably already done within the knitr/rmarkdown.

Thanks,

Malcolm

 > 
 > Best,
 > Chuck

  reply	other threads:[~2015-11-09 20:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 19:59 BUG: emacs orgmode ob-R.el function org-babel-R-evaluate-session over aggressively performs "; ; cleanup extra prompts left in output" and a possible workaround Cook, Malcolm
2015-10-01 21:56 ` Charles C. Berry
2015-10-01 23:15   ` Cook, Malcolm
2015-10-08 19:24     ` Charles C. Berry
2015-10-08 20:41       ` Cook, Malcolm
2015-11-05 12:57       ` Nicolas Goaziou
2015-11-06 23:11         ` Charles C. Berry
2015-11-07 21:30         ` Charles C. Berry
2015-11-07 21:41           ` Nicolas Goaziou
2015-11-07 23:22           ` Cook, Malcolm
2015-11-08  0:32             ` Charles C. Berry
2015-11-09 20:04               ` Cook, Malcolm [this message]
2015-11-09 20:56                 ` Charles C. Berry
2015-11-09 22:11                   ` Cook, Malcolm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39f0e21eec95434b95514837a7ccb71f@exchsrv2.sgc.loc \
    --to=mec@stowers.org \
    --cc=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).