]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix file name completion in Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Thu, 24 May 2018 14:55:16 +0000 (16:55 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Thu, 24 May 2018 14:55:16 +0000 (16:55 +0200)
* 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.

lisp/net/tramp.el
test/lisp/net/tramp-tests.el

index cc3130e2122790c575b7a3941c2013b37e0239e2..398372883b39fdaf41c29e694c322d11bf735e75 100644 (file)
@@ -3153,15 +3153,11 @@ User is always nil."
 
 (defun tramp-handle-file-name-directory (file)
   "Like `file-name-directory' but aware of Tramp files."
-  ;; Everything except the last filename thing is the directory.  We
-  ;; cannot apply `with-parsed-tramp-file-name', because this expands
-  ;; the remote file name parts.  This is a problem when we are in
-  ;; file name completion.
-  (let ((v (tramp-dissect-file-name file t)))
+  (with-parsed-tramp-file-name file nil
+    (setf (tramp-file-name-localname v) nil)
     ;; Run the command on the localname portion only.
     (tramp-make-tramp-file-name
-     v (tramp-run-real-handler
-       'file-name-directory (list (or (tramp-file-name-localname v) ""))))))
+     v (tramp-run-real-handler'file-name-directory (list localname)))))
 
 (defun tramp-handle-file-name-nondirectory (file)
   "Like `file-name-nondirectory' but aware of Tramp files."
index 65ffcb34f7636f5e8720a82c45cb4aca77a3ec44..09e9bac9e5c75126926bb5b9c4bef2a9d1c32329 100644 (file)
@@ -1938,6 +1938,14 @@ This checks also `file-name-as-directory', `file-name-directory',
    (string-equal
     (file-name-directory "/method:host:/path/to/file/")
     "/method:host:/path/to/file/"))
+  (should
+   (string-equal (file-name-directory "/method:host:file") "/method:host:"))
+  (should
+   (string-equal
+    (file-name-directory "/method:host:path/") "/method:host:path/"))
+  (should
+   (string-equal
+    (file-name-directory "/method:host:path/to") "/method:host:path/"))
   (should
    (string-equal (file-name-nondirectory "/method:host:/path/to/file") "file"))
   (should