mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-12 09:28:24 +00:00
Fix inconsistency expanding "//" in Tramp
* doc/misc/tramp.texi (File name completion): Adapt example expanding "//". * lisp/net/tramp.el (tramp-handle-substitute-in-file-name): "//" shall expand the localname only, even when on top of the local part. * test/lisp/net/tramp-tests.el (tramp-test04-substitute-in-file-name): Adapt test.
This commit is contained in:
parent
8fbf28536e
commit
c24c5dc4a4
@ -2509,7 +2509,7 @@ Example:
|
||||
@print{} @trampfn{ssh,melancholia,/etc}
|
||||
|
||||
@kbd{C-x C-f @trampfn{ssh,melancholia,//etc} @key{TAB}}
|
||||
@print{} /etc
|
||||
@print{} @trampfn{ssh,melancholia,/etc}
|
||||
|
||||
@kbd{C-x C-f @trampfn{ssh,melancholia,/usr/local/bin///etc} @key{TAB}}
|
||||
@print{} /etc
|
||||
|
@ -3554,17 +3554,19 @@ support symbolic links."
|
||||
;; First, we must replace environment variables.
|
||||
(setq filename (tramp-replace-environment-variables filename))
|
||||
(with-parsed-tramp-file-name filename nil
|
||||
;; Ignore in LOCALNAME everything before "//" or "/~".
|
||||
(when (and (stringp localname) (string-match ".+?/\\(/\\|~\\)" localname))
|
||||
(setq filename
|
||||
(concat (file-remote-p filename)
|
||||
(replace-match "\\1" nil nil localname)))
|
||||
;; "/m:h:~" does not work for completion. We use "/m:h:~/".
|
||||
(when (string-match "~$" filename)
|
||||
(setq filename (concat filename "/"))))
|
||||
;; We do not want to replace environment variables, again.
|
||||
(let (process-environment)
|
||||
(tramp-run-real-handler 'substitute-in-file-name (list filename))))))
|
||||
;; Ignore in LOCALNAME everything before "//" or "/~".
|
||||
(when (stringp localname)
|
||||
(if (string-match "//\\(/\\|~\\)" localname)
|
||||
(setq filename (substitute-in-file-name localname))
|
||||
(setq filename
|
||||
(concat (file-remote-p filename)
|
||||
(substitute-in-file-name localname))))))
|
||||
;; "/m:h:~" does not work for completion. We use "/m:h:~/".
|
||||
(if (string-match "~$" filename)
|
||||
(concat filename "/")
|
||||
filename))))
|
||||
|
||||
(defun tramp-handle-set-visited-file-modtime (&optional time-list)
|
||||
"Like `set-visited-file-modtime' for Tramp files."
|
||||
|
@ -1712,39 +1712,59 @@ handled properly. BODY shall not contain a timeout."
|
||||
|
||||
(ert-deftest tramp-test04-substitute-in-file-name ()
|
||||
"Check `substitute-in-file-name'."
|
||||
(should (string-equal (substitute-in-file-name "/method:host://foo") "/foo"))
|
||||
(should (string-equal (substitute-in-file-name "/method:host:///foo") "/foo"))
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name "/method:host://foo") "/method:host:/foo"))
|
||||
(should
|
||||
(string-equal (substitute-in-file-name "/method:host:/path///foo") "/foo"))
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name "/method:host:/path//foo") "/method:host:/foo"))
|
||||
(should
|
||||
(string-equal (substitute-in-file-name "/method:host:/path///foo") "/foo"))
|
||||
;; Quoting local part.
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name "/method:host:/:///foo") "/method:host:/:///foo"))
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name "/method:host:/://foo") "/method:host:/://foo"))
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name "/method:host:/:/path//foo")
|
||||
"/method:host:/:/path//foo"))
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name "/method:host:/:/path///foo")
|
||||
"/method:host:/:/path///foo"))
|
||||
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name "/method:host:/path/~/foo") "/method:host:~/foo"))
|
||||
(substitute-in-file-name "/method:host:/:/path//foo")
|
||||
"/method:host:/:/path//foo"))
|
||||
|
||||
(should
|
||||
(string-equal (substitute-in-file-name "/method:host:/path//~/foo") "~/foo"))
|
||||
(string-equal (substitute-in-file-name "/method:host://~foo") "/~foo"))
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name "/method:host:/~foo") "/method:host:/~foo"))
|
||||
(should
|
||||
(string-equal (substitute-in-file-name "/method:host:/path//~foo") "/~foo"))
|
||||
;; (substitute-in-file-name "/path/~foo") expands only to "/~foo"",
|
||||
;; if $LOGNAME or $USER is "foo". Otherwise, it doesn't expand.
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name
|
||||
"/method:host:/path/~foo") "/method:host:/path/~foo"))
|
||||
;; Quoting local part.
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name "/method:host:/:/path/~/foo")
|
||||
"/method:host:/:/path/~/foo"))
|
||||
(substitute-in-file-name "/method:host:/://~foo") "/method:host:/://~foo"))
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name "/method:host:/:/path//~/foo")
|
||||
"/method:host:/:/path//~/foo"))
|
||||
(substitute-in-file-name "/method:host:/:/~foo") "/method:host:/:/~foo"))
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name
|
||||
"/method:host:/:/path//~foo") "/method:host:/:/path//~foo"))
|
||||
(should
|
||||
(string-equal
|
||||
(substitute-in-file-name
|
||||
"/method:host:/:/path/~foo") "/method:host:/:/path/~foo"))
|
||||
|
||||
(let (process-environment)
|
||||
(should
|
||||
|
Loading…
Reference in New Issue
Block a user