emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 9fe9f21: Fix file name completion in Tramp


From: Michael Albinus
Subject: [Emacs-diffs] master 9fe9f21: Fix file name completion in Tramp
Date: Thu, 24 May 2018 10:55:28 -0400 (EDT)

branch: master
commit 9fe9f21515ccb4562269cc6ce8dfcebc4cd11384
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    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.
---
 lisp/net/tramp.el            | 10 +++-------
 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 cc3130e..3983728 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -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."
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 65ffcb3..09e9bac 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',
     (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
    (string-equal (file-name-nondirectory "/method:host:/path/to/file/") ""))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]