]> git.eshelyaron.com Git - emacs.git/commitdiff
* net/tramp.el (tramp-replace-environment-variables): New defun.
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 27 Apr 2008 09:30:36 +0000 (09:30 +0000)
committerMichael Albinus <michael.albinus@gmx.de>
Sun, 27 Apr 2008 09:30:36 +0000 (09:30 +0000)
(tramp-handle-substitute-in-file-name, tramp-file-name-handler):
Use it.

lisp/ChangeLog
lisp/net/tramp.el

index 63e7dedc0697a013073733e4b7aa06a3ce271b92..fd624ebcd3f97f69878398c313d2a5c0e68551df 100644 (file)
@@ -1,3 +1,9 @@
+2008-04-27  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp.el (tramp-replace-environment-variables): New defun.
+       (tramp-handle-substitute-in-file-name, tramp-file-name-handler):
+       Use it.
+
 2008-04-27  Glenn Morris  <rgm@gnu.org>
 
        * emacs-lisp/bytecomp.el (byte-compile-file): Doc fix.
index a3053f73ded582ace3d714e03f173a9bd40e61a8..4b0b66abf7f52f035be53a1647af4b1bad25ce61 100644 (file)
@@ -3557,11 +3557,23 @@ the result will be a local, non-Tramp, filename."
          (tramp-run-real-handler 'expand-file-name
                                  (list localname))))))))
 
+(defun tramp-replace-environment-variables (filename)
+  "Replace environment variables in FILENAME.
+Return the string with the replaced variables."
+  (when (string-match "$\\w+" filename)
+    (setq filename
+         (replace-match
+          (substitute-in-file-name (match-string 0 filename))
+          t nil filename)))
+  filename)
+
 (defun tramp-handle-substitute-in-file-name (filename)
   "Like `substitute-in-file-name' for Tramp files.
 \"//\" and \"/~\" substitute only in the local filename part.
 If the URL Tramp syntax is chosen, \"//\" as method delimeter and \"/~\" at
 beginning of local filename are not substituted."
+  ;; First, we must replace environment variables.
+  (setq filename (tramp-replace-environment-variables filename))
   (with-parsed-tramp-file-name filename nil
     (if (equal tramp-syntax 'url)
        ;; We need to check localname only.  The other parts cannot contain
@@ -4451,7 +4463,9 @@ ARGS are the arguments OPERATION has been called with."
   "Invoke Tramp file name handler.
 Falls back to normal file name handler if no Tramp file name handler exists."
   (save-match-data
-    (let* ((filename (apply 'tramp-file-name-for-operation operation args))
+    (let* ((filename
+           (tramp-replace-environment-variables
+            (apply 'tramp-file-name-for-operation operation args)))
           (completion (tramp-completion-mode-p))
           (foreign (tramp-find-foreign-file-name-handler filename)))
       (with-parsed-tramp-file-name filename nil