summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfpi2020-08-23 19:01:30 +0200
committerfpi2020-08-23 19:01:30 +0200
commite7c83c6a52f097ed2aaba099a6c8e2dfd8843333 (patch)
tree1b3f55ba2f3208ea221d010186bae990a8a67d17
parentMinor function changes/fixes (diff)
Improve result handling
-rw-r--r--ob-spice.el18
1 files changed, 15 insertions, 3 deletions
diff --git a/ob-spice.el b/ob-spice.el
index 0e228ad..01786b6 100644
--- a/ob-spice.el
+++ b/ob-spice.el
@@ -214,9 +214,21 @@ started."
)))
(comint-send-input nil t))
;; split result to output multiple comma separated vars as table
- (let ((result (org-babel-spice-cleanup-result
- (org-babel-chomp
- (org-babel-eval-read-file tmp-file)))))
+ (let* ((raw-result (org-babel-chomp (org-babel-eval-read-file tmp-file)))
+ (result nil))
+ (when (string-match "^print" raw-result)
+ (let ((tmp-file (org-babel-temp-file "spice-")))
+ (org-babel-comint-with-output
+ (buffer org-babel-spice-eoe-indicator)
+ (mapc
+ (lambda (line)
+ (insert (org-babel-chomp line)) (comint-send-input nil t))
+ (append (list (format "%s > %s" raw-result tmp-file))
+ (list (format "echo \"%s\"" org-babel-spice-eoe-indicator))))
+ (comint-send-input nil t))
+ (setq raw-result (org-babel-eval-read-file tmp-file))))
+ (setq result (org-babel-spice-cleanup-result
+ (org-babel-chomp raw-result)))
(if (or (not (listp result)) (cdr result))
result
(car result))