emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help debugging R source code block output problem with :session


From: Jeremie Juste
Subject: Re: Help debugging R source code block output problem with :session
Date: Mon, 03 May 2021 10:53:59 +0200

Hello,

I must apologize again for the delay. I'll be more responsive from now
on.

@Jack, I have applied the patch at the bottom of the mail. It is not
your latest patch but it works as well and is able to handle R errors.

> https://orgmode.org/list/87ft7t9wqk.fsf@gmail.com/
I have also added the 2 test cases with to make sure we are aware if
this feature breaks in the future.

> https://orgmode.org/list/87h7slgbi5.fsf@gmail.com/
> I'd be interested to hear if the attached patch works for the common
> cases you encounter, such as with tibbles.


@ Ilja, sorry for the delayed reply.
Regarding tibbles we are still not out of the woods. But the current
patch would work if crayon option is removed.

#+BEGIN_SRC R :results output :session "local1" :pre
  options(crayon.enabled=FALSE)
  library(tidyr)
  library(dplyr)
  as_tibble(iris)
#+END_SRC

#+RESULTS:
#+begin_example
# A tibble: 150 x 5
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
          <dbl>       <dbl>        <dbl>       <dbl> <fct>  
 1          5.1         3.5          1.4         0.2 setosa 
 2          4.9         3            1.4         0.2 setosa 
 3          4.7         3.2          1.3         0.2 setosa 
 4          4.6         3.1          1.5         0.2 setosa 
 5          5           3.6          1.4         0.2 setosa 
 6          5.4         3.9          1.7         0.4 setosa 
 7          4.6         3.4          1.4         0.3 setosa 
 8          5           3.4          1.5         0.2 setosa 
 9          4.4         2.9          1.4         0.2 setosa 
10          4.9         3.1          1.5         0.1 setosa 
# … with 140 more rows
#+end_example

> 

@Chuck

> https://orgmode.org/list/352C7149-743F-4944-ACA5-7A1242B5A3AA@health.ucsd.edu/
>If you do decide to dig into solving this, please be sure that remote
>sessions and graphical outputs are not broken. test-ob-R.el does not
>cover those cases. In fact, it is pretty short, so there are probably
>other things that could break without `make test' complaining.


The current patch have been tested for remote connections as well and
AFAIK, nothing breaks.

But I'm afraid that the graphical output is broken and has long been
even before the path. The test for graphical output is compromised and
does not do the right test. I will suggest new ones. 


Please feel free to contact me or reply on the mailing list if you have
see any improvements to be made.

Best regards,
Jeremie



On Saturday, 29 Aug 2020 at 00:24, Jack Kamm wrote:

>>From 9eaf81d708f88d06f14f9b6b9cf4182dd0fbb997 Mon Sep 17 00:00:00 2001
> From: Jack Kamm <jackkamm@gmail.com>
> Date: Sat, 29 Aug 2020 00:07:58 -0700
> Subject: [PATCH] ob-R: Fix prompt mangling in session output
>
> * lisp/ob-R.el (org-babel-R-evaluate-session): Force comint prompt
> regexp to start at beginning of line, to prevent
> org-babel-comint-with-output from splitting mid-line.
>
> Fixes https://orgmode.org/list/875zgjh8wn.fsf@gmail.com/ and
> https://orgmode.org/list/87r1rqled0.fsf@havana/
> ---
>  lisp/ob-R.el | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/lisp/ob-R.el b/lisp/ob-R.el
> index 5e9d35f58..10b3b6fe3 100644
> --- a/lisp/ob-R.el
> +++ b/lisp/ob-R.el
> @@ -450,11 +450,13 @@ (defun org-babel-R-evaluate-session
>                     (car (split-string line "\n")))
>                    (substring line (match-end 1))
>                  line))
> -            (org-babel-comint-with-output (session org-babel-R-eoe-output)
> -              (insert (mapconcat 'org-babel-chomp
> -                                 (list body org-babel-R-eoe-indicator)
> -                                 "\n"))
> -              (inferior-ess-send-input)))))) "\n"))))
> +            (with-current-buffer session
> +              (let ((comint-prompt-regexp (concat "^" comint-prompt-regexp)))
> +                (org-babel-comint-with-output (session 
> org-babel-R-eoe-output)
> +                  (insert (mapconcat 'org-babel-chomp
> +                                     (list body org-babel-R-eoe-indicator)
> +                                     "\n"))
> +                  (inferior-ess-send-input)))))))) "\n"))))
>  
>  (defun org-babel-R-process-value-result (result column-names-p)
>    "R-specific processing of return value.
> -- 
> 2.28.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]