From 12390991200c4d657974648b172a7985e8fc48cc Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 3 Aug 2010 00:14:35 -0400 Subject: [PATCH 1/3] babel: python: Fix recognition of lists and tuples 2010-08-03 Dan Davison * ob-python.el (org-babel-python-table-or-string): Fix recognition of lists and tuples Prior to this we had #+begin_src python return [1, 2] #+end_src #+results: : [1, 2] --- lisp/ob-python.el | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lisp/ob-python.el b/lisp/ob-python.el index ab6da3fa0..e7101f075 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -125,10 +125,7 @@ Emacs-lisp table, otherwise return the results as a string." (mapcar (lambda (el) (if (equal el 'None) 'hline el)) res) res)) (org-babel-read - (if (or (and (equal (substring results 0 1) "[") - (equal (substring results -2 -1) "]")) - (and (equal (substring results 0 1) "(") - (equal (substring results -2 -1) ")"))) + (if (and (stringp results) (string-match "^[([].+[])]$" results)) (org-babel-read (concat "'" (replace-regexp-in-string From 34144f9a954e2a55933fa4470111bff2307b1390 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 3 Aug 2010 00:06:25 -0400 Subject: [PATCH 2/3] babel: Allow specification of field separator when reading tables 2010-08-03 Dan Davison * ob.el (org-babel-import-elisp-from-file): Allow separator to be specified --- lisp/ob.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index b946f3c43..6e74c15aa 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1508,7 +1508,7 @@ This is taken almost directly from `org-read-prop'." (length string))) (string-to-number string))) -(defun org-babel-import-elisp-from-file (file-name) +(defun org-babel-import-elisp-from-file (file-name &optional separator) "Read the results located at FILE-NAME into an elisp table. If the table is trivial, then return it as a scalar." (let (result) @@ -1516,7 +1516,7 @@ If the table is trivial, then return it as a scalar." (with-temp-buffer (condition-case nil (progn - (org-table-import file-name nil) + (org-table-import file-name separator) (delete-file file-name) (setq result (mapcar (lambda (row) (mapcar #'org-babel-string-read row)) From 5122aee4a7c806a7ef07ce1d49a32ada658e31b4 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 3 Aug 2010 00:12:53 -0400 Subject: [PATCH 3/3] babel: R: Specify that tables are tab-delimited 2010-08-03 Dan Davison * ob-R.el (org-babel-R-evaluate): Specify that tabular data is tab-delimited Prior to this we had #+begin_src R c("some words", "with spaces") #+end_src #+results: | some | words | | with | spaces | --- lisp/ob-R.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index eae36696c..e9633ae28 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -230,7 +230,7 @@ return the value of the last statement in BODY, as elisp." "FALSE"))) (org-babel-R-process-value-result (org-babel-import-elisp-from-file - (org-babel-maybe-remote-file tmp-file)) column-names-p)))) + (org-babel-maybe-remote-file tmp-file) '(16)) column-names-p)))) ;; comint session evaluation (case result-type (value @@ -251,7 +251,7 @@ return the value of the last statement in BODY, as elisp." (inferior-ess-send-input)) (org-babel-R-process-value-result (org-babel-import-elisp-from-file - (org-babel-maybe-remote-file tmp-file)) column-names-p))) + (org-babel-maybe-remote-file tmp-file) '(16)) column-names-p))) (output (mapconcat #'org-babel-chomp