Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #3634

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

### Changes

- `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.
- [#3626](https://github.com/clojure-emacs/cider/issues/3626): `cider-ns-refresh`: jump to the relevant file/line on errors.
- [#3628](https://github.com/clojure-emacs/cider/issues/3628): `cider-ns-refresh`: summarize errors as an overlay.
- Bump the injected nREPL to [1.1.1](https://github.com/nrepl/nrepl/blob/v1.1.1/CHANGELOG.md#111-2024-02-20).
Expand Down
2 changes: 1 addition & 1 deletion cider-eval.el
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ when `cider-auto-inspect-after-eval' is non-nil."
(cider--make-fringe-overlay end))
(when (and cider-auto-inspect-after-eval
(boundp 'cider-inspector-buffer)
(windowp (get-buffer-window cider-inspector-buffer 'visible)))
(windowp (cider--get-inspector-window)))
(cider-inspect-last-result)
(select-window (get-buffer-window buffer)))
(when cider-eval-register
Expand Down
3 changes: 1 addition & 2 deletions cider-inspector.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
(require 'easymenu)
(require 'seq)
(require 'cider-eval)
(require 'cider-util)

;; ===================================
;; Inspector Key Map and Derived Mode
;; ===================================

(defconst cider-inspector-buffer "*cider-inspect*")

;;; Customization
(defgroup cider-inspector nil
"Presentation and behavior of the CIDER value inspector."
Expand Down
18 changes: 18 additions & 0 deletions cider-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,24 @@ KIND can be the symbols `ns', `var', `emph', `fn', or a face name."
(t x)))
menu-list))

;; Defined here to avoid circular dependencies
(defconst cider-inspector-buffer "*cider-inspect*")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure I like this, because the way I see it the inspector shouldn't be depending on cider-eval and now we're kind of sweeping this odd dependency under the rug.


(defun cider--get-inspector-window ()
"Returns a window showing the *cider-inspect* buffer,
honoring the `cider-inspector-auto-select-buffer' preference.

May return nil."
(get-buffer-window cider-inspector-buffer
;; pass arguments that work well with the existing
;; `(cider-popup-buffer-display cider-inspector-buffer cider-inspector-auto-select-buffer)'
;; usage in cider-inspector.el,
;; namely: for `cider-inspector-auto-select-buffer' t, only consider windows that can be selected,
;; for `cider-inspector-auto-select-buffer' nil, consider windows in all frames.
(if cider-inspector-auto-select-buffer
'visible
t)))

(provide 'cider-util)

;;; cider-util.el ends here
7 changes: 6 additions & 1 deletion doc/modules/ROOT/pages/debugging/inspector.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ Alternatively, after a regular eval command, you can inspect the last
evaluated value using `cider-inspect-last-result`. When an inspector
buffer is visible in the background, it is automatically updated with
the last result. This behavior can be controlled with the variable
`cider-auto-inspect-after-eval`.
`cider-auto-inspect-after-eval` (and `cider-inspector-auto-select-buffer`
for even more fine-grained control over the UX).

TIP: setting `cider-auto-inspect-after-eval` to `t` and `cider-inspector-auto-select-buffer` to nil
allows you to have the cider-inspector permanently open in a background frame. This way,
it's always there as you eval forms, while it doesn't interrupt you when it's not needed.`

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