1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-23 07:18:53 +00:00

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.
This commit is contained in:
Eric Schulte 2010-12-20 10:24:53 -07:00 committed by Dan Davison
parent 74d752b4b5
commit e0b7927678

View File

@ -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)