diff options
author | Dan Davison <dandavison7@gmail.com> | 2010-12-20 16:44:24 +0000 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2010-12-20 16:44:24 +0000 |
commit | a871c6a77ce4ad573eafc895a78f29fb3a310382 (patch) | |
tree | d67e55cf77aefbca68d853f0f7ca2b9f4f77f17a | |
parent | 5f77fd6a81a4241ce5a8e346acb9df089d65b462 (diff) | |
download | org-mode-a871c6a77ce4ad573eafc895a78f29fb3a310382.tar.gz |
new :results behavior
-rw-r--r-- | lisp/ob.el | 48 |
1 files changed, 29 insertions, 19 deletions
@@ -405,17 +405,23 @@ block." (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (setq result ((lambda (result) - (cond - ((member "file" result-params) - (or (cdr (assoc :file params)) - (if (stringp result) result))) - ((and (eq (cdr (assoc :result-type params)) 'value) - (or (member "vector" result-params) - (member "table" result-params)) - (not (listp result))) - (list (list result))) - (t result))) + (if (and (eq (cdr (assoc :result-type params)) 'value) + (or (member "vector" result-params) + (member "table" result-params)) + (not (listp result))) + (list (list result)) result)) (funcall cmd body params))) + ;; if non-empty result and :file then write to :file + (flet ((echo-res (result) + (if (stringp result) result (format "%S" result)))) + (when (cdr (assoc :file params)) + (when result + (with-temp-file (cdr (assoc :file params)) + (if (stringp result) + (insert result) + (insert (orgtbl-to-generic + result '(:sep "\t" :fmt echo-res)))))) + (setq result (cdr (assoc :file params))))) (org-babel-insert-result result result-params info new-hash indent lang) (run-hooks 'org-babel-after-execute-hook) @@ -1538,15 +1544,19 @@ code ---- the results are extracted in the syntax of the source "Convert RESULT into an `org-mode' link. If the `default-directory' is different from the containing file's directory then expand relative links." - (format - "[[file:%s]]" - (if (and default-directory - buffer-file-name - (not (string= (expand-file-name default-directory) - (expand-file-name - (file-name-directory buffer-file-name))))) - (expand-file-name result default-directory) - result))) + (flet ((cond-exp (file) + (if (and default-directory + buffer-file-name + (not (string= (expand-file-name default-directory) + (expand-file-name + (file-name-directory buffer-file-name))))) + (expand-file-name file default-directory) + file))) + (if (stringp result) + (format "[[file:%s]]" (cond-exp result)) + (when (and (listp result) (= 2 (length result)) + (stringp (car result)) (stringp (cadr result))) + (format "[[file:%s][%s]]" (car result) (cadr result)))))) (defun org-babel-examplize-region (beg end &optional results-switches) "Comment out region using the ': ' org example quote." |