Function: cider--infer-ports
cider--infer-ports is a byte-compiled function defined in
cider-endpoint.el.
Signature
(cider--infer-ports HOST SSH-HOSTS)
Documentation
Infer nREPL ports on HOST.
Return a list of elements of the form (directory port). SSH-HOSTS is a list of remote SSH hosts.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-endpoint.el
(defun cider--infer-ports (host ssh-hosts)
"Infer nREPL ports on HOST.
Return a list of elements of the form (directory port). SSH-HOSTS is a list
of remote SSH hosts."
(let ((localp (or (nrepl-local-host-p host)
(not (assoc-string host ssh-hosts)))))
(if localp
(let* ((container-method (nrepl--tramp-container-method))
(container (and container-method
(file-remote-p default-directory 'host)))
;; A container's nREPL is only reachable through the ports it
;; publishes on the local host, so scan inside the container
;; and translate each suggestion; unpublished ports are
;; unreachable from Emacs and get dropped.
(container-pairs
(when container-method
(delq nil
(mapcar (lambda (pair)
(when-let* ((published (nrepl--container-published-port
container-method container
(string-to-number (cadr pair)))))
(list (car pair) (number-to-string published))))
(cider-locate-running-nrepl-ports default-directory)))))
;; change dir: current file might be remote
(change-dir-p (file-remote-p default-directory))
(default-directory (if change-dir-p "~/" default-directory)))
(append container-pairs
(cider-locate-running-nrepl-ports (unless change-dir-p default-directory))))
(when cider-infer-remote-nrepl-ports
(let ((vec (vector "sshx" nil host "" nil))
;; change dir: user might want to connect to a different remote
(dir (when (file-remote-p default-directory)
(with-parsed-tramp-file-name default-directory cur
(when (string= cur-host host) default-directory)))))
(tramp-maybe-open-connection (cider--tramp-file-name vec))
(with-current-buffer (tramp-get-connection-buffer (cider--tramp-file-name vec))
(cider-locate-running-nrepl-ports dir)))))))