diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-12-20 10:24:53 -0700 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2010-12-21 14:19:24 +0000 |
commit | e0b79276789e47c268ac9a3dcc9b9bac93c1f251 (patch) | |
tree | 7720d6ba2e3b18c1e9a47b6985a434f9fe444114 | |
parent | 74d752b4b5416b33798ac573cbea723bff85c75b (diff) | |
download | org-mode-e0b79276789e47c268ac9a3dcc9b9bac93c1f251.tar.gz |
ob: :sep specifies table separator when opening or writing tabular results
* lisp/ob.el (org-babel-execute-src-block): Allow specification of
table separator with :sep header argument.
(org-babel-open-src-block-result): Allow specification of table
separator with :sep header argument.
-rw-r--r-- | lisp/ob.el | 55 |
1 files changed, 31 insertions, 24 deletions
@@ -420,7 +420,9 @@ block." (if (stringp result) (insert result) (insert (orgtbl-to-generic - result '(:sep "\t" :fmt echo-res)))))) + result + (list :sep (or (cdr (assoc :sep params)) "\t") + :fmt 'echo-res)))))) (setq result (cdr (assoc :file params))))) (org-babel-insert-result result result-params info new-hash indent lang) @@ -577,29 +579,34 @@ source code block, otherwise return nil. With optional prefix argument RE-RUN the source-code block is evaluated even if results already exist." (interactive "P") - (when (org-babel-get-src-block-info) - (save-excursion - ;; go to the results, if there aren't any then run the block - (goto-char (or (and (not re-run) (org-babel-where-is-src-block-result)) - (progn (org-babel-execute-src-block) - (org-babel-where-is-src-block-result)))) - (end-of-line 1) - (while (looking-at "[\n\r\t\f ]") (forward-char 1)) - ;; open the results - (if (looking-at org-bracket-link-regexp) - ;; file results - (org-open-at-point) - (let ((results (org-babel-read-result))) - (flet ((echo-res (result) - (if (stringp result) result (format "%S" result)))) - (pop-to-buffer (get-buffer-create "org-babel-results")) - (delete-region (point-min) (point-max)) - (if (listp results) - ;; table result - (insert (orgtbl-to-generic results '(:sep "\t" :fmt echo-res))) - ;; scalar result - (insert (echo-res results)))))) - t))) + (let ((info (org-babel-get-src-block-info))) + (when info + (save-excursion + ;; go to the results, if there aren't any then run the block + (goto-char (or (and (not re-run) (org-babel-where-is-src-block-result)) + (progn (org-babel-execute-src-block) + (org-babel-where-is-src-block-result)))) + (end-of-line 1) + (while (looking-at "[\n\r\t\f ]") (forward-char 1)) + ;; open the results + (if (looking-at org-bracket-link-regexp) + ;; file results + (org-open-at-point) + (let ((results (org-babel-read-result))) + (flet ((echo-res (result) + (if (stringp result) result (format "%S" result)))) + (pop-to-buffer (get-buffer-create "org-babel-results")) + (delete-region (point-min) (point-max)) + (if (listp results) + ;; table result + (insert (orgtbl-to-generic + results + (list + :sep (or (cdr (assoc :sep (nth 2 info))) "\t") + :fmt 'echo-res))) + ;; scalar result + (insert (echo-res results)))))) + t)))) ;;;###autoload (defmacro org-babel-map-src-blocks (file &rest body) |