# HG changeset patch # User Michael Albinus # Date 1209288581 0 # Node ID f020c9568544e13c2900c9852ede47d6b5efb95f # Parent d1731f0f80487ec9e08d2739b5b9cf2df4ee7b85 * net/tramp.el (tramp-replace-environment-variables): New defun. (tramp-handle-substitute-in-file-name, tramp-file-name-handler): Use it. diff -r d1731f0f8048 -r f020c9568544 lisp/net/tramp.el --- a/lisp/net/tramp.el Sun Apr 27 09:06:42 2008 +0000 +++ b/lisp/net/tramp.el Sun Apr 27 09:29:41 2008 +0000 @@ -3557,11 +3557,23 @@ (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 @@ "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