babel: working directories and remote execution

This introduces a new header argument :dir. For the duration of source
block execution, default-directory is set to the value of this header
argument. Consequences include:

- external interpreter processes run in that directory
- new session processes run in that directory (but existing ones are unaffected)
- relative paths for file output are relative to that directory

The name of a directory on a remote machine may be specified with
tramp syntax (/user@host:path), in which case the interpreter
executable will be sought in tramp-remote-path, and if found will
execute on the remote machine in the specified remote directory.
This commit is contained in:
Dan Davison 2010-02-21 00:27:44 -05:00
parent 5f8a57ad48
commit b3d5a1eb39
2 changed files with 4 additions and 0 deletions

View File

@ -42,6 +42,7 @@ called by `org-babel-execute-src-block'."
(save-excursion
(let* ((processed-params (org-babel-process-params params))
(result-type (fourth processed-params))
(ess-ask-for-ess-directory (not (cdr (assoc :dir params))))
(session (org-babel-R-initiate-session (first processed-params)))
(vars (second processed-params))
(column-names-p (and (cdr (assoc :colnames params))

View File

@ -214,6 +214,9 @@ block."
((member "value" result-params) 'value)
(t 'value)))
(cmd (intern (concat "org-babel-execute:" lang)))
(dir (cdr (assoc :dir params)))
(default-directory
(or (and dir (if (string-match "/$" dir) dir (concat dir "/"))) default-directory))
result)
;; (message "params=%S" params) ;; debugging
(unless (member lang org-babel-interpreters)