[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cider 0f4887b253 1/2: Locate multiple ports for a single p
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cider 0f4887b253 1/2: Locate multiple ports for a single project |
Date: |
Wed, 10 Aug 2022 11:58:20 -0400 (EDT) |
branch: elpa/cider
commit 0f4887b253cd0a6178bf5763df096161b7dad40f
Author: Daniel Midwood <dan@danmidwood.com>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>
Locate multiple ports for a single project
Searching for a nrepl port to connect to would return a maximum of one
port per project, ignoring any others that you might want to connect
to. This creates a case where when connecting to a shadow-cljs nrepl
server the port is not presented to you as a completion when you
already have another nrepl server running.
This commit changes nrepl-extract-port to nrepl-extract-ports and the
return type from a single port to a list of ports (including nils
where a specific project type nrepl port file doesn't exist) to
provide the full view of nrepl servers that are available in the
project, and then the cider-locate-running-nrepl-ports fn is changed
to accommodate that.
This fixes #3140.
---
CHANGELOG.md | 1 +
cider.el | 9 +++++----
nrepl-client.el | 10 ++++++++++
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4da142d65a..3d171a6d6d 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 9aeae4212d..827091dfd6 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 8b3c8a1167..c80906933d 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)