Skip to content

Commit

Permalink
clojure: eval clojure with cider inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalli-johnny committed Jan 17, 2024
1 parent 8489373 commit 3f76226
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions docs/evaluating-clojure/inspect.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
# Inspect Clojure values

`, d v` is the Cider Inspector menu used to efficiently page through large data sets and easily navigate through nested data structures.
`, d v` is the Cider Inspector menu used to efficiently page through very large data sets and navigate through nested data structures.

The Cider Inspector opens in a new buffer that shows the underlying type of the value and all of its details. of the current symbol under the cursor. This provides a very readable way to understand the value and browse through larger data sets.
`, d v l` shows the last evaluation in the inspector

The Cider Inspector is used in the [REPL driven development with Spacemacs video](https://youtu.be/NDrpclY54E0).
`, d v f` evaluates the top level expression under the cursor and displays the result in the inspector

`, d v e` evaluates the previous expression before the cursor and displays the result in the inspector

!!! HINT "Following evaluation results in Cider Inspector"
The Cider Inspector will show the results of any evaluation, from `, e` or `, d v` menus, whilst the buffer is visible.
Keep the Cider Inspector buffer open to update with the result of the latest expression evaluation, from `, e` or `, d v` menus.

??? INFO "Inspector in action"
Clojure REPL workflow video includes using the Cider Inspector, 20 minutes into the video

<p style="text-align:center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/NDrpclY54E0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</p>


`, d v f` to evaluate a top level expression and show the results in the Cider Inspector.
## Use Inspector buffer

Once Cider Inspector buffer is open:

`n` and `p` page through the data if the number of elements in the data set is greater than the page size (default 32), (`cider-inspector-next-page`, `cider-inspector-prev-page`)

Expand All @@ -30,6 +42,10 @@ Inspecting a number or character shows the underlying type, the value and proper

![Spacemacs - Clojure - Inspect value - java.lang.Long](/images/spacemace-clojure-inspect-java-lang-long.png)

Inspect a dynamic var

![Spacemacs - Clojure - Inspect value - dynamic var]()


## Inspecting Collections

Expand All @@ -50,8 +66,6 @@ If there are collections within collections then those values can be navigated t

Mutable containers, `atom`, `ref`, can also be inspected. The class of the container is shown, along with the class of the value it contains along with its elements.

![Spacemacs - Clojure - Inspect atom containing a vector](/images/spacemacs-clojure-inspect-atom-containing-persistent-vector.png)

Inspecting an atom or ref gives the value at the current time. The inspector does not update if the value of the atom or ref is updated. Use `r` in the inspector buffer to refresh or restart the inspector with `, d v` each time you want to check if the value has changed.


Expand All @@ -66,3 +80,8 @@ Meta data includes the file and position of the code, the name of the var and wh
Inspecting a `defn` also shows the argument list as part of the meta data.

![Spacemacs Clojure Cider Inspector - inspect last value - defn](/images/spacemacs-clojure-cider-inspector-inspect-last-value-defn.png)

Open API docs data structure example shows class, value, meta information and datafy data

![Spacemacs Clojure Cider Inspector - OpenAPI docs example](https://github.com/practicalli/graphic-design/blob/live/editors/spacemacs/screenshots/spacemacs-clojure-cider-inspector-var-openapi-docs-light.png?raw=true#only-light)
![Spacemacs Clojure Cider Inspector - OpenAPI docs example](https://github.com/practicalli/graphic-design/blob/live/editors/spacemacs/screenshots/spacemacs-clojure-cider-inspector-var-openapi-docs-dark.png?raw=true#only-dark)

0 comments on commit 3f76226

Please sign in to comment.