Browse Source

lisp/ob-R.el: Fix session output with substrings matching prompts

* lisp/ob-R.el (org-babel-R-evaluate-session): New implementation for session output
results, that concat "^" to comint-prompt-regexp to avoid prompt
confusion with R.

Patch suggested by Jack Kamm:
https://orgmode.org/list/87h7slgbi5.fsf@gmail.com/
Jeremie Juste 3 years ago
parent
commit
ac8c009e00
1 changed files with 7 additions and 5 deletions
  1. 7 5
      lisp/ob-R.el

+ 7 - 5
lisp/ob-R.el

@@ -451,11 +451,13 @@ last statement in BODY, as elisp."
 		      (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.