Skip to content

Commit e140417

Browse files
committed
cider-eval: Introduce new cider-auto-inspect-after-eval-select-window defcustom
It allows one to have the `*cider-inspect*` buffer rendered without switching to it.
1 parent 7826a2d commit e140417

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
### Changes
1515

16+
- `cider-eval`: Introduce new `cider-auto-inspect-after-eval-select-window` defcustom.
17+
- It allows one to have the `*cider-inspect*` buffer rendered without switching to it.
1618
- [#3626](https://github.com/clojure-emacs/cider/issues/3626): `cider-ns-refresh`: jump to the relevant file/line on errors.
1719
- [#3628](https://github.com/clojure-emacs/cider/issues/3628): `cider-ns-refresh`: summarize errors as an overlay.
1820
- Bump the injected nREPL to [1.1.1](https://github.com/nrepl/nrepl/blob/v1.1.1/CHANGELOG.md#111-2024-02-20).

cider-eval.el

+4-3
Original file line numberDiff line numberDiff line change
@@ -993,17 +993,18 @@ when `cider-auto-inspect-after-eval' is non-nil."
993993
;; and needs no jumping:
994994
phase)))
995995
;; done handler:
996-
(lambda (buffer)
996+
(lambda (_buffer)
997997
(if beg
998998
(unless fringed
999999
(cider--make-fringe-overlays-for-region beg end)
10001000
(setq fringed t))
10011001
(cider--make-fringe-overlay end))
10021002
(when (and cider-auto-inspect-after-eval
10031003
(boundp 'cider-inspector-buffer)
1004-
(windowp (get-buffer-window cider-inspector-buffer 'visible)))
1004+
(windowp (cider--get-inspector-window)))
10051005
(cider-inspect-last-result)
1006-
(select-window (get-buffer-window buffer)))
1006+
(when cider-auto-inspect-after-eval-select-window
1007+
(select-window (cider--get-inspector-window))))
10071008
(when cider-eval-register
10081009
(set-register cider-eval-register res))))))
10091010

cider-inspector.el

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
(require 'easymenu)
3232
(require 'seq)
3333
(require 'cider-eval)
34+
(require 'cider-util)
3435

3536
;; ===================================
3637
;; Inspector Key Map and Derived Mode
3738
;; ===================================
3839

39-
(defconst cider-inspector-buffer "*cider-inspect*")
40-
4140
;;; Customization
4241
(defgroup cider-inspector nil
4342
"Presentation and behavior of the CIDER value inspector."

cider-util.el

+24
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,30 @@ KIND can be the symbols `ns', `var', `emph', `fn', or a face name."
826826
(t x)))
827827
menu-list))
828828

829+
;; Defined here to avoid circular dependencies
830+
(defconst cider-inspector-buffer "*cider-inspect*")
831+
832+
(defcustom cider-auto-inspect-after-eval-select-window t
833+
"When t (and `cider-auto-inspect-after-eval' is also t),
834+
the inspector window will be selected after eval.
835+
836+
When nil, while the underlying *cider-inspect* buffer will be re-rendered,
837+
its window won't be selected.
838+
839+
You may want the nil value if you like having *cider-inspect* in a background frame."
840+
:type 'boolean
841+
:group 'cider
842+
:package-version '(cider . "1.14.0"))
843+
844+
(defun cider--get-inspector-window ()
845+
"Returns a window showing the *cider-inspect* buffer,
846+
honoring the `cider-auto-inspect-after-eval-select-window' preference.
847+
848+
May return nil."
849+
(get-buffer-window cider-inspector-buffer (if cider-auto-inspect-after-eval-select-window
850+
'visible
851+
t)))
852+
829853
(provide 'cider-util)
830854

831855
;;; cider-util.el ends here

doc/modules/ROOT/pages/debugging/inspector.adoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Alternatively, after a regular eval command, you can inspect the last
1717
evaluated value using `cider-inspect-last-result`. When an inspector
1818
buffer is visible in the background, it is automatically updated with
1919
the last result. This behavior can be controlled with the variable
20-
`cider-auto-inspect-after-eval`.
20+
`cider-auto-inspect-after-eval` (and `cider-auto-inspect-after-eval-select-window`,
21+
`cider-inspector-auto-select-buffer` for even more fine-grained control over the UX).
2122

2223
TIP: The inspector can also be invoked in the middle of a debugging
2324
session, see xref:debugging/debugger.adoc[here] for more details.

0 commit comments

Comments
 (0)