diff options
author | Aaron Ecay <aaronecay@gmail.com> | 2014-08-07 14:00:01 -0400 |
---|---|---|
committer | Aaron Ecay <aaronecay@gmail.com> | 2014-08-07 14:00:01 -0400 |
commit | 59cd25cd759cc08fea25ad7796f904fffe2040d7 (patch) | |
tree | 6bf14637a29b9a39f20a57c6a3e976d94d95be23 | |
parent | 3ea1ce2e859db0e5b815364d0596eef7c92ade55 (diff) | |
download | org-mode-59cd25cd759cc08fea25ad7796f904fffe2040d7.tar.gz |
Revert "ob-R.el: Improve the capturing of output-type results in sessions."
This reverts commit b51746332dca87a35c387b2db0bb678b4c24a4da.
-rw-r--r-- | lisp/ob-R.el | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/lisp/ob-R.el b/lisp/ob-R.el index a7965af..9f4eb4b 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -365,7 +365,7 @@ last statement in BODY, as elisp." (defvar ess-eval-visibly-p) (defun org-babel-R-evaluate-session - (session body result-type result-params column-names-p row-names-p) + (session body result-type result-params column-names-p row-names-p) "Evaluate BODY in SESSION. If RESULT-TYPE equals 'output then return standard output as a string. If RESULT-TYPE equals 'value then return the value of the @@ -395,20 +395,23 @@ last statement in BODY, as elisp." (org-babel-import-elisp-from-file tmp-file '(16))) column-names-p))) (output - (let* ((output-file (org-babel-temp-file "R-")) - (sentinel-file (concat output-file "-sentinel"))) - (org-babel-comint-eval-invisibly-and-wait-for-file - session sentinel-file - (format "capture.output({%s}, file=%S); file.create(%S)" - (org-babel-chomp body) - output-file - sentinel-file)) - (with-temp-buffer - (insert-file-contents output-file) - (goto-char (point-min)) - (flush-lines "^$") - (delete-trailing-whitespace) - (buffer-string)))))) + (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 + "^\\([ ]*[>+\\.][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line) + (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")))) (defun org-babel-R-process-value-result (result column-names-p) "R-specific processing of return value. |