From 2b66de1c1bc9e966cfa7c8711e0699c622ad64e1 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sun, 19 Jul 2009 17:45:00 -0400 Subject: [PATCH] Reorganising R evaluation code. With this change we avoid messing about extracting the output from the comint buffer in the :results value case (the value has already been written to file). --- lisp/langs/org-babel-R.el | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lisp/langs/org-babel-R.el b/lisp/langs/org-babel-R.el index c2ca67936..0a0234578 100644 --- a/lisp/langs/org-babel-R.el +++ b/lisp/langs/org-babel-R.el @@ -122,26 +122,26 @@ last statement in BODY, as elisp." (full-body (mapconcat #'org-babel-chomp (list body last-value-eval org-babel-R-eoe-indicator) "\n")) (raw (org-babel-comint-with-output buffer org-babel-R-eoe-output nil - (insert full-body) (inferior-ess-send-input))) - (results - (let ((broke nil)) - (delete - nil - (mapcar (lambda (el) - (if (or broke - (and (string-match (regexp-quote org-babel-R-eoe-output) - el) (setq broke t))) - nil - (if (= (length el) 0) - nil - (if (string-match comint-prompt-regexp el) - (substring el (match-end 0)) - el)))) - (mapcar #'org-babel-trim raw)))))) + (insert full-body) (inferior-ess-send-input))) broke results) (case result-type - (output (org-babel-chomp (mapconcat #'identity results "\n"))) (value (org-babel-R-process-value-result - (org-babel-import-elisp-from-file tmp-file) column-names-p))))))) + (org-babel-import-elisp-from-file tmp-file) column-names-p)) + (output + (setq broke nil results + (delete + nil + (mapcar (lambda (el) + (if (or broke + (and (string-match (regexp-quote org-babel-R-eoe-output) el) + (setq broke t))) + nil + (if (= (length el) 0) + nil + (if (string-match comint-prompt-regexp el) + (substring el (match-end 0)) + el)))) + (mapcar #'org-babel-chomp raw)))) + (mapconcat #'identity results "\n"))))))) (defun org-babel-R-process-value-result (result column-names-p) "R-specific processing of return value prior to return to org-babel.