aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2018-10-31 20:04:04 +0100
committerMichael Albinus2018-10-31 20:04:04 +0100
commit0913f18dbebd8480289863480cd147a63ee59cca (patch)
tree928657cdee62bea8261f93a6c00108dc121e2475
parent42681c54bf5ea2ff9d2a3ec6553766b194454caf (diff)
downloademacs-0913f18dbebd8480289863480cd147a63ee59cca.tar.gz
emacs-0913f18dbebd8480289863480cd147a63ee59cca.zip
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.
-rw-r--r--doc/misc/tramp.texi8
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/net/tramp.el19
3 files changed, 32 insertions, 0 deletions
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.
2538When the configuration (@pxref{Customizing Completion}) includes user 2538When the configuration (@pxref{Customizing Completion}) includes user
2539names, then the completion lists will account for the user names as well. 2539names, then the completion lists will account for the user names as well.
2540 2540
2541@vindex tramp-completion-use-auth-sources
2542Results from @code{auth-sources} search (@pxref{Using an
2543authentication file}) are added to the completion candidates. This
2544search could be annoying, for example due to a passphrase request of
2545the @file{~/.authinfo.gpg} authentication file. The user option
2546@code{tramp-completion-use-auth-sources} controls, whether such a
2547search is performed during completion.
2548
2541Remote hosts previously visited or hosts whose connections are kept 2549Remote hosts previously visited or hosts whose connections are kept
2542persistently (@pxref{Connection caching}) will be included in the 2550persistently (@pxref{Connection caching}) will be included in the
2543completion lists. 2551completion lists.
diff --git a/etc/NEWS b/etc/NEWS
index 226ae1e1353..ac23b3b1814 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -751,6 +751,11 @@ are obsoleted in GVFS.
751*** Validated passwords are saved by auth-source backends which support this. 751*** Validated passwords are saved by auth-source backends which support this.
752 752
753+++ 753+++
754*** During user and host name completion in the minibuffer, results
755from auth-source search are taken into account. This can be disabled
756by setting user option 'tramp-completion-use-auth-sources' to nil.
757
758+++
754*** The user option 'tramp-ignored-file-name-regexp' allows to disable 759*** The user option 'tramp-ignored-file-name-regexp' allows to disable
755Tramp for some look-alike remote file names. 760Tramp for some look-alike remote file names.
756 761
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'."
1985 (append 1985 (append
1986 `(;; Default settings are taken into account. 1986 `(;; Default settings are taken into account.
1987 (tramp-parse-default-user-host ,method) 1987 (tramp-parse-default-user-host ,method)
1988 ;; Hits from auth-sources.
1989 (tramp-parse-auth-sources ,method)
1988 ;; Hosts visited once shall be remembered. 1990 ;; Hosts visited once shall be remembered.
1989 (tramp-parse-connection-properties ,method)) 1991 (tramp-parse-connection-properties ,method))
1990 ;; The method related defaults. 1992 ;; The method related defaults.
@@ -2788,6 +2790,23 @@ This function is added always in `tramp-get-completion-function'
2788for all methods. Resulting data are derived from default settings." 2790for all methods. Resulting data are derived from default settings."
2789 `((,(tramp-find-user method nil nil) ,(tramp-find-host method nil nil)))) 2791 `((,(tramp-find-user method nil nil) ,(tramp-find-host method nil nil))))
2790 2792
2793(defcustom tramp-completion-use-auth-sources auth-source-do-cache
2794 "Whether to use `auth-source-search' for completion of user and host names.
2795This could be disturbing, if it requires a password / passphrase,
2796as for \"~/.authinfo.gpg\"."
2797 :group 'tramp
2798 :version "27.1"
2799 :type 'boolean)
2800
2801(defun tramp-parse-auth-sources (method)
2802 "Return a list of (user host) tuples allowed to access for METHOD.
2803This function is added always in `tramp-get-completion-function'
2804for all methods. Resulting data are derived from default settings."
2805 (and tramp-completion-use-auth-sources
2806 (mapcar
2807 (lambda (x) `(,(plist-get x :user) ,(plist-get x :host)))
2808 (auth-source-search :port method :max most-positive-fixnum))))
2809
2791;; Generic function. 2810;; Generic function.
2792(defun tramp-parse-group (regexp match-level skip-regexp) 2811(defun tramp-parse-group (regexp match-level skip-regexp)
2793 "Return a (user host) tuple allowed to access. 2812 "Return a (user host) tuple allowed to access.