Function: pcmpl-ssh-known-hosts

pcmpl-ssh-known-hosts is a byte-compiled function defined in pcmpl-unix.el.gz.

Signature

(pcmpl-ssh-known-hosts)

Documentation

Return a list of hosts found in pcmpl-ssh-known-hosts-file.

Source Code

;; Defined in /usr/src/emacs/lisp/pcmpl-unix.el.gz
;;; Network commands

;; ssh support by Phil Hagelberg.
;; https://www.emacswiki.org/cgi-bin/wiki/pcmpl-ssh.el

(defun pcmpl-ssh-known-hosts ()
  "Return a list of hosts found in `pcmpl-ssh-known-hosts-file'."
  (when (and pcmpl-ssh-known-hosts-file
             (file-readable-p pcmpl-ssh-known-hosts-file))
    (with-temp-buffer
      (insert-file-contents-literally pcmpl-ssh-known-hosts-file)
      (let ((host-re "\\(?:\\([-.[:alnum:]]+\\)\\|\\[\\([-.[:alnum:]]+\\)\\]:[0-9]+\\)[, ]")
            ssh-hosts-list)
        (while (re-search-forward (concat "^ *" host-re) nil t)
          (push (concat (match-string 1)
                        (match-string 2))
                ssh-hosts-list)
          (while (and (eq (char-before) ?,)
                      (re-search-forward host-re (line-end-position) t))
            (push  (concat (match-string 1)
                           (match-string 2))
                   ssh-hosts-list)))
        ssh-hosts-list))))