 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
-
+;; Provides an interface to connect to remote hosts.
 ;;
 
 ;;; Code:

(defvar remotehost-connect-history nil
  "History for `remotehost-connect'.")

(defun remotehost-connect--derive-remote-name (plist)
  "Derive the remote file name implied by the settings in PLIST."
  (format "/%s:%s@%s:%s"
          (plist-get plist :method)
          (plist-get plist :user)
          (plist-get plist :host)
          (plist-get plist :dir)))

(defun remotehost-connect--find-file (plist)
  "Opens a remote host location, whose properties are contained in PLIST."
  (let ((file (remotehost-connect--derive-remote-name plist)))
    (find-file file)
    ))

;;;###autoload
(defun remotehost-connect-read-file (file)

    (ivy-read "Remote host: " hosts
              :history 'remotehost-connect-history
              :action (lambda (x)
                        (if (consp x)
                            (remotehost-connect--find-file (cdr x))
                          (remotehost-connect--find-file x)))
              :caller 'remotehost-connect
              )))

