emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 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
@ 2015-10-01 19:59 Cook, Malcolm
  2015-10-01 21:56 ` Charles C. Berry
  0 siblings, 1 reply; 14+ messages in thread
From: Cook, Malcolm @ 2015-10-01 19:59 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org; +Cc: bioc-devel@r-project.org, r-devel@r-project.org

Hello ,

I am not sure what the best solution is, but, in my hands using Org-mode version 8.3.2-elpa org-20150929 the reg-expt  used to "cleanup extra prompts left in output" is over-aggressive and will trim session :output at lines consisting exclusively of blanks and periods such as produced when printing a BioConductor 'Views' object which wants to appear as

#+RESULTS:
#+begin_example
  Views on a 23011544-letter DNAString subject
subject: CGACAATGCACGACAGAGGAAGCAGAACAGATATTTAGATTGCCTCTCATTTTCTCTCCCATATTATAGGGAGAAATATGATCGCGTATGCGAGAGTAGTGCCAACATATTGTGCTCTTTGATTTTTTGGCAACCCAAAATGGTGGCGGATGAACGAGATGATAATATATTCAAGTTGCCGCTAATCAGAAATAAATTCATTGCAACGTTAAATACAGCACAATATATGATCGCGTATGCGAGAGTAGTGCCAACATATTGTGCTAATGAGTGCCTCTCGTTCTCTGTCTTATA...TATCTTTCAAATTTTGATGACCCCCACTAGCAAAAAATGCGAAAATTAACCCAAATAATGATTTCCCTAAATCCTTCCAAAAGTAAATATTAACTTTTTGGCAAAATCCATTTTCCCAAATTTCGGTCATTAAATAATCAGTTTTTTGCCACAACTTTTAAAATAATTGTCTGAAAATGGAATGTCATATCTCGATGAGCTCATAATTAAATTTACAATCAAACTGTGTTCGAAAAAGAGAAAACTAACATTTTTTTGGCATATTTGCAAATTTTGATGAACCCCCCTTTCAAA
views:
         start      end width
  [1]   344766   344773     8 [CATGAGGC]
  [2]   563564   563571     8 [CATGAGGC]
  [3]   641027   641034     8 [CATGAGGC]
  [4]   656168   656175     8 [CATGAGGC]
  [5]   709112   709119     8 [CATGAGGC]
  ...      ...      ...   ... ...
[141] 22209984 22209991     8 [CATGAGGC]
[142] 22371543 22371550     8 [CATGAGGC]
[143] 22554991 22554998     8 [CATGAGGC]
[144] 22618578 22618585     8 [CATGAGGC]
[145] 22897728 22897735     8 [CATGAGGC]
#+end_example

But alas rather appears as:

#+RESULTS:
#+begin_example
  ...      ...      ...   ... ...
[141] 22209984 22209991     8 [CATGAGGC]
[142] 22371543 22371550     8 [CATGAGGC]
[143] 22554991 22554998     8 [CATGAGGC]
[144] 22618578 22618585     8 [CATGAGGC]
[145] 22897728 22897735     8 [CATGAGGC]
#+end_example


I offer as a possible workaround the following:

So far, I have had good success having removed provision for allowing leading whitespace by changing the regexp  org-babel-R-evaluate-session  from
      "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"
 to
      "^\\([>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"

But I don't know all the test cases so, YMMV....

HTH,

~Malcolm (who, FWIW, has never really liked the way ob-R communicated with the inferior R session in the first place....)

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

* 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
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Charles C. Berry @ 2015-10-01 21:56 UTC (permalink / raw)
  To: Cook, Malcolm; +Cc: emacs-orgmode@gnu.org

On Thu, 1 Oct 2015, Cook, Malcolm wrote:

> Hello ,
>

> I am not sure what the best solution is, but, in my hands using Org-mode 
> version 8.3.2-elpa org-20150929 the reg-expt used to "cleanup extra 
> prompts left in output" is over-aggressive and will trim session :output 
> at lines consisting exclusively of blanks and periods such as produced 
> when printing a BioConductor 'Views' object which wants to appear as

I'd try (for example):

#+BEGIN_SRC R :results value raw drawer :session
require(GenomicRanges)
capture.output(show(GRanges(seqnames=rep("a",100),
 	IRanges(start=1:100,width=1),strand=rep("*",100))))
#+END_SRC

rather than messing with the regexp.

>
>
> I offer as a possible workaround the following:
>
> So far, I have had good success having removed provision for allowing leading whitespace by changing the regexp  org-babel-R-evaluate-session  from
>      "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"
> to
>      "^\\([>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"
>
> But I don't know all the test cases so, YMMV....

Just guessing that the things that `(setq ess-eval-visibly nil)' generates 
(e.g., + + + + + > ) won't behave using your version.

