babel: read remote results from remote files
When using ':results value' in certain situations, results are written to file by the foreign language process and subsequently read from file by emacs into an elisp table structure. If the foreign language process is running remotely, then the results are written remotely. These changes ensure that in that case, an appropriate remote file name is constructed to read the remote data.
This commit is contained in:
parent
2056d7d419
commit
24cdeea122
|
@ -155,7 +155,9 @@ last statement in BODY, as elisp."
|
|||
body tmp-file (if column-names-p "TRUE" "FALSE")))
|
||||
(shell-command-on-region (point-min) (point-max) "R --no-save" 'replace))
|
||||
(org-babel-R-process-value-result
|
||||
(org-babel-import-elisp-from-file out-tmp-file) column-names-p))))
|
||||
(org-babel-import-elisp-from-file
|
||||
(if (file-remote-p default-directory) (org-babel-make-remote-file-name tmp-file) tmp-file))
|
||||
column-names-p))))
|
||||
;; comint session evaluation
|
||||
(org-babel-comint-in-buffer session
|
||||
(let* ((tmp-file (make-temp-file "org-babel-R"))
|
||||
|
@ -178,7 +180,9 @@ last statement in BODY, as elisp."
|
|||
broke results)
|
||||
(case result-type
|
||||
(value (org-babel-R-process-value-result
|
||||
(org-babel-import-elisp-from-file tmp-file) column-names-p))
|
||||
(org-babel-import-elisp-from-file
|
||||
(if (file-remote-p default-directory) (org-babel-make-remote-file-name tmp-file) tmp-file))
|
||||
column-names-p))
|
||||
(output
|
||||
(flet ((extractor
|
||||
(el)
|
||||
|
|
|
@ -178,7 +178,10 @@ last statement in BODY, as elisp."
|
|||
tmp-file))
|
||||
;; (message "buffer=%s" (buffer-string)) ;; debugging
|
||||
(shell-command-on-region (point-min) (point-max) "python"))
|
||||
(let ((raw (with-temp-buffer (insert-file-contents tmp-file) (buffer-string))))
|
||||
(let ((raw (with-temp-buffer
|
||||
(insert-file-contents
|
||||
(if (file-remote-p default-directory) (org-babel-make-remote-file-name tmp-file) tmp-file))
|
||||
(buffer-string))))
|
||||
(if (or (member "code" result-params) (member "pp" result-params))
|
||||
raw
|
||||
(org-babel-python-table-or-string raw)))))))
|
||||
|
|
|
@ -175,8 +175,10 @@ last statement in BODY, as elisp."
|
|||
org-babel-ruby-wrapper-method) body tmp-file))
|
||||
;; (message "buffer=%s" (buffer-string)) ;; debugging
|
||||
(shell-command-on-region (point-min) (point-max) "ruby"))
|
||||
(let ((raw (with-temp-buffer (insert-file-contents tmp-file)
|
||||
(buffer-string))))
|
||||
(let ((raw (with-temp-buffer
|
||||
(insert-file-contents
|
||||
(if (file-remote-p default-directory) (org-babel-make-remote-file-name tmp-file) tmp-file))
|
||||
(buffer-string))))
|
||||
(if (or (member "code" result-params) (member "pp" result-params))
|
||||
raw
|
||||
(org-babel-ruby-table-or-string raw)))))))
|
||||
|
|
|
@ -1102,5 +1102,12 @@ Fixes a bug in `tramp-handle-call-process-region'."
|
|||
;; call-process-region-original is the original emacs definition. It
|
||||
;; is in scope from the let binding in org-babel-execute-src-block
|
||||
(apply call-process-region-original start end program delete buffer display args)))
|
||||
|
||||
(defun org-babel-make-remote-file-name (file)
|
||||
(let* ((vec (tramp-dissect-file-name default-directory))
|
||||
(user (tramp-file-name-user vec))
|
||||
(host (tramp-file-name-host vec)))
|
||||
(concat "/" user (when user "@") host ":" file)))
|
||||
|
||||
(provide 'org-babel)
|
||||
;;; org-babel.el ends here
|
||||
|
|
Loading…
Reference in New Issue