From c23c3394aeab609850146767294418e7eab62bbe Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sun, 27 Apr 2008 09:30:36 +0000 Subject: [PATCH] * net/tramp.el (tramp-replace-environment-variables): New defun. (tramp-handle-substitute-in-file-name, tramp-file-name-handler): Use it. --- lisp/ChangeLog | 6 ++++++ lisp/net/tramp.el | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 63e7dedc069..fd624ebcd3f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2008-04-27 Michael Albinus + + * 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 * emacs-lisp/bytecomp.el (byte-compile-file): Doc fix. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index a3053f73ded..4b0b66abf7f 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -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 -- 2.39.2