HTH,

Chuck

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

* 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
  2015-10-01 21:56 ` Charles C. Berry
@ 2015-10-01 23:15   ` Cook, Malcolm
  2015-10-08 19:24     ` Charles C. Berry
  0 siblings, 1 reply; 14+ messages in thread
From: Cook, Malcolm @ 2015-10-01 23:15 UTC (permalink / raw)
  To: 'Charles C. Berry'; +Cc: emacs-orgmode@gnu.org

> > I am not sure what the best solution is, but, in my hands using
 > > Org-mode version 8.3.2-elpa org-20150929 the reg-expt used to "cleanup
 > > extra prompts left in output" is over-aggressive and will trim session
 > > :output at lines consisting exclusively of blanks and periods such as
 > > produced when printing a BioConductor 'Views' object which wants to
 > > appear as
 > 
 > I'd try (for example):
 > 
 > #+BEGIN_SRC R :results value raw drawer :session
 > require(GenomicRanges)
 > capture.output(show(GRanges(seqnames=rep("a",100),
 >  	IRanges(start=1:100,width=1),strand=rep("*",100))))
 > #+END_SRC

Thanks for the thought, but, I'm trying to engage in "literate programming" for which in my opinion I should not have to re-write my code (using capture.output and show) to get the output of evaluation captured.

We're I to sweave my code I would get all this un-wanted cruft.

I think org-bable-R-evaluate-FOO should be handling all this for us.

 > rather than messing with the regexp.

Hmm.... not sure I understand your preference here.   I'm providing an example of some that should "just work", but does not.   I too prefer not to mess with the regexp other than to identify it as the source of the issue.  Perhaps the "real solution" is to recode org-bable-R-evaluate-FOO.

> > I offer as a possible workaround the following:
 > >
 > > So far, I have had good success having removed provision for allowing
 > leading whitespace by changing the regexp  org-babel-R-evaluate-session
 > from
 > >      "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"
 > > to
 > >      "^\\([>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"
 > >
 > > But I don't know all the test cases so, YMMV....
 > 
 > Just guessing that the things that `(setq ess-eval-visibly nil)' generates (e.g., +
 > + + + + > ) won't behave using your version.
 > 

In fact it does behave.  I tried it.  I think that ess-eval-visibly effects how ob-R interacts with the ess session.

 > HTH,

I wish it did.... ;)  Thanks for your efforts.

 > 
 > Chuck

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

* 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
  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
  0 siblings, 2 replies; 14+ messages in thread
From: Charles C. Berry @ 2015-10-08 19:24 UTC (permalink / raw)
  To: Cook, Malcolm; +Cc: emacs-orgmode@gnu.org

On Thu, 1 Oct 2015, Cook, Malcolm wrote:

>>> I am not sure what the best solution is, but, in my hands using
> > > Org-mode version 8.3.2-elpa org-20150929 the reg-expt used to "cleanup
> > > extra prompts left in output" is over-aggressive and will trim session
> > > :output at lines consisting exclusively of blanks and periods such as
> > > produced when printing a BioConductor 'Views' object which wants to
> > > appear as
> >

[snip]

