Skip to content

Commit

Permalink
Inspector: Introduce jump to previous/next sibling commands
Browse files Browse the repository at this point in the history
Fixes #3529
  • Loading branch information
vemv committed Oct 24, 2023
1 parent 12ac771 commit 1203129
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### New features

- [#3529](https://github.com/clojure-emacs/cider/issues/3529): CIDER inspector: introduce `cider-inspector-previous-sibling`, `cider-inspector-next-sibling` commands ([doc](https://docs.cider.mx/cider/debugging/inspector.html#usage)).

### Changes

- [#3546](https://github.com/clojure-emacs/cider/issues/3546): Inspector: render Java items using `java-mode` syntax coloring.
Expand Down
35 changes: 34 additions & 1 deletion cider-inspector.el
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ by clicking or navigating to them by other means."
(define-key map "p" #'cider-inspector-previous-inspectable-object)
(define-key map "f" #'forward-char)
(define-key map "b" #'backward-char)
(define-key map "9" #'cider-inspector-previous-sibling)
(define-key map "0" #'cider-inspector-next-sibling)
;; Emacs translates S-TAB to BACKTAB on X.
(define-key map [backtab] #'cider-inspector-previous-inspectable-object)
(easy-menu-define cider-inspector-mode-menu map
Expand Down Expand Up @@ -223,8 +225,27 @@ See `cider-sync-request:inspect-pop' and `cider-inspector--render-value'."
(defun cider-inspector-push (idx)
"Inspect the value at IDX in the inspector stack and render it.
See `cider-sync-request:inspect-push' and `cider-inspector--render-value'"
(push (point) cider-inspector-location-stack)
(interactive)
(when-let* ((value (cider-sync-request:inspect-push idx)))
(push (point) cider-inspector-location-stack)
(cider-inspector--render-value value)
(cider-inspector-next-inspectable-object 1)))

(defun cider-inspector-previous-sibling ()
"Inspect the previous sibling value within a sequential parent.
See `cider-sync-request:inspect-previous-sibling' and `cider-inspector--render-value'"
(interactive)
(when-let* ((value (cider-sync-request:inspect-previous-sibling)))
(push (point) cider-inspector-location-stack)
(cider-inspector--render-value value)
(cider-inspector-next-inspectable-object 1)))

(defun cider-inspector-next-sibling ()
"Inspect the next sibling value within a sequential parent.
See `cider-sync-request:inspect-next-sibling' and `cider-inspector--render-value'"
(interactive)
(when-let* ((value (cider-sync-request:inspect-next-sibling)))
(push (point) cider-inspector-location-stack)
(cider-inspector--render-value value)
(cider-inspector-next-inspectable-object 1)))

Expand Down Expand Up @@ -321,6 +342,18 @@ current-namespace."
(cider-nrepl-send-sync-request cider-inspector--current-repl)
(nrepl-dict-get "value")))

(defun cider-sync-request:inspect-previous-sibling ()
"Inspect the previous sibling value within a sequential parent."
(thread-first `("op" "inspect-previous-sibling")
(cider-nrepl-send-sync-request cider-inspector--current-repl)
(nrepl-dict-get "value")))

(defun cider-sync-request:inspect-next-sibling ()
"Inspect the next sibling value within a sequential parent."
(thread-first `("op" "inspect-next-sibling")
(cider-nrepl-send-sync-request cider-inspector--current-repl)
(nrepl-dict-get "value")))

(defun cider-sync-request:inspect-refresh ()
"Re-render the currently inspected value."
(thread-first '("op" "inspect-refresh")
Expand Down
23 changes: 21 additions & 2 deletions doc/modules/ROOT/pages/debugging/inspector.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,59 @@ You'll have access to additional keybindings in the inspector buffer
(which is internally using `cider-inspector-mode`):

|===
| Keyboard shortcut | Description
| Keyboard shortcut | Command | Description

| kbd:[Tab] and kbd:[Shift-Tab] / kdb:[n] and kbd:[p]
| kbd:[Tab] and kbd:[Shift-Tab] / kbd:[n] and kbd:[p]
| `cider-inspector-next-inspectable-object`
| Navigate inspectable sub-objects

| kbd:[f] and kbd:[b]
| `forward-char`, `backward-char`
| Navigate across characters on a line

| kbd:[Return]
| `cider-inspector-operate-on-point`
| Inspect sub-objects

| kbd:[l]
| `cider-inspector-pop`
| Pop to the parent object

| kbd:[g]
| `cider-inspector-refresh`
| Refresh the inspector (e.g. if viewing an atom/ref/agent)

| kbd:[SPC]
| `cider-inspector-next-page`
| Jump to next page in paginated view

| kbd:[M-SPC]
| `cider-inspector-prev-page`
| Jump to previous page in paginated view

| kbd:[s]
| `cider-inspector-set-page-size`
| Set a new page size in paginated view

| kbd:[c]
| `cider-inspector-set-max-coll-size`
| Set a new maximum size above which nested collections are truncated

| kbd:[a]
| `cider-inspector-set-max-atom-length`
| Set a new maximum length above which nested atoms (non-collections) are truncated

| kbd:[d]
| `cider-inspector-def-current-val`
| Defines a var in the REPL namespace with current inspector value. If you tend to always choose the same name(s), you may want to set the `cider-inspector-preferred-var-names` customization option.

| kbd:[9]
| `cider-inspector-previous-sibling`
| Navigates to the previous sibling, within a sequential collection.

| kbd:[0]
| `cider-inspector-next-sibling`
| Navigates to the next sibling, within a sequential collection.
|===

== Configuration
Expand Down

0 comments on commit 1203129

Please sign in to comment.