1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-23 10:34:17 +00:00

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:
Dan Davison 2010-02-21 00:43:53 -05:00
parent 2056d7d419
commit 24cdeea122
4 changed files with 21 additions and 5 deletions

View File

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

View File

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

View File

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

View File

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