Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

## 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.
- [#3528](https://github.com/clojure-emacs/cider/issues/3528): Bump the injected `cider-nrepl` to [0.41.0](https://github.com/clojure-emacs/cider-nrepl/blob/v0.41.0/CHANGELOG.md#0410-2023-10-24).
- Updates [Orchard](https://github.com/clojure-emacs/orchard/blob/v0.17.0/CHANGELOG.md#0170-2023-10-24), providing misc presentational improvements for the CIDER Inspector.

### Bugs fixed

Expand Down
52 changes: 47 additions & 5 deletions 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.
Copy link
Member

Choose a reason for hiding this comment

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

Probably I would have named those next/previous element, so it's clearer we're talking about the elements of some sequence. But I guess the current naming will do.

Copy link
Member Author

Choose a reason for hiding this comment

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

Might have worked, although the overlap with cider-inspector-next-inspectable-object seemed prone to confusion.

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 Expand Up @@ -436,7 +469,13 @@ MAX-COLL-SIZE if non nil."
(cider-inspector-render-el* el)))

(defconst cider--inspector-java-headers
'("--- Interfaces:" "--- Constructors:" "--- Fields:" "--- Methods:" "--- Imports:"))
;; NOTE "--- Static fields:" "--- Instance fields:" are for objects,
;; and don't deserve Java syntax highlighting (they can contain a Clojure value like `:foo/bar`, for instance)
'("--- Interfaces:"
"--- Fields:" ;; rendered only for Class objects (and not other objects) - see previous comment
"--- Constructors:"
"--- Methods:"
"--- Imports:"))

(defun cider-inspector-render-el* (el)
"Render EL."
Expand All @@ -450,9 +489,12 @@ MAX-COLL-SIZE if non nil."
(cond ((symbolp el) (insert (symbol-name el)))
((stringp el) (insert (if cider-inspector-looking-at-java-p
(cider-font-lock-as 'java-mode el)
(propertize el 'font-lock-face (if header-p
'font-lock-comment-face
'font-lock-keyword-face)))))
(let ((trimmed-el (replace-regexp-in-string (regexp-quote "<non-inspectable value>")
""
el)))
(propertize trimmed-el 'font-lock-face (if header-p
'font-lock-comment-face
'font-lock-keyword-face))))))
((and (consp el) (eq (car el) :newline))
(insert "\n"))
((and (consp el) (eq (car el) :value))
Expand Down
2 changes: 1 addition & 1 deletion cider.el
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ the artifact.")
(defconst cider-latest-clojure-version "1.10.1"
"Latest supported version of Clojure.")

(defconst cider-required-middleware-version "0.40.0"
(defconst cider-required-middleware-version "0.41.0"
"The CIDER nREPL version that's known to work properly with CIDER.")

(defcustom cider-injected-middleware-version cider-required-middleware-version
Expand Down
2 changes: 1 addition & 1 deletion dev/docker-sample-project/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
:dependencies [[org.clojure/clojure "1.11.1"]
[clj-http "3.12.3"]]
:source-paths ["src"]
:plugins [[cider/cider-nrepl "0.40.0"]])
:plugins [[cider/cider-nrepl "0.41.0"]])
2 changes: 1 addition & 1 deletion dev/tramp-sample-project/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
:dependencies [[org.clojure/clojure "1.11.1"]
[clj-http "3.12.3"]]
:source-paths ["src"]
:plugins [[cider/cider-nrepl "0.40.0"]
:plugins [[cider/cider-nrepl "0.41.0"]
[refactor-nrepl "3.9.0"]])
10 changes: 5 additions & 5 deletions doc/modules/ROOT/pages/basics/middleware_setup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ Use the convenient plugin for defaults, either in your project's

[source,clojure]
----
:plugins [[cider/cider-nrepl "0.40.0"]]
:plugins [[cider/cider-nrepl "0.41.0"]]
----

A minimal `profiles.clj` for CIDER would be:

[source,clojure]
----
{:repl {:plugins [[cider/cider-nrepl "0.40.0"]]}}
{:repl {:plugins [[cider/cider-nrepl "0.41.0"]]}}
----

WARNING: Be careful not to place this in the `:user` profile, as this way CIDER's
Expand All @@ -59,7 +59,7 @@ all of their projects using a `~/.boot/profile.boot` file like so:
(require 'boot.repl)

(swap! boot.repl/*default-dependencies*
concat '[[cider/cider-nrepl "0.40.0"]])
concat '[[cider/cider-nrepl "0.41.0"]])

(swap! boot.repl/*default-middleware*
conj 'cider.nrepl/cider-middleware)
Expand All @@ -76,11 +76,11 @@ run `cider-connect` or `cider-connect-cljs`.

[source,clojure]
----
:cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.40.0"}}
:cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.41.0"}}
:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}

:cider-cljs {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.339"}
cider/cider-nrepl {:mvn/version "0.40.0"}
cider/cider-nrepl {:mvn/version "0.41.0"}
cider/piggieback {:mvn/version "0.5.3"}}
:main-opts ["-m" "nrepl.cmdline" "--middleware"
"[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}
Expand Down
4 changes: 2 additions & 2 deletions doc/modules/ROOT/pages/basics/up_and_running.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ simple - CIDER simply passes the extra dependencies and nREPL configuration to
your build tool in the command it runs to start the nREPL server. Here's how
this looks for `tools.deps`:

$ clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/cider-nrepl {:mvn/version "0.40.0"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'
$ clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/cider-nrepl {:mvn/version "0.41.0"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'

TIP: If you don't want `cider-jack-in` to inject dependencies automatically, set
`cider-inject-dependencies-at-jack-in` to `nil`. Note that you'll have to setup
Expand Down Expand Up @@ -292,7 +292,7 @@ It is also possible for plain `clj`, although the command is somewhat longer:

[source,sh]
----
$ clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.40.0"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
$ clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.41.0"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
----

Alternatively, you can start nREPL either manually or using the facilities
Expand Down
2 changes: 1 addition & 1 deletion doc/modules/ROOT/pages/cljs/shadow-cljs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ And connect to it with `cider-connect`.
...For that to work, `shadow-cljs.edn` contents like the following are assumed:

```clj
:dependencies [[cider/cider-nrepl "0.40.0"] ;; mandatory (unless it's inherited from deps.edn or otherwise present in the classpath of shadow-cljs's JVM process)
:dependencies [[cider/cider-nrepl "0.41.0"] ;; mandatory (unless it's inherited from deps.edn or otherwise present in the classpath of shadow-cljs's JVM process)
[refactor-nrepl/refactor-nrepl "3.9.0"]] ;; refactor-nrepl is optional

:nrepl {:middleware [cider.nrepl/cider-middleware ;; it's advisable to explicitly add this middleware. It's automatically added by shadow-cljs (if available in the classpath), unless `:nrepl {:cider false}`
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
Loading