diff --git a/CHANGELOG.md b/CHANGELOG.md index 4da142d65..3d171a6d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ ### Bugs fixed * [#3235](https://github.com/clojure-emacs/cider/issues/3235): Check `name` is a TRAMP file in `cider--client-tramp-filename` via `tramp-tramp-file-p`. +- [#3234](https://github.com/clojure-emacs/cider/pull/3234) Autocomplete multiple available ports on nRepl connect. ## 1.4.1 (2022-05-25) diff --git a/cider.el b/cider.el index 9aeae4212..827091dfd 100644 --- a/cider.el +++ b/cider.el @@ -1625,10 +1625,11 @@ of remote SSH hosts." When DIR is non-nil also look for nREPL port files in DIR. Return a list of list of the form (project-dir port)." (let* ((paths (cider--running-nrepl-paths)) - (proj-ports (mapcar (lambda (d) - (when-let* ((port (and d (nrepl-extract-port (cider--file-path d))))) - (list (file-name-nondirectory (directory-file-name d)) port))) - (cons (clojure-project-dir dir) paths)))) + (proj-ports (apply #'append + (mapcar (lambda (d) + (mapcar (lambda (p) (list (file-name-nondirectory (directory-file-name d)) p)) + (and d (nrepl-extract-ports (cider--file-path d))))) + (cons (clojure-project-dir dir) paths))))) (seq-uniq (delq nil proj-ports)))) (defun cider--running-nrepl-paths () diff --git a/nrepl-client.el b/nrepl-client.el index 8b3c8a116..c80906933 100644 --- a/nrepl-client.el +++ b/nrepl-client.el @@ -237,6 +237,16 @@ PARAMS is as in `nrepl-make-buffer-name'." (nrepl--port-from-file (expand-file-name "target/repl-port" dir)) (nrepl--port-from-file (expand-file-name ".shadow-cljs/nrepl.port" dir)))) +(defun nrepl-extract-ports (dir) + "Read ports from applicable repl-port files in directory DIR." + (delq nil + (list (nrepl--port-from-file (expand-file-name "repl-port" dir)) + (nrepl--port-from-file (expand-file-name ".nrepl-port" dir)) + (nrepl--port-from-file (expand-file-name "target/repl-port" dir)) + (nrepl--port-from-file (expand-file-name ".shadow-cljs/nrepl.port" dir))))) + +(make-obsolete 'nrepl-extract-port 'nrepl-extract-ports "1.4.2") + (defun nrepl--port-from-file (file) "Attempts to read port from a file named by FILE." (when (file-exists-p file)