Skip to content

Commit dba1be0

Browse files
committed
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.
1 parent 4b2c2fa commit dba1be0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lisp/net/tramp.el

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3259,10 +3259,16 @@ User is always nil."
32593259
(defun tramp-handle-file-name-completion
32603260
(filename directory &optional predicate)
32613261
"Like `file-name-completion' for Tramp files."
3262-
(let (hits-ignored-extensions)
3262+
(let (hits-ignored-extensions fnac)
3263+
(setq fnac (file-name-all-completions filename directory))
3264+
;; "." and ".." are never interesting as completions, and are
3265+
;; actually in the way in a directory with only one file. See
3266+
;; file_name_completion() in dired.c.
3267+
(when (and (consp fnac) (= (length (delete "./" (delete "../" fnac))) 1))
3268+
(setq fnac (delete "./" (delete "../" fnac))))
32633269
(or
32643270
(try-completion
3265-
filename (file-name-all-completions filename directory)
3271+
filename fnac
32663272
(lambda (x)
32673273
(when (funcall (or predicate #'identity) (expand-file-name x directory))
32683274
(not

0 commit comments

Comments
 (0)