On Wed, Jan 12, 2022 at 1:50 AM Jeremie Juste <[email protected]> wrote:
>
> Hello John,
>
> Many thanks for reporting. I'm short of time right now, but I'll take a
> closer look at the problem over
> the weekend and keep you posted. Could you let me know which version of
> org-mode you are currently using?
Sure thing and thanks for the quick note! I use org from git and
*thought* it used to report the most recent release tag, but I see:
$ git log
commit 7fa8173282f85c2ca03cc7f51f28f6adfb250610 (HEAD -> master,
origin/master, origin/HEAD)
Author: Ian Martins <[email protected]>
Date: Sat Jan 16 15:52:21 2021 -0500
But Mx-version:
Org mode version 9.4.4 (release_9.4.4-186-g7fa817.dirty @
/home/jwhendy/.elisp/org/lisp/)
So perhaps it appends the git commit to the system version?
Btw, it's dirty as I was able to apply Jack's patches (with some mods)
successfully and am a happy camper. In case it's helpful, I attached
the patches as I applied them (first -1, then -2) to this org-version.
Nothing special, they are just Jack's patches with a couple sections
removed (one change was already present, and I removed the adjustments
to the testing file as they were failing).
Thanks so much to all of you who contributed to that, as I'm so happy
that I can at least continue on with my report at this point with good
looking output!
Many thanks,
John
>
> Best regards,
> Jeremie Juste
>
>
> On Tuesday, 11 Jan 2022 at 17:36, John Hendy wrote:
> > Greetings,
> >
> > Apologies for writing off-list, but I don't have the original thread
> > anymore to reply to. I just pulled this group in directly from the
> > email I found... I just got bitten by this as well and burned most of
> > my afternoon trying to figure out what the issue was.
> >
> > Any further thoughts on a patch that could be finalized/applied?
> >
> > Is the one from the thread still the best from your continued experience?
> > https://list.orgmode.org/[email protected]/
> >
> > This r/orgmode post was what finally got me to the existence of this
> > as a previous issue (I'd just sent my own email to list as my
> > searching did not find the above):
> > https://www.reddit.com/r/orgmode/comments/pt3em4/source_block_modifying_format_of_results_r/
> >
> > And it links to a patch as well:
> > https://gist.github.com/gtuckerkellogg/e356d20497cfdc8e4fc683412e320e3e
> >
> > Many thanks,
> > John
diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 5e9d35f58..b37e3965a 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -437,24 +439,23 @@ (defun org-babel-R-evaluate-session
(org-babel-import-elisp-from-file tmp-file '(16)))
column-names-p)))
(output
- (mapconcat
- 'org-babel-chomp
- (butlast
- (delq nil
- (mapcar
- (lambda (line) (when (> (length line) 0) line))
- (mapcar
- (lambda (line) ;; cleanup extra prompts left in output
- (if (string-match
- "^\\([>+.]\\([ ][>.+]\\)*[ ]\\)"
- (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"))))
+ (let* ((tmp-file (org-babel-temp-file "R-")))
+ (with-temp-file tmp-file
+ (insert (concat body "\n" org-babel-R-eoe-indicator)))
+ (with-current-buffer session
+ (let* ((process (get-buffer-process (current-buffer)))
+ (string-buffer "")
+ (comint-output-filter-functions
+ (cons (lambda (text) (setq string-buffer
+ (concat string-buffer text)))
+ comint-output-filter-functions)))
+ (ess-send-string
+ process (format "source('%s', print.eval=TRUE)"
+ (org-babel-process-file-name tmp-file 'noquote)))
+ (while (not (string-match (regexp-quote org-babel-R-eoe-output)
+ string-buffer))
+ (accept-process-output process))
+ (substring string-buffer 0 (match-beginning 0))))))))
(defun org-babel-R-process-value-result (result column-names-p)
"R-specific processing of return value.
diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index b37e3965a..5ddf0ebd1 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -441,7 +441,7 @@ (defun org-babel-R-evaluate-session
(output
(let* ((tmp-file (org-babel-temp-file "R-")))
(with-temp-file tmp-file
- (insert (concat body "\n" org-babel-R-eoe-indicator)))
+ (insert body))
(with-current-buffer session
(let* ((process (get-buffer-process (current-buffer)))
(string-buffer "")
@@ -450,8 +450,9 @@ (defun org-babel-R-evaluate-session
(concat string-buffer text)))
comint-output-filter-functions)))
(ess-send-string
- process (format "source('%s', print.eval=TRUE)"
- (org-babel-process-file-name tmp-file 'noquote)))
+ process (format "tryCatch(source('%s', print.eval=TRUE), finally=print(%s))"
+ (org-babel-process-file-name tmp-file 'noquote)
+ org-babel-R-eoe-indicator))
(while (not (string-match (regexp-quote org-babel-R-eoe-output)
string-buffer))
(accept-process-output process))