>>> I offer as a possible workaround the following:
> > >
> > > So far, I have had good success having removed provision for allowing
> > leading whitespace by changing the regexp  org-babel-R-evaluate-session
> > from
> > >      "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"
> > > to
> > >      "^\\([>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"
> > >
> > > But I don't know all the test cases so, YMMV....

I have traced this back to its source, and the culprit appears to be me.

See
   commit dc92eaa08d89e4bc9556f868ae65633196157a8d
   Author: Eric Schulte <schulte.eric@gmail.com>
   Date:   Wed Jul 28 08:05:30 2010 -0600
and subsequent modifications.

I believe the leading blank(s) in the regex were copied from ess, but 
nowadays I only see this in code in ess-traceback.el that is commented 
out.

So I guess there would be no harm in pushing the latter regex.

Chuck

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

* 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
  2015-10-08 19:24     ` Charles C. Berry
@ 2015-10-08 20:41       ` Cook, Malcolm
  2015-11-05 12:57       ` Nicolas Goaziou
  1 sibling, 0 replies; 14+ messages in thread
From: Cook, Malcolm @ 2015-10-08 20:41 UTC (permalink / raw)
  To: 'Charles C. Berry'; +Cc: emacs-orgmode@gnu.org

> On Thu, 1 Oct 2015, Cook, Malcolm wrote:
 > 
 > >>> I am not sure what the best solution is, but, in my hands using
 > > > > Org-mode version 8.3.2-elpa org-20150929 the reg-expt used to
 > > > > "cleanup extra prompts left in output" is over-aggressive and will
 > > > > trim session :output at lines consisting exclusively of blanks and
 > > > > periods such as produced when printing a BioConductor 'Views'
 > > > > object which wants to appear as
 > > >
 > 
 > [snip]
 > 
 > >>> I offer as a possible workaround the following:
 > > > >
 > > > > So far, I have had good success having removed provision for
 > > > > allowing
 > > > leading whitespace by changing the regexp
 > > > org-babel-R-evaluate-session from
 > > > >      "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"
 > > > > to
 > > > >      "^\\([>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)"
 > > > >
 > > > > But I don't know all the test cases so, YMMV....
 > 
 > I have traced this back to its source, and the culprit appears to be me.
 > 
 > See
 >    commit dc92eaa08d89e4bc9556f868ae65633196157a8d
 >    Author: Eric Schulte <schulte.eric@gmail.com>
 >    Date:   Wed Jul 28 08:05:30 2010 -0600
 > and subsequent modifications.
 > 
 > I believe the leading blank(s) in the regex were copied from ess, but nowadays
 > I only see this in code in ess-traceback.el that is commented out.
 > 
 > So I guess there would be no harm in pushing the latter regex.


Hi Chuck.  Thanks for the history lesson, and taking this on in the first place.  Yay!    ~Malcolm

 > 
 > Chuck

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

* 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
  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
  1 sibling, 2 replies; 14+ messages in thread
From: Nicolas Goaziou @ 2015-11-05 12:57 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: Cook, Malcolm, emacs-orgmode@gnu.org

Hello,

"Charles C. Berry" <ccberry@ucsd.edu> writes:

> I have traced this back to its source, and the culprit appears to be me.
>
> See
>   commit dc92eaa08d89e4bc9556f868ae65633196157a8d
>   Author: Eric Schulte <schulte.eric@gmail.com>
>   Date:   Wed Jul 28 08:05:30 2010 -0600
> and subsequent modifications.
>
> I believe the leading blank(s) in the regex were copied from ess, but
> nowadays I only see this in code in ess-traceback.el that is commented
> out.
>
> So I guess there would be no harm in pushing the latter regex.

Would you want to provide a patch for that (and commit it while you're
at it)?

Thank you for the investigation.


Regards,

-- 
Nicolas Goaziou

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

* 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
  2015-11-05 12:57       ` Nicolas Goaziou
@ 2015-11-06 23:11         ` Charles C. Berry
  2015-11-07 21:30         ` Charles C. Berry
  1 sibling, 0 replies; 14+ messages in thread
