From: Michael Albinus Date: Wed, 31 Oct 2018 19:04:04 +0000 (+0100) Subject: Remote file name completion is also performed by auth-sources search X-Git-Tag: emacs-27.0.90~4235 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0913f18dbebd8480289863480cd147a63ee59cca;p=emacs.git Remote file name completion is also performed by auth-sources search * doc/misc/tramp.texi (File name completion): User and host name completion is also performed by auth-sources search. * etc/NEWS: Document remote file name completion using auth-sources. * lisp/net/tramp.el (tramp-completion-use-auth-sources): New user option. (tramp-parse-auth-sources): New defun. (tramp-get-completion-function): Call it. --- diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 128501c3908..f68205519f3 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -2538,6 +2538,14 @@ names on that host. 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. diff --git a/etc/NEWS b/etc/NEWS index 226ae1e1353..ac23b3b1814 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -750,6 +750,11 @@ are obsoleted in GVFS. +++ *** 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. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index a1246659d8d..13c3b5f939c 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1985,6 +1985,8 @@ For definition of that list see `tramp-set-completion-function'." (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. @@ -2788,6 +2790,23 @@ This function is added always in `tramp-get-completion-function' 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.