mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-12-31 11:13:59 +00:00
babel: Fix temporary file processing in the remote execution case.
* ob.el (org-babel-temp-file): Don't use babel temporary directory in remote case; use make-temp-file with remote file name so that temp file is guaranteed not to exist previously on remote machine. (org-babel-tramp-localname): New function to return local name portion of possibly remote file specification * ob-R.el (org-babel-R-evaluate-external-process): Respond to changes in `org-babel-temp-file'; pass local file name to remote R process. (org-babel-R-evaluate-session) Respond to changes in `org-babel-temp-file'; pass local file name to remote R process.
This commit is contained in:
parent
fcfba8d487
commit
9c878a8290
14
lisp/ob-R.el
14
lisp/ob-R.el
@ -236,7 +236,7 @@ string. If RESULT-TYPE equals 'value then return the value of the
|
||||
last statement in BODY, as elisp."
|
||||
(case result-type
|
||||
(value
|
||||
(let ((tmp-file (org-babel-temp-file "R-results-")))
|
||||
(let ((tmp-file (org-babel-temp-file "R-")))
|
||||
(org-babel-eval org-babel-R-command
|
||||
(format org-babel-R-write-object-command
|
||||
(if row-names-p "TRUE" "FALSE")
|
||||
@ -244,10 +244,9 @@ last statement in BODY, as elisp."
|
||||
(if row-names-p "NA" "TRUE")
|
||||
"FALSE")
|
||||
(format "{function ()\n{\n%s\n}}()" body)
|
||||
tmp-file))
|
||||
(org-babel-tramp-localname tmp-file)))
|
||||
(org-babel-R-process-value-result
|
||||
(org-babel-import-elisp-from-file
|
||||
(org-babel-maybe-remote-file tmp-file) '(16)) column-names-p)))
|
||||
(org-babel-import-elisp-from-file tmp-file '(16)) column-names-p)))
|
||||
(output (org-babel-eval org-babel-R-command body))))
|
||||
|
||||
(defun org-babel-R-evaluate-session
|
||||
@ -265,16 +264,15 @@ last statement in BODY, as elisp."
|
||||
(ess-eval-buffer nil)))
|
||||
(let ((tmp-file (org-babel-temp-file "R-")))
|
||||
(org-babel-comint-eval-invisibly-and-wait-for-file
|
||||
session (org-babel-maybe-remote-file tmp-file)
|
||||
session tmp-file
|
||||
(format org-babel-R-write-object-command
|
||||
(if row-names-p "TRUE" "FALSE")
|
||||
(if column-names-p
|
||||
(if row-names-p "NA" "TRUE")
|
||||
"FALSE")
|
||||
".Last.value" tmp-file))
|
||||
".Last.value" (org-babel-tramp-localname tmp-file)))
|
||||
(org-babel-R-process-value-result
|
||||
(org-babel-import-elisp-from-file
|
||||
(org-babel-maybe-remote-file tmp-file) '(16)) column-names-p)))
|
||||
(org-babel-import-elisp-from-file tmp-file '(16)) column-names-p)))
|
||||
(output
|
||||
(mapconcat
|
||||
#'org-babel-chomp
|
||||
|
21
lisp/ob.el
21
lisp/ob.el
@ -1671,6 +1671,13 @@ the remote connection."
|
||||
(concat "/" user (when user "@") host ":" file))
|
||||
file))
|
||||
|
||||
(defun org-babel-tramp-localname (file)
|
||||
"Return the local name component of FILE."
|
||||
(if (file-remote-p file)
|
||||
(with-parsed-tramp-file-name file nil
|
||||
localname)
|
||||
file))
|
||||
|
||||
(defvar org-babel-temporary-directory
|
||||
(or (and (boundp 'org-babel-temporary-directory)
|
||||
org-babel-temporary-directory)
|
||||
@ -1684,10 +1691,16 @@ Emacs shutdown.")
|
||||
Passes PREFIX and SUFFIX directly to `make-temp-file' with the
|
||||
value of `temporary-file-directory' temporarily set to the value
|
||||
of `org-babel-temporary-directory'."
|
||||
(let ((temporary-file-directory (expand-file-name
|
||||
org-babel-temporary-directory
|
||||
temporary-file-directory)))
|
||||
(make-temp-file prefix nil suffix)))
|
||||
(if (file-remote-p default-directory)
|
||||
(make-temp-file
|
||||
(concat (file-remote-p default-directory)
|
||||
(expand-file-name
|
||||
prefix temporary-file-directory)
|
||||
nil suffix))
|
||||
(let ((temporary-file-directory (expand-file-name
|
||||
org-babel-temporary-directory
|
||||
temporary-file-directory)))
|
||||
(make-temp-file prefix nil suffix))))
|
||||
|
||||
(defun org-babel-remove-temporary-directory ()
|
||||
"Remove `org-babel-temporary-directory' on Emacs shutdown."
|
||||
|
Loading…
Reference in New Issue
Block a user