From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Cook, Malcolm" 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 Message-ID: <39f0e21eec95434b95514837a7ccb71f@exchsrv2.sgc.loc> References: <2a1b8832412e49b7a0a4d231c3e289cf@exchsrv2.sgc.loc> <87mvusob7j.fsf@nicolasgoaziou.fr>, <3333fb4a-6541-4b80-b1b4-e7f6ff80ee83@email.android.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvsgG-0000mC-RU for emacs-orgmode@gnu.org; Mon, 09 Nov 2015 15:04:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvsgD-0001vW-LS for emacs-orgmode@gnu.org; Mon, 09 Nov 2015 15:04:44 -0500 Received: from smtp01.stowers.org ([40.141.174.61]:33212) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvsgD-0001vQ-EK for emacs-orgmode@gnu.org; Mon, 09 Nov 2015 15:04:41 -0500 In-Reply-To: Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "'Charles C. Berry'" Cc: "emacs-orgmode@gnu.org" > -----Original Message----- > From: Charles C. Berry [mailto:ccberry@ucsd.edu] > Sent: Saturday, November 07, 2015 6:33 PM > To: Cook, Malcolm > 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 ou= tput" > and a possible workaround >=20 > On Sat, 7 Nov 2015, Cook, Malcolm wrote: >=20 > > 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 wit= h > > visible results echoed into the transcript. >=20 > You can do stuff like this using babel and some R code. >=20 > Here is a start: >=20 > --8<---------------cut here---------------start------------->8--- > #+NAME: my-block > #+BEGIN_SRC R :eval no > ls() > a <- 1 > sqrt(a+2) > ls() > #+END_SRC >=20 >=20 > #+BEGIN_SRC R :session :noweb yes :results value raw :wrap example > capture.output( > source(textConnection(" > <> > "), > echo=3DT,print=3DT)) > #+END_SRC >=20 > #+RESULTS: > #+BEGIN_example >=20 > > ls() > [1] "a" >=20 > > a <- 1 >=20 > > sqrt(a+2) > [1] 1.732051 >=20 > > ls() > [1] "a" > #+END_example >=20 >=20 > --8<---------------cut here---------------end--------------->8--- >=20 > I suppose you would want `:exports results'. Hi Chuck, Sourcing a textConnection on a :noweb interpolated block will not handle em= bedded quotes in the source block correctly. Adding an assignment of a str= ing to a variable in my-block reveals this (i.e. `b<-"asdf"`) Nor does it extend to my underspecified conception of what :transcript outp= ut would be. I intended that :transcript would generate a colorized sourc= e blocks separated by results for statements which generated visible result= s. You implementation makes the source and results undifferentiated. My = mistake for underspecifying my intention. I think I might be able to cobbl= e what I want using the 'evaluate' package (https://cran.rstudio.com/web/pa= ckages/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 effor= t. Or rather, probably already done within the knitr/rmarkdown. Thanks, Malcolm >=20 > Best, > Chuck