diff options
| author | Michael Albinus | 2018-05-24 16:55:16 +0200 |
|---|---|---|
| committer | Michael Albinus | 2018-05-24 16:55:16 +0200 |
| commit | 9fe9f21515ccb4562269cc6ce8dfcebc4cd11384 (patch) | |
| tree | aa26d99797ddc401bd01e70f27304e3043cdaa44 | |
| parent | 5444cb5f6867d43d1c21f30949e2002d8450cbc2 (diff) | |
| download | emacs-9fe9f21515ccb4562269cc6ce8dfcebc4cd11384.tar.gz emacs-9fe9f21515ccb4562269cc6ce8dfcebc4cd11384.zip | |
Fix file name completion in Tramp
* lisp/net/tramp.el (tramp-handle-file-name-directory): Fix case
of localname starts w/o a slash.
* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name):
Extend test.
| -rw-r--r-- | lisp/net/tramp.el | 10 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 8 |
2 files changed, 11 insertions, 7 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index cc3130e2122..398372883b3 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -3153,15 +3153,11 @@ User is always nil." | |||
| 3153 | 3153 | ||
| 3154 | (defun tramp-handle-file-name-directory (file) | 3154 | (defun tramp-handle-file-name-directory (file) |
| 3155 | "Like `file-name-directory' but aware of Tramp files." | 3155 | "Like `file-name-directory' but aware of Tramp files." |
| 3156 | ;; Everything except the last filename thing is the directory. We | 3156 | (with-parsed-tramp-file-name file nil |
| 3157 | ;; cannot apply `with-parsed-tramp-file-name', because this expands | 3157 | (setf (tramp-file-name-localname v) nil) |
| 3158 | ;; the remote file name parts. This is a problem when we are in | ||
| 3159 | ;; file name completion. | ||
| 3160 | (let ((v (tramp-dissect-file-name file t))) | ||
| 3161 | ;; Run the command on the localname portion only. | 3158 | ;; Run the command on the localname portion only. |
| 3162 | (tramp-make-tramp-file-name | 3159 | (tramp-make-tramp-file-name |
| 3163 | v (tramp-run-real-handler | 3160 | v (tramp-run-real-handler'file-name-directory (list localname))))) |
| 3164 | 'file-name-directory (list (or (tramp-file-name-localname v) "")))))) | ||
| 3165 | 3161 | ||
| 3166 | (defun tramp-handle-file-name-nondirectory (file) | 3162 | (defun tramp-handle-file-name-nondirectory (file) |
| 3167 | "Like `file-name-nondirectory' but aware of Tramp files." | 3163 | "Like `file-name-nondirectory' but aware of Tramp files." |
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 65ffcb34f76..09e9bac9e5c 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -1939,6 +1939,14 @@ This checks also `file-name-as-directory', `file-name-directory', | |||
| 1939 | (file-name-directory "/method:host:/path/to/file/") | 1939 | (file-name-directory "/method:host:/path/to/file/") |
| 1940 | "/method:host:/path/to/file/")) | 1940 | "/method:host:/path/to/file/")) |
| 1941 | (should | 1941 | (should |
| 1942 | (string-equal (file-name-directory "/method:host:file") "/method:host:")) | ||
| 1943 | (should | ||
| 1944 | (string-equal | ||
| 1945 | (file-name-directory "/method:host:path/") "/method:host:path/")) | ||
| 1946 | (should | ||
| 1947 | (string-equal | ||
| 1948 | (file-name-directory "/method:host:path/to") "/method:host:path/")) | ||
| 1949 | (should | ||
| 1942 | (string-equal (file-name-nondirectory "/method:host:/path/to/file") "file")) | 1950 | (string-equal (file-name-nondirectory "/method:host:/path/to/file") "file")) |
| 1943 | (should | 1951 | (should |
| 1944 | (string-equal (file-name-nondirectory "/method:host:/path/to/file/") "")) | 1952 | (string-equal (file-name-nondirectory "/method:host:/path/to/file/") "")) |