>From 2b8db5486de75ec35c2c0d3e6063847cf582ace7 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Fri, 27 Sep 2013 13:34:03 +0200 Subject: [PATCH] * ob-core.el (org-babel-local-file-name): Simplify. (org-babel-process-file-name): Apply `expand-file-name' first. (org-babel-remote-temporary-directory): New defcustom. (org-babel-temp-file): Use it. --- lisp/ob-core.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 5a032a1..a7c227b 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -2680,11 +2680,7 @@ Fixes a bug in `tramp-handle-call-process-region'." (defun org-babel-local-file-name (file) "Return the local name component of FILE." - (if (file-remote-p file) - (let (localname) - (with-parsed-tramp-file-name file nil - localname)) - file)) + (or (file-remote-p file 'localname) file)) (defun org-babel-process-file-name (name &optional no-quote-p) "Prepare NAME to be used in an external process. @@ -2694,7 +2690,10 @@ remotely. The file name is then processed by `expand-file-name'. Unless second argument NO-QUOTE-P is non-nil, the file name is additionally processed by `shell-quote-argument'" ((lambda (f) (if no-quote-p f (shell-quote-argument f))) - (expand-file-name (org-babel-local-file-name name)))) + ;; We must apply `expand-file-name' on the whole filename. If we + ;; would apply it on the local filename only, undesired effects + ;; like prepending a drive letter on MS Windows could happen. + (org-babel-local-file-name (expand-file-name name)))) (defvar org-babel-temporary-directory) (unless (or noninteractive (boundp 'org-babel-temporary-directory)) @@ -2707,6 +2706,11 @@ additionally processed by `shell-quote-argument'" Used by `org-babel-temp-file'. This directory will be removed on Emacs shutdown.")) +(defcustom org-babel-remote-temporary-directory "/tmp/" + "Directory to hold temporary files on remote hosts." + :group 'org-babel + :type 'string) + (defmacro org-babel-result-cond (result-params scalar-form &rest table-forms) "Call the code to parse raw string results according to RESULT-PARAMS." (declare (indent 1) @@ -2736,7 +2740,8 @@ of `org-babel-temporary-directory'." (if (file-remote-p default-directory) (let ((prefix (concat (file-remote-p default-directory) - (expand-file-name prefix temporary-file-directory)))) + (expand-file-name + prefix org-babel-remote-temporary-directory)))) (make-temp-file prefix nil suffix)) (let ((temporary-file-directory (or (and (boundp 'org-babel-temporary-directory) -- 1.8.1.2