Function: nrepl--port-from-file
nrepl--port-from-file is a byte-compiled function defined in
nrepl-client.el.
Signature
(nrepl--port-from-file FILE)
Documentation
Attempt to read port from a file named by FILE.
Discards it if it can be determined that the port is not active.
Source Code
;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/nrepl-client.el
(defun nrepl--port-from-file (file)
"Attempt to read port from a file named by FILE.
Discards it if it can be determined that the port is not active."
(when (file-exists-p file)
(when-let* ((port-string (with-temp-buffer
(insert-file-contents file)
;; trim: some tools write a trailing newline,
;; which pollutes completion candidates and
;; breaks dedup against lsof-sourced ports
(string-trim (buffer-string))))
;; extract the number, most of all for not passing garbage to `lsof' (which might even be a security risk):
(port-number (nrepl--port-string-to-number port-string)))
(when (nrepl--port-alive-p port-number)
port-string))))