diff --git a/lisp/eshell/em-tramp.el b/lisp/eshell/em-tramp.el index 94eb9797033..c90e689f6de 100644 --- a/lisp/eshell/em-tramp.el +++ b/lisp/eshell/em-tramp.el @@ -51,11 +51,23 @@ eshell-tramp-initialize "Initialize the Tramp-using commands code." (when (eshell-using-module 'eshell-cmpl) (add-hook 'pcomplete-try-first-hook - 'eshell-complete-host-reference nil t)) + 'eshell-complete-partial-tramp-file-name)) (setq-local eshell-complex-commands (append '("su" "sudo" "doas") eshell-complex-commands))) +(defun eshell-complete-partial-tramp-file-name () + "Complete a partial Tramp file name (method, user name, hostname)." + (let ((arg (pcomplete-actual-arg)) + (non-essential t) + (minibuffer-completing-file-name t)) + (when (string-match tramp-completion-file-name-regexp arg) + (setq pcomplete-stub (substring arg (length tramp-prefix-format)) + pcomplete-last-completion-raw t + pcomplete-termination-string "") + (throw 'pcomplete-completions + (file-name-all-completions pcomplete-stub tramp-prefix-format))))) + (autoload 'eshell-parse-command "esh-cmd") (defun eshell/su (&rest args)