From dba1be0a9b3e92717f7921335f8507c007df8ca6 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 17 Dec 2019 10:38:42 +0100 Subject: [PATCH] Improve Tramp's file-name-completion * lisp/net/tramp.el (tramp-handle-file-name-completion): Filter out "./" and "../", if there's only one other result. --- lisp/net/tramp.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 8988e57b8df..4b44d7a8031 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -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 -- 2.39.2