From: Charles C. Berry @ 2015-11-06 23:11 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Cook, Malcolm, emacs-orgmode@gnu.org

On Thu, 5 Nov 2015, Nicolas Goaziou wrote:

> Hello,
>
> "Charles C. Berry" <ccberry@ucsd.edu> writes:
>
>> I have traced this back to its source, and the culprit appears to be me.
>>
>> See
>>   commit dc92eaa08d89e4bc9556f868ae65633196157a8d
>>   Author: Eric Schulte <schulte.eric@gmail.com>
>>   Date:   Wed Jul 28 08:05:30 2010 -0600
>> and subsequent modifications.
>>
>> I believe the leading blank(s) in the regex were copied from ess, but
>> nowadays I only see this in code in ess-traceback.el that is commented
>> out.
>>
>> So I guess there would be no harm in pushing the latter regex.
>
> Would you want to provide a patch for that (and commit it while you're
> at it)?

Yes, but Babel seems to be broken - at least on my box - by this

commit 40356ae3765d123fd9950a961718530219fa5cb8
Author: Aaron Ecay <aaronecay@gmail.com>
Date:   Thu Nov 5 15:51:06 2015 +0000

Once that is resolved, I'll do something.

Chuck

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

* 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
  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
  1 sibling, 2 replies; 14+ messages in thread
From: Charles C. Berry @ 2015-11-07 21:30 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Cook, Malcolm, emacs-orgmode@gnu.org

On Thu, 5 Nov 2015, Nicolas Goaziou wrote:
[...]
> Would you want to provide a patch for that (and commit it while you're
> at it)?
>

Done.

Chuck

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

* 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
  2015-11-07 21:30         ` Charles C. Berry
@ 2015-11-07 21:41           ` Nicolas Goaziou
  2015-11-07 23:22           ` Cook, Malcolm
  1 sibling, 0 replies; 14+ messages in thread
From: Nicolas Goaziou @ 2015-11-07 21:41 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: Cook, Malcolm, emacs-orgmode@gnu.org

"Charles C. Berry" <ccberry@ucsd.edu> writes:

> On Thu, 5 Nov 2015, Nicolas Goaziou wrote:
> [...]
>> Would you want to provide a patch for that (and commit it while you're
>> at it)?
>>
>
> Done.

Thank you.

Regards,

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

* 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
  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
  1 sibling, 1 reply; 14+ messages in thread
From: Cook, Malcolm @ 2015-11-07 23:22 UTC (permalink / raw)
  To: Charles Berry; +Cc: emacs-orgmode@gnu.org, Nicolas Goaziou

[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]

Thanks Chuck for setting this through.

I've never been happy at how Babel arranged the inter process communication with R  including the need for cleaning up the output with scary regular expressions like this.

Also there are some of uses of temp files that sometime cause of bugs especially when running R under tramp on a remote host. I'll be sure to report it next time I see it.

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.

But I digress.....

Thanks again for running with my workaround....

On Nov 7, 2015 3:31 PM, "Charles C. Berry" <ccberry@ucsd.edu> wrote:
On Thu, 5 Nov 2015, Nicolas Goaziou wrote:
[...]
> Would you want to provide a patch for that (and commit it while you're
> at it)?
>

Done.

Chuck

[-- Attachment #2: Type: text/html, Size: 1967 bytes --]

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

* 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
  2015-11-07 23:22           ` Cook, Malcolm
@ 2015-11-08  0:32             ` Charles C. Berry
  2015-11-09 20:04               ` Cook, Malcolm
  0 siblings, 1 reply; 14+ messages in thread
From: Charles C. Berry @ 2015-11-08  0:32 UTC (permalink / raw)
  To: Cook, Malcolm; +Cc: emacs-orgmode@gnu.org

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

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

* 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
  2015-11-08  0:32             ` Charles C. Berry
@ 2015-11-09 20:04               ` Cook, Malcolm
  2015-11-09 20:56                 ` Charles C. Berry
  0 siblings, 1 reply; 14+ messages in thread
From: Cook, Malcolm @ 2015-11-09 20:04 UTC (permalink / raw)
  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 <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

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

* 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
  2015-11-09 20:04               ` Cook, Malcolm
