]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve Tramp's file-name-completion
authorMichael Albinus <michael.albinus@gmx.de>
Tue, 17 Dec 2019 09:38:42 +0000 (10:38 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Tue, 17 Dec 2019 09:38:42 +0000 (10:38 +0100)
* lisp/net/tramp.el (tramp-handle-file-name-completion):
Filter out "./" and "../", if there's only one other result.

lisp/net/tramp.el

index 8988e57b8df13db8914132b6360a1243b7b5bc49..4b44d7a803135495b0761609c1338b3c5548a2d8 100644 (file)
@@ -3259,10 +3259,16 @@ User is always nil."
 (defun tramp-handle-file-name-completion
   (filename directory &optional predicate)
   "Like `file-name-completion' for Tramp files."
-  (let (hits-ignored-extensions)
+  (let (hits-ignored-extensions fnac)
+    (setq fnac (file-name-all-completions filename directory))
+    ;; "." and ".." are never interesting as completions, and are
+    ;; actually in the way in a directory with only one file.  See
+    ;; file_name_completion() in dired.c.
+    (when (and (consp fnac) (= (length (delete "./" (delete "../" fnac))) 1))
+      (setq fnac (delete "./" (delete "../" fnac))))
     (or
      (try-completion
-      filename (file-name-all-completions filename directory)
+      filename fnac
       (lambda (x)
        (when (funcall (or predicate #'identity) (expand-file-name x directory))
          (not