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).
This commit is contained in:
Dan Davison 2009-07-19 17:45:00 -04:00
parent 162b522728
commit 2b66de1c1b
1 changed files with 18 additions and 18 deletions

View File

@ -122,26 +122,26 @@ last statement in BODY, as elisp."
(full-body (mapconcat #'org-babel-chomp (full-body (mapconcat #'org-babel-chomp
(list body last-value-eval org-babel-R-eoe-indicator) "\n")) (list body last-value-eval org-babel-R-eoe-indicator) "\n"))
(raw (org-babel-comint-with-output buffer org-babel-R-eoe-output nil (raw (org-babel-comint-with-output buffer org-babel-R-eoe-output nil
(insert full-body) (inferior-ess-send-input))) (insert full-body) (inferior-ess-send-input))) broke results)
(results (case result-type
(let ((broke nil)) (value (org-babel-R-process-value-result
(org-babel-import-elisp-from-file tmp-file) column-names-p))
(output
(setq broke nil results
(delete (delete
nil nil
(mapcar (lambda (el) (mapcar (lambda (el)
(if (or broke (if (or broke
(and (string-match (regexp-quote org-babel-R-eoe-output) (and (string-match (regexp-quote org-babel-R-eoe-output) el)
el) (setq broke t))) (setq broke t)))
nil nil
(if (= (length el) 0) (if (= (length el) 0)
nil nil
(if (string-match comint-prompt-regexp el) (if (string-match comint-prompt-regexp el)
(substring el (match-end 0)) (substring el (match-end 0))
el)))) el))))
(mapcar #'org-babel-trim raw)))))) (mapcar #'org-babel-chomp raw))))
(case result-type (mapconcat #'identity results "\n")))))))
(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)))))))
(defun org-babel-R-process-value-result (result column-names-p) (defun org-babel-R-process-value-result (result column-names-p)
"R-specific processing of return value prior to return to org-babel. "R-specific processing of return value prior to return to org-babel.