diff options
author | Charles Berry <ccberry@ucsd.edu> | 2016-01-19 19:32:11 -0800 |
---|---|---|
committer | Charles Berry <ccberry@ucsd.edu> | 2016-01-19 20:10:43 -0800 |
commit | 3142d139fac70d060020d3f59f309061705adca4 (patch) | |
tree | 8af91f99e65ebb7d559e44ff97db6d00eaf4971d | |
parent | 2e77161519c87c835275f75abd9356d59b2fea40 (diff) | |
download | org-mode-3142d139fac70d060020d3f59f309061705adca4.tar.gz |
ob-R.el: Trim extraneous newline from results
* lisp/ob-R.el: org-babel-R-evaluate-external-process and
org-babel-R-evaluate-session trim the extraneous newlines from the
end of R output.
* testing/lisp/test-ob-R.el: test-ob-R/results-file tests that
`:results file' yields one line enclosed in square brackets for a
result like "abc/def.ghi".
Fixes issue noted by Andreas Leha
Subject: [babel] return file from R
Archived-At: <http://permalink.gmane.org/gmane.emacs.orgmode/103658>
-rw-r--r-- | lisp/ob-R.el | 4 | ||||
-rw-r--r-- | testing/lisp/test-ob-R.el | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 519ae4e..b87b1f8 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -397,7 +397,7 @@ last statement in BODY, as elisp." (org-babel-result-cond result-params (with-temp-buffer (insert-file-contents tmp-file) - (buffer-string)) + (org-babel-chomp (buffer-string) "\n")) (org-babel-import-elisp-from-file tmp-file '(16))) column-names-p))) (output (org-babel-eval org-babel-R-command body)))) @@ -431,7 +431,7 @@ last statement in BODY, as elisp." (org-babel-result-cond result-params (with-temp-buffer (insert-file-contents tmp-file) - (buffer-string)) + (org-babel-chomp (buffer-string) "\n")) (org-babel-import-elisp-from-file tmp-file '(16))) column-names-p))) (output diff --git a/testing/lisp/test-ob-R.el b/testing/lisp/test-ob-R.el index e3f13f1..744a706 100644 --- a/testing/lisp/test-ob-R.el +++ b/testing/lisp/test-ob-R.el @@ -79,6 +79,22 @@ x (should (equal '(("col") ("a") ("b")) (org-babel-execute-src-block))))) +(ert-deftest test-ob-R/results-file () + (org-test-with-temp-text "#+NAME: TESTSRC +#+BEGIN_SRC R :results file + a <- file.path(\"junk\", \"test.org\") + a +#+END_SRC" + (goto-char (point-min)) (org-babel-execute-maybe) + (org-babel-goto-named-result "TESTSRC") (forward-line 1) + (should (string= "[[file:junk/test.org]]" + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))) + (goto-char (point-min)) (forward-line 1) + (insert "#+header: :session\n") + (goto-char (point-min)) (org-babel-execute-maybe) + (org-babel-goto-named-result "TESTSRC") (forward-line 1) + (should (string= "[[file:junk/test.org]]" + (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))) (provide 'test-ob-R) ;;; test-ob-R.el ends here |