Skip to content

Commit e0074ce

Browse files
Wilfredbbatsov
authored andcommitted
cider--completing-read-port: Default to 7888
Whilst 7888 isn't the official port (see nrepl/nrepl#6 discussion), it's frequently used in practice. Set that as the default value in the minibuffer if we couldn't infer a port. Most nREPL implementations do create a `.nrepl-port` file but it's nice to have 7888 suggested to save a few keystrokes.
1 parent e26a4da commit e0074ce

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- [#3909](https://github.com/clojure-emacs/cider/issues/3909): `cider--sesman-friendly-session-p` is more robust at attaching buffers to existing sessions. The classpath and namespace caches are now populated eagerly at connection time instead of lazily on first sesman call (previously a nil/empty result was indistinguishable from "not cached" and was re-fetched on every check). The matcher is now a pure path comparison and never blocks on the REPL. Beyond the caching fix, it also falls back to the connection's `nrepl-project-dir` when classpath matching fails, uses `file-in-directory-p` for classpath-root boundary checks (avoiding spurious prefix matches like `/foo/bar` against `/foo/barber/...`), and short-circuits to the chosen session when `cider-default-session` is set.
3030
- `nrepl-bencode` no longer crashes when handed a non-string scalar (symbol, float, etc.). The documented fallback ("everything else is encoded as string") used `string-bytes` directly, which errors on non-string input; values are now coerced via `format' before measuring byte length.
3131
- [#3915](https://github.com/clojure-emacs/cider/issues/3915): Fix `cider-repl-history` failing with "Unmatched bracket or quote" on its second invocation in a session when the user's history contained an entry with unbalanced parens. `cider-repl-history-setup` now erases the reused `*cider-repl-history*` buffer before re-entering `cider-repl-history-mode`, so any user-configured `clojure-mode-hook` (e.g. one that runs `check-parens') runs on an empty buffer instead of stale content from the previous render.
32+
- `cider--completing-read-port` now defaults to `7888` when no running nREPL port can be inferred.
3233

3334
### Changes
3435

lisp/cider-endpoint.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ Sub-match 1 must be the project path.")
7070
(defvar cider-host-history nil
7171
"Completion history for connection hosts.")
7272

73+
(defconst cider-default-nrepl-port "7888"
74+
"Use this port number when we couldn't infer a port.
75+
See also https://github.com/nrepl/nREPL/issues/6.")
7376

7477
;;; Endpoint selection
7578

@@ -158,7 +161,8 @@ of remote SSH hosts."
158161
"Interactively select port for HOST from PORTS."
159162
(let* ((ports (cider-join-into-alist ports))
160163
(sel-port (completing-read (format "Port for %s: " host) ports
161-
nil nil nil nil (caar ports)))
164+
nil nil nil nil (or (caar ports)
165+
cider-default-nrepl-port)))
162166
(port (or (cdr (assoc sel-port ports)) sel-port))
163167
(port (if (listp port) (cadr port) port)))
164168
(if (stringp port) (string-to-number port) port)))

0 commit comments

Comments
 (0)