@ 2015-11-09 20:56                 ` Charles C. Berry
  2015-11-09 22:11                   ` Cook, Malcolm
  0 siblings, 1 reply; 14+ messages in thread
From: Charles C. Berry @ 2015-11-09 20:56 UTC (permalink / raw)
  To: Cook, Malcolm; +Cc: emacs-orgmode@gnu.org

On Mon, 9 Nov 2015, Cook, Malcolm wrote:
[...]
> > >
> > [...]
> > >
> > > 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:
> >

[snip]

> 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"`)

I know. That is why I said it is a 'start'. You can work around this
with more Babel if that is the only issue. Write a src block `good-fmt' 
that will render the body of another block as you want it and then use
<<good-fmt("R-src-blk-with-quotes")>> to insert it.


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

See Aaron Ecay's patches from around 08/2014. And discussions on this
list from about that time.  He had some of this working, but there
were some issues about handling remote calls, IIRC.

> Probably not worth the effort.  Or rather, probably
> already done within the knitr/rmarkdown.

By default knitr interlaces the code and output in a frame with
the output lines prefixed by '##'. The code is highlighted by default.

In *.Rnw this leads to a single block with a background color and
colorized code.

In *.Rhtml you get source code blocks colored per <div class="source">
and results blocks uncolored per <div class="output">.

Using *.org via ox-ravel --> *.Rhtml via knitr --> *.html will get you 
that far.

Maybe customizing the classes to your taste will finish it.

Best,

Chuck

p.s. If you go with ox-ravel, I recommend the ravel-lang branch:
https://github.com/chasberry/orgmode-accessories/tree/ravel-lang

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

* 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
  2015-11-09 20:56                 ` Charles C. Berry
@ 2015-11-09 22:11                   ` Cook, Malcolm
  0 siblings, 0 replies; 14+ messages in thread
From: Cook, Malcolm @ 2015-11-09 22:11 UTC (permalink / raw)
  To: 'Charles C. Berry'; +Cc: emacs-orgmode@gnu.org

> [...]
 > > > >
 > > > [...]
 > > > >
 > > > > 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:
 > > >
 > 
 > [snip]
 > 
 > > 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"`)
 > 
 > I know. That is why I said it is a 'start'. You can work around this
 > with more Babel if that is the only issue. Write a src block `good-fmt'
 > that will render the body of another block as you want it and then use
 > <<good-fmt("R-src-blk-with-quotes")>> to insert it.
 > 
 > 
 > > 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.
 > 
 > See Aaron Ecay's patches from around 08/2014. And discussions on this
 > list from about that time.  He had some of this working, but there
 > were some issues about handling remote calls, IIRC.
 > 
 > > Probably not worth the effort.  Or rather, probably
 > > already done within the knitr/rmarkdown.
 > 
 > By default knitr interlaces the code and output in a frame with
 > the output lines prefixed by '##'. The code is highlighted by default.
 > 
 > In *.Rnw this leads to a single block with a background color and
 > colorized code.
 > 
 > In *.Rhtml you get source code blocks colored per <div class="source">
 > and results blocks uncolored per <div class="output">.
 > 
 > Using *.org via ox-ravel --> *.Rhtml via knitr --> *.html will get you
 > that far.
 > 

Indeed it does.  I have previously used ox-ravel to superb effect allowing me to compose R lessons as *.org and distribute as *.Rmd for use within RStudio server.  I must remember to remember this option!

 > Maybe customizing the classes to your taste will finish it.
 > 
 > Best,
 > 
 > Chuck
 > 
 > p.s. If you go with ox-ravel, I recommend the ravel-lang branch:
 > https://github.com/chasberry/orgmode-accessories/tree/ravel-lang	

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

end of thread, other threads:[~2015-11-09 22:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2015-11-09 20:56                 ` Charles C. Berry
2015-11-09 22:11                   ` Cook, Malcolm

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