* net/tramp-compat.el (tramp-compat-temporary-file-directory):
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 6 Jun 2012 13:32:36 +0000 (15:32 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Wed, 6 Jun 2012 13:32:36 +0000 (15:32 +0200)
Ensure, that the temp directory is local.

* net/tramp-sh.el (tramp-sh-handle-write-region): Let-bind
`temporary-file-directory'.

lisp/ChangeLog
lisp/net/tramp-compat.el
lisp/net/tramp-sh.el

index 124b2bb..0911da1 100644 (file)
@@ -8,6 +8,12 @@
        * files.el (enable-remote-dir-locals): New option.
        (hack-dir-local-variables): Use it.  (Bug#1933, Bug#6731)
 
+       * net/tramp-compat.el (tramp-compat-temporary-file-directory):
+       Ensure, that the temp directory is local.
+
+       * net/tramp-sh.el (tramp-sh-handle-write-region): Let-bind
+       `temporary-file-directory'.
+
        * progmodes/python.el (python-send-region): Ensure, that the
        temporary file is created also in the remote case.
 
index 2aea87e..3a79269 100644 (file)
 For Emacs, this is the variable `temporary-file-directory', for XEmacs
 this is the function `temp-directory'."
   (cond
-   ((boundp 'temporary-file-directory) (symbol-value 'temporary-file-directory))
+   ((and (boundp 'temporary-file-directory)
+        (not (file-remote-p (symbol-value 'temporary-file-directory))))
+    (symbol-value 'temporary-file-directory))
    ((fboundp 'temp-directory) (tramp-compat-funcall 'temp-directory))
    ((let ((d (getenv "TEMP"))) (and d (file-directory-p d)))
     (file-name-as-directory (getenv "TEMP")))
index b3a5341..9ccf1d8 100644 (file)
@@ -3093,22 +3093,25 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
           'write-region
           (list start end localname append 'no-message lockname confirm))
 
-       (let ((modes (save-excursion (tramp-default-file-modes filename)))
-             ;; We use this to save the value of
-             ;; `last-coding-system-used' after writing the tmp
-             ;; file.  At the end of the function, we set
-             ;; `last-coding-system-used' to this saved value.  This
-             ;; way, any intermediary coding systems used while
-             ;; talking to the remote shell or suchlike won't hose
-             ;; this variable.  This approach was snarfed from
-             ;; ange-ftp.el.
-             coding-system-used
-             ;; Write region into a tmp file.  This isn't really
-             ;; needed if we use an encoding function, but currently
-             ;; we use it always because this makes the logic
-             ;; simpler.
-             (tmpfile (or tramp-temp-buffer-file-name
-                          (tramp-compat-make-temp-file filename))))
+       (let* ((modes (save-excursion (tramp-default-file-modes filename)))
+              ;; We use this to save the value of
+              ;; `last-coding-system-used' after writing the tmp
+              ;; file.  At the end of the function, we set
+              ;; `last-coding-system-used' to this saved value.  This
+              ;; way, any intermediary coding systems used while
+              ;; talking to the remote shell or suchlike won't hose
+              ;; this variable.  This approach was snarfed from
+              ;; ange-ftp.el.
+              coding-system-used
+              ;; Write region into a tmp file.  This isn't really
+              ;; needed if we use an encoding function, but currently
+              ;; we use it always because this makes the logic
+              ;; simpler.  We must also set `temporary-file-directory',
+              ;; because it could point to a remote directory.
+              (temporary-file-directory
+               (tramp-compat-temporary-file-directory))
+              (tmpfile (or tramp-temp-buffer-file-name
+                           (tramp-compat-make-temp-file filename))))
 
          ;; If `append' is non-nil, we copy the file locally, and let
          ;; the native `write-region' implementation do the job.