Skip to content

Commit ddce948

Browse files
committed
cider-eval: support re-rendering the Inspector buffer when cider-inspector-auto-select-buffer is set to nil and there's a *cider-inspect* buffer shown in a non-visible frame
This supports the workflow of using the inspector occasionally (less intrusively), but ready to be shown anytime.
1 parent 7826a2d commit ddce948

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

CHANGELOG.md

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

1414
### Changes
1515

16+
- `cider-eval`: support re-rendering the Inspector buffer when `cider-inspector-auto-select-buffer` is set to nil and there's a `*cider-inspect*` buffer shown in a non-visible frame.
17+
- This supports the workflow of using the inspector occasionally (less intrusively), but ready to be shown anytime.
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ when `cider-auto-inspect-after-eval' is non-nil."
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)
10061006
(select-window (get-buffer-window buffer)))
10071007
(when cider-eval-register

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

+18
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,24 @@ 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+
(defun cider--get-inspector-window ()
833+
"Returns a window showing the *cider-inspect* buffer,
834+
honoring the `cider-inspector-auto-select-buffer' preference.
835+
836+
May return nil."
837+
(get-buffer-window cider-inspector-buffer
838+
;; pass arguments that work well with the existing
839+
;; `(cider-popup-buffer-display cider-inspector-buffer cider-inspector-auto-select-buffer)'
840+
;; usage in cider-inspector.el,
841+
;; namely: for `cider-inspector-auto-select-buffer' t, only consider windows that can be selected,
842+
;; for `cider-inspector-auto-select-buffer' nil, consider windows in all frames.
843+
(if cider-inspector-auto-select-buffer
844+
'visible
845+
t)))
846+
829847
(provide 'cider-util)
830848

831849
;;; cider-util.el ends here

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ 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-inspector-auto-select-buffer`
21+
for even more fine-grained control over the UX).
22+
23+
TIP: setting `cider-auto-inspect-after-eval` to `t` and `cider-inspector-auto-select-buffer` to nil
24+
allows you to have the cider-inspector permanently open in a background frame. This way,
25+
it's always there as you eval forms, while it doesn't interrupt you when it's not needed.`
2126

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

0 commit comments

Comments
 (0)