When the configuration (@pxref{Customizing Completion}) includes user
names, then the completion lists will account for the user names as well.
+@vindex tramp-completion-use-auth-sources
+Results from @code{auth-sources} search (@pxref{Using an
+authentication file}) are added to the completion candidates. This
+search could be annoying, for example due to a passphrase request of
+the @file{~/.authinfo.gpg} authentication file. The user option
+@code{tramp-completion-use-auth-sources} controls, whether such a
+search is performed during completion.
+
Remote hosts previously visited or hosts whose connections are kept
persistently (@pxref{Connection caching}) will be included in the
completion lists.
+++
*** Validated passwords are saved by auth-source backends which support this.
++++
+*** During user and host name completion in the minibuffer, results
+from auth-source search are taken into account. This can be disabled
+by setting user option 'tramp-completion-use-auth-sources' to nil.
+
+++
*** The user option 'tramp-ignored-file-name-regexp' allows to disable
Tramp for some look-alike remote file names.
(append
`(;; Default settings are taken into account.
(tramp-parse-default-user-host ,method)
+ ;; Hits from auth-sources.
+ (tramp-parse-auth-sources ,method)
;; Hosts visited once shall be remembered.
(tramp-parse-connection-properties ,method))
;; The method related defaults.
for all methods. Resulting data are derived from default settings."
`((,(tramp-find-user method nil nil) ,(tramp-find-host method nil nil))))
+(defcustom tramp-completion-use-auth-sources auth-source-do-cache
+ "Whether to use `auth-source-search' for completion of user and host names.
+This could be disturbing, if it requires a password / passphrase,
+as for \"~/.authinfo.gpg\"."
+ :group 'tramp
+ :version "27.1"
+ :type 'boolean)
+
+(defun tramp-parse-auth-sources (method)
+ "Return a list of (user host) tuples allowed to access for METHOD.
+This function is added always in `tramp-get-completion-function'
+for all methods. Resulting data are derived from default settings."
+ (and tramp-completion-use-auth-sources
+ (mapcar
+ (lambda (x) `(,(plist-get x :user) ,(plist-get x :host)))
+ (auth-source-search :port method :max most-positive-fixnum))))
+
;; Generic function.
(defun tramp-parse-group (regexp match-level skip-regexp)
"Return a (user host) tuple allowed to access.