From efe26b4dc2693619cc3d569c5da9dd2a43323044 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Fri, 6 Jan 2023 09:48:02 +0000 Subject: [PATCH] Improve handling of non-default completion styles with Tramp methods * lisp/net/tramp.el (tramp-completion-handle-file-name-all-completions): Do not return Tramp methods when the filename already contains a complete method and completion-styles contain 'substring' and/or 'flex'. * lisp/icomplete.el (icomplete--fido-mode-setup): Add 'basic' after 'flex' in the completion styles, for cases where 'flex' does not return anything. This is required by Tramp. * doc/misc/tramp.texi (File name completion): Remove the footnote about the limitation of the 'substring' and 'flex' completion styles. Fixes bug#50387, bug#51386, bug#52758, bug#53513, bug#54042 and bug#60505. --- doc/misc/tramp.texi | 5 +---- lisp/icomplete.el | 3 ++- lisp/net/tramp.el | 13 +++++++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 56436d3297..c43d9a9991 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -3497,10 +3497,7 @@ File name completion Type @kbd{s h @value{postfixhop}} for the minibuffer completion to @samp{@value{prefix}ssh@value{postfixhop}}. Typing @kbd{@key{TAB}} shows host names @value{tramp} extracts from @file{~/.ssh/config} -@c bug#50387 -file, for example@footnote{Some completion styles, like -@code{substring} or @code{flex}, require to type at least one -character after the trailing @samp{@value{postfixhop}}.}. +file, for example. @example @group diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 9fa622017f..e91c2f254a 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -414,7 +414,8 @@ icomplete--fido-mode-setup icomplete-show-matches-on-no-input t icomplete-hide-common-prefix nil icomplete-scroll (not (null icomplete-vertical-mode)) - completion-styles '(flex) + ;; The 'basic' style is required by Tramp. + completion-styles '(flex basic) completion-flex-nospace nil completion-ignore-case t read-buffer-completion-ignore-case t diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index f0b17ef393..8e0b0e9c6e 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3022,8 +3022,17 @@ tramp-completion-handle-file-name-all-completions (delq nil all-user-hosts))))) ;; Possible methods. - (setq result - (append result (tramp-get-completion-methods m))))))) + ;; FIXME: This is a workaround to handle the substring and + ;; flex completion styles in a better way, until a better + ;; fix to handle Tramp methods, possibly in the code of + ;; these completion styles, is implemented. See + ;; bug#50387, bug#51386, bug#52758, bug#53513, bug#54042 + ;; and bug#60505. + (unless (and (string-empty-p method) + (or (memq 'substring completion-styles) + (memq 'flex completion-styles))) + (setq result + (append result (tramp-get-completion-methods m)))))))) ;; Unify list, add hop, remove nil elements. (dolist (elt result) -- 2.39.0