tramp: Customizing Completion

 
 4.11 Selecting config files for user/host name completion
 =========================================================
 
 ‘tramp-completion-function-alist’ uses predefined files for user and
 host name completion (SeeFile name completion).  For each method,
 it keeps a set of configuration files and a function that can parse that
 file.  Each entry in ‘tramp-completion-function-alist’ is of the form
 (METHOD PAIR1 PAIR2 ...).
 
    Each PAIR is composed of (FUNCTION FILE).  FUNCTION is responsible
 for extracting user names and host names from FILE for completion.
 There are two functions which access this variable:
 
  -- Function: tramp-get-completion-function method
      This function returns the list of completion functions for METHOD.
 
      Example:
           (tramp-get-completion-function "rsh")
 
                ⇒ ((tramp-parse-rhosts "/etc/hosts.equiv")
                    (tramp-parse-rhosts "~/.rhosts"))
 
  -- Function: tramp-set-completion-function method function-list
      This function sets FUNCTION-LIST as list of completion functions
      for METHOD.
 
      Example:
           (tramp-set-completion-function "ssh"
            '((tramp-parse-sconfig "/etc/ssh_config")
              (tramp-parse-sconfig "~/.ssh/config")))
 
                ⇒ ((tramp-parse-sconfig "/etc/ssh_config")
                    (tramp-parse-sconfig "~/.ssh/config"))
 
    The following predefined functions parsing configuration files exist:
 
 ‘tramp-parse-rhosts’
 
      This function parses files which are syntactical equivalent to
      ‘~/.rhosts’.  It returns both host names and user names, if
      specified.
 
 ‘tramp-parse-shosts’
 
      This function parses files which are syntactical equivalent to
      ‘~/.ssh/known_hosts’.  Since there are no user names specified in
      such files, it can return host names only.
 
 ‘tramp-parse-sconfig’
 
      This function returns the host nicknames defined by ‘Host’ entries
      in ‘~/.ssh/config’ style files.
 
 ‘tramp-parse-shostkeys’
 
      SSH2 parsing of directories ‘/etc/ssh2/hostkeys/*’ and
      ‘~/ssh2/hostkeys/*’.  Hosts are coded in file names
      ‘hostkey_PORTNUMBER_HOST-NAME.pub’.  User names are always ‘nil’.
 
 ‘tramp-parse-sknownhosts’
 
      Another SSH2 style parsing of directories like
      ‘/etc/ssh2/knownhosts/*’ and ‘~/ssh2/knownhosts/*’.  This case,
      hosts names are coded in file names ‘HOST-NAME.ALGORITHM.pub’.
      User names are always ‘nil’.
 
 ‘tramp-parse-hosts’
 
      A function dedicated to ‘/etc/hosts’ for host names.
 
 ‘tramp-parse-passwd’
 
      A function which parses ‘/etc/passwd’ files for user names.
 
 ‘tramp-parse-netrc’
 
      A function which parses ‘~/.netrc’ and ‘~/.authinfo’-style files.
 
    To keep a custom file with custom data in a custom structure, a
 custom function has to be provided.  This function must meet the
 following conventions:
 
  -- Function: my-tramp-parse file
      FILE must be either a file on the host, or ‘nil’.  The function
      must return a list of (USER HOST), which are taken as candidates
      for completion for user and host names.
 
      Example:
           (my-tramp-parse "~/.my-tramp-hosts")
 
                ⇒ ((nil "toto") ("daniel" "melancholia"))