I just realized my patch had an issue where it freezes if there is an
error in the source block.

I'm attaching a second patch, to be applied on top of the first one, that fixes 
the issue.

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

Reply via email to