branch: elpa/cider
commit 03bffb62b7c30250979a9b4512c210f165dc36c9
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Make cider-enlighten-mode light things up again
Two client-side regressions conspired to keep enlighten dark (on top of
two more on the cider-nrepl side):
- nrepl-extra-eval-params-function - the decoupled home of the
'enlighten' flag since 1.22 - is local to the connection buffer, but
eval requests are assembled in the source buffer for their file/line
context, so the params were never consulted and the flag never sent.
Look them up against the connection explicitly.
- Enlighten events carry the form's line/column but no source text, and
cider--debug-position-for-code errored on the missing code (swallowed
by the response dispatcher), so no overlay was ever placed. Treat
absent code as nothing-to-verify and trust the position.
---
CHANGELOG.md | 1 +
lisp/cider-debug.el | 9 +++++++--
lisp/nrepl-client.el | 19 +++++++++++++++----
test/nrepl-client-tests.el | 33 +++++++++++++++++++++++++++++++++
4 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0083203744..097e751254 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@
### Bugs fixed
- [#4115](https://github.com/clojure-emacs/cider/pull/4115): Fix inline macro
stepping (`cider-macrostep`): pressing `e`/`RET` right after `n`/`p` now
expands the operator you jumped to, instead of erroring with "No sexp before
point to expand".
+- [#4114](https://github.com/clojure-emacs/cider/pull/4114): Fix
`cider-enlighten-mode` never lighting anything up: the `enlighten` flag was
dropped from eval requests built in source buffers (a 1.22 regression), and the
value overlays were discarded because enlighten events carry no source text to
verify against.
- [#4111](https://github.com/clojure-emacs/cider/issues/4111): Fix the
macroexpansion commands refusing to expand `let`, `fn`, `loop` and `letfn`
(macros that double as special forms), restore the no-op expansion of non-macro
forms (useful for normalizing reader syntax like `::auto/kw` and `#(...)`), and
stop gating `cider-macroexpand-all` on the top-level operator (a
fully-recursive expansion can reach macros in nested sub-forms).
## 2.0.0 (2026-07-15)
diff --git a/lisp/cider-debug.el b/lisp/cider-debug.el
index cb355cb564..d2e73a3a94 100644
--- a/lisp/cider-debug.el
+++ b/lisp/cider-debug.el
@@ -745,8 +745,13 @@ key of a map, and it means \"go to the value associated
with this key\"."
(defun cider--debug-position-for-code (code)
"Return non-nil if point is roughly before CODE.
-This might move point one line above."
- (or (looking-at-p (regexp-quote code))
+This might move point one line above.
+
+A nil CODE counts as a match: enlighten events carry only the form's
+line/column (not its source text), so there is nothing to verify against
+and the position must be trusted as-is."
+ (or (null code)
+ (looking-at-p (regexp-quote code))
(let ((trimmed (regexp-quote (cider--debug-trim-code code))))
(or (looking-at-p trimmed)
;; If this is a fake #dbg injected by `C-u
diff --git a/lisp/nrepl-client.el b/lisp/nrepl-client.el
index 3fe466f452..dd28ca7f0a 100644
--- a/lisp/nrepl-client.el
+++ b/lisp/nrepl-client.el
@@ -1062,14 +1062,22 @@ If LINE and COLUMN are non-nil and current buffer is a
file buffer, \"line\",
`("op" "eval"
"code" ,(substring-no-properties input)
,@(when ns `("ns" ,ns))
- ,@(when nrepl-extra-eval-params-function
- (funcall nrepl-extra-eval-params-function))
,@(let ((file (or (buffer-file-name) (buffer-name))))
(when (and line column file)
`("file" ,file
"line" ,line
"column" ,column)))))
+(defun nrepl--connection-eval-params (connection)
+ "Extra eval-request params contributed by CONNECTION's client.
+`nrepl-extra-eval-params-function' is local to the connection buffer, while
+eval requests are assembled in the originating source buffer (whose file and
+position they carry), so the lookup must target CONNECTION explicitly."
+ (when-let* ((buffer (cond ((buffer-live-p connection) connection)
+ ((stringp connection) (get-buffer connection))))
+ (f (buffer-local-value 'nrepl-extra-eval-params-function
buffer)))
+ (funcall f)))
+
(cl-defun nrepl-send-eval-request (input callback connection
&key ns line column additional-params
tooling)
"Send the request INPUT and register the CALLBACK as the response handler.
@@ -1082,7 +1090,9 @@ ADDITIONAL-PARAMS is a plist to be appended to the
request message.
This is the keyword-argument form; `nrepl-request:eval' is the legacy
positional shim retained for backward compatibility."
- (nrepl-send-request (append (nrepl--eval-request input ns line column)
additional-params)
+ (nrepl-send-request (append (nrepl--eval-request input ns line column)
+ (nrepl--connection-eval-params connection)
+ additional-params)
callback
connection
tooling))
@@ -1147,7 +1157,8 @@ If NS is non-nil, include it in the request
If TOOLING is non-nil the evaluation is done using the tooling nREPL
session."
(nrepl-sync-request
- (nrepl--eval-request input ns)
+ (append (nrepl--eval-request input ns)
+ (nrepl--connection-eval-params connection))
connection
:tooling tooling))
diff --git a/test/nrepl-client-tests.el b/test/nrepl-client-tests.el
index 5765ba1eab..c5153e0bf1 100644
--- a/test/nrepl-client-tests.el
+++ b/test/nrepl-client-tests.el
@@ -554,3 +554,36 @@
(it "does not treat a server message as a format string"
(expect (nrepl-notify "test %s and 100%" "warning") :not :to-throw)
(expect (nrepl-notify "raw 50% done" nil) :not :to-throw)))
+
+(describe "nrepl--connection-eval-params"
+ ;; `nrepl-extra-eval-params-function' lives in the connection buffer, but
+ ;; eval requests are assembled in the source buffer (for their file/line
+ ;; context), so the params must be looked up against the connection - this
+ ;; is how `cider-enlighten-mode' gets its `enlighten' flag onto requests.
+ (it "contributes the connection's extra params from any buffer"
+ (let ((conn (generate-new-buffer " *fake-conn*")))
+ (unwind-protect
+ (progn
+ (with-current-buffer conn
+ (setq-local nrepl-extra-eval-params-function
+ (lambda () '("enlighten" "true"))))
+ (with-temp-buffer ;; an unrelated source buffer
+ (spy-on 'nrepl-send-request)
+ (nrepl-send-eval-request "(inc 1)" #'ignore conn)
+ (let ((request (car (spy-calls-args-for 'nrepl-send-request 0))))
+ (expect (member "enlighten" request) :to-be-truthy))
+ (spy-on 'nrepl-sync-request)
+ (nrepl-sync-request:eval "(inc 1)" conn)
+ (let ((request (car (spy-calls-args-for 'nrepl-sync-request 0))))
+ (expect (member "enlighten" request) :to-be-truthy))))
+ (kill-buffer conn))))
+
+ (it "contributes nothing when the connection sets no params function"
+ (let ((conn (generate-new-buffer " *fake-conn*")))
+ (unwind-protect
+ (with-temp-buffer
+ (spy-on 'nrepl-send-request)
+ (nrepl-send-eval-request "(inc 1)" #'ignore conn)
+ (let ((request (car (spy-calls-args-for 'nrepl-send-request 0))))
+ (expect (member "enlighten" request) :not :to-be-truthy)))
+ (kill-buffer conn)))))