Skip to content

Commit 151b02b

Browse files
authored
Introduce errors-only value for cider-use-overlays (#3524)
Fixes #3522
1 parent b83c997 commit 151b02b

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
- [#3521](https://github.com/clojure-emacs/cider/issues/3521): Expand `cider-clojure-compilation-regexp` to also match e.g. `Unexpected error (ExceptionInfo) macroexpanding defmulti at (src/ns.clj:1:1).`.
88
- Remove module info from the [CIDER error overlay](https://docs.cider.mx/cider/usage/dealing_with_errors.html#configuration).
99
- Example string that is now trimmed away: `(java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.IObj is in unnamed module of loader 'app')`
10+
- [#3522](https://github.com/clojure-emacs/cider/issues/3522): Introduce a new possible value for [`cider-use-overlays`](https://docs.cider.mx/cider/usage/code_evaluation.html#overlays): `errors-only`.
11+
- If specified, only errors will result in an overlay being shown.
1012

1113
## 1.8.2 (2023-10-15)
1214

@@ -45,15 +47,14 @@
4547
- [#3383](https://github.com/clojure-emacs/cider/issues/3383): `cider-connect-clj&cljs`: don't render `"ClojureScript REPL type:"` for JVM repls.
4648
- [#3331](https://github.com/clojure-emacs/cider/issues/3331): `cider-eval`: never jump to spurious locations, as sometimes conveyed by nREPL.
4749
- [#3112](https://github.com/clojure-emacs/cider/issues/3112): Fix the CIDER `xref-find-references` backend to return correct filenames.
48-
- [#3393](https://github.com/clojure-emacs/cider/issues/3393): recompute namespace info on each shadow-cljs recompilation or evaluation.
4950
- [#3402](https://github.com/clojure-emacs/cider/issues/3402): Fix `cider-format-connection-params` edge case for Emacs 29.
5051
- [#3393](https://github.com/clojure-emacs/cider/issues/3393): Recompute namespace info on each shadow-cljs recompilation or evaluation.
5152
- Recompute namespace info on each fighweel-main recompilation.
5253
- [#3250](https://github.com/clojure-emacs/cider/issues/3250): Don't lose the CIDER session over TRAMP files.
5354
- [#3413](https://github.com/clojure-emacs/cider/issues/3413): Make jump-to-definition work in projects needing `cider-path-translations` (i.e. Dockerized projects).
5455
- [#2436](https://github.com/clojure-emacs/cider/issues/2436): Prevent malformed `cider-repl-history-file`s from failing `cider-jack-in`.
5556
- [#3456](https://github.com/clojure-emacs/cider/issues/3456): Restore xref-based jump-to-definition in Babashka (and any nREPL clients not having cider-nrepl).
56-
- [#3466](https://github.com/clojure-emacs/cider/issues/3466): Restore usual `cider--connected-handler` performance for JVM Clojure repls.
57+
- [#3466](https://github.com/clojure-emacs/cider/issues/3466): Restore the usual `cider--connected-handler` performance for JVM Clojure repls.
5758
- [#3503](https://github.com/clojure-emacs/cider/issues/3503): Make `cider-repl-set-ns` more reliable on Piggieback connections.
5859
- Fix the `xref-find-definitions` CIDER backend to return correct filenames.
5960
- Fix the `cider-xref-fn-deps` buttons to direct to the right file.

cider-eval.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ when `cider-auto-inspect-after-eval' is non-nil."
840840
(nrepl-make-response-handler (or buffer eval-buffer)
841841
(lambda (_buffer value)
842842
(setq res (concat res value))
843-
(cider--display-interactive-eval-result res end))
843+
(cider--display-interactive-eval-result res 'value end))
844844
(lambda (_buffer out)
845845
(cider-emit-interactive-eval-output out))
846846
(lambda (buffer err)
@@ -864,6 +864,7 @@ when `cider-auto-inspect-after-eval' is non-nil."
864864
(string-trim))))
865865
(cider--display-interactive-eval-result
866866
trimmed-err
867+
'error
867868
end
868869
'cider-error-overlay-face)))
869870

@@ -897,7 +898,7 @@ Optional argument DONE-HANDLER lambda will be run once load is complete."
897898
(res ""))
898899
(nrepl-make-response-handler (or buffer eval-buffer)
899900
(lambda (buffer value)
900-
(cider--display-interactive-eval-result value)
901+
(cider--display-interactive-eval-result value 'value)
901902
(when cider-eval-register
902903
(setq res (concat res value)))
903904
(when (buffer-live-p buffer)

cider-overlays.el

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ font-locking it."
7070
(defcustom cider-use-overlays 'both
7171
"Whether to display evaluation results with overlays.
7272
If t, use overlays determined by `cider-result-overlay-position'.
73+
If `errors-only', use overlays determined by `cider-result-overlay-position',
74+
but only for error messages - other messages will be displayed on the echo area.
7375
If nil, display on the echo area.
74-
If both, display on both places.
76+
If `both', display on both places.
7577
7678
Only applies to evaluation commands. To configure the debugger overlays,
7779
see `cider-debug-use-overlays'."
@@ -290,21 +292,27 @@ overlay."
290292

291293

292294
;;; Displaying eval result
293-
(defun cider--display-interactive-eval-result (value &optional point overlay-face)
295+
(defun cider--display-interactive-eval-result (value value-type &optional point overlay-face)
294296
"Display the result VALUE of an interactive eval operation.
295297
VALUE is syntax-highlighted and displayed in the echo area.
298+
VALUE-TYPE is one of: `value', `error'.
296299
OVERLAY-FACE is the face applied to the overlay, which defaults to
297300
`cider-result-overlay-face' if nil.
298301
If POINT and `cider-use-overlays' are non-nil, it is also displayed in an
299302
overlay at the end of the line containing POINT.
300303
Note that, while POINT can be a number, it's preferable to be a marker, as
301304
that will better handle some corner cases where the original buffer is not
302305
focused."
306+
(cl-assert (symbolp value-type)) ;; We assert because for avoiding confusion with the optional args.
303307
(let* ((font-value (if cider-result-use-clojure-font-lock
304308
(cider-font-lock-as-clojure value)
305309
value))
306310
(font-value (string-trim-right font-value))
307-
(used-overlay (when (and point cider-use-overlays)
311+
(used-overlay (when (and point
312+
cider-use-overlays
313+
(if (equal 'error value-type)
314+
t
315+
(not (equal 'errors-only cider-use-overlays))))
308316
(cider--make-result-overlay font-value
309317
:where point
310318
:duration cider-eval-result-duration

doc/modules/ROOT/pages/usage/code_evaluation.adoc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,18 @@ variable.
189189
(setq cider-overlays-use-font-lock t)
190190
----
191191

192-
You can disable overlays entirely (and display results in the echo-area at the
193-
bottom) with the `cider-use-overlays` variable.
192+
If you don't like seeing overlays so often,
193+
you can restrict overlays to only be shown for errors
194+
(and display non-error results in the echo area at the bottom)
195+
by customizing the `cider-use-overlays` variable:
196+
197+
[source,lisp]
198+
----
199+
(setq cider-use-overlays 'errors-only)
200+
----
201+
202+
You can disable overlays entirely (and display results in the echo area at the
203+
bottom) with the `cider-use-overlays` variable:
194204

195205
[source,lisp]
196206
----

0 commit comments

Comments
 (0)