Skip to content

Commit

Permalink
[inspector] Use inspect-refresh op for dynamic configuration updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed May 31, 2024
1 parent 6646778 commit 254e936
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions cider-inspector.el
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,19 @@ See `cider-sync-request:inspect-next-sibling' and `cider-inspector--render-value
(cider-inspector--render-value result 'v2)
(cider-inspector-next-inspectable-object 1))))

(defun cider-inspector--refresh-with-opts (&rest opts)
"Invokes `inspect-refresh' op with supplied extra parameters and re-renders
the currently inspected value."
(let ((result (cider-nrepl-send-sync-request `("op" "inspect-refresh" ,@opts)
cider-inspector--current-repl)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))

(defun cider-inspector-refresh ()
"Re-render the currently inspected value.
See `cider-sync-request:inspect-refresh' and `cider-inspector--render-value'"
(interactive)
(let ((result (cider-sync-request:inspect-refresh 'v2)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))
(cider-inspector--refresh-with-opts))

(defun cider-inspector-next-page ()
"Jump to the next page when inspecting a paginated sequence/map.
Expand All @@ -326,32 +332,24 @@ Does nothing if already on the first page."
Current page will be reset to zero."
(interactive (list (read-number "Page size: " cider-inspector-page-size)))
(let ((result (cider-sync-request:inspect-set-page-size page-size 'v2)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))
(cider-inspector--refresh-with-opts "page-size" page-size))

(defun cider-inspector-set-max-atom-length (max-length)
"Set the max length of nested atoms to MAX-LENGTH."
(interactive (list (read-number "Max atom length: " cider-inspector-max-atom-length)))
(let ((result (cider-sync-request:inspect-set-max-atom-length max-length 'v2)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))
(cider-inspector--refresh-with-opts "max-atom-length" max-length))

(defun cider-inspector-set-max-coll-size (max-size)
"Set the number of nested collection members to display before truncating.
MAX-SIZE is the new value."
(interactive (list (read-number "Max collection size: " cider-inspector-max-coll-size)))
(let ((result (cider-sync-request:inspect-set-max-coll-size max-size 'v2)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))
(cider-inspector--refresh-with-opts "max-coll-size" max-size))

(defun cider-inspector-set-max-nested-depth (max-nested-depth)
"Set the level of nesting for collections to display beflore truncating.
MAX-NESTED-DEPTH is the new value."
(interactive (list (read-number "Max nested depth: " cider-inspector-max-nested-depth)))
(let ((result (cider-sync-request:inspect-set-max-nested-depth max-nested-depth 'v2)))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))
(cider-inspector--refresh-with-opts "max-nested-depth" max-nested-depth))

(defcustom cider-inspector-preferred-var-names nil
"The preferred var names to be suggested by `cider-inspector-def-current-val'.
Expand Down Expand Up @@ -503,7 +501,8 @@ instead of just its \"value\" entry."
(nrepl-dict-get result "value"))))

(defun cider-sync-request:inspect-set-page-size (page-size &optional v2)
"Set the page size in paginated view to PAGE-SIZE,
"DEPRECATED. use `inspect-refresh' op instead.
Set the page size in paginated view to PAGE-SIZE,
V2 indicates if the entire response should be returned
instead of just its \"value\" entry."
(let ((result (thread-first `("op" "inspect-set-page-size"
Expand All @@ -514,7 +513,8 @@ instead of just its \"value\" entry."
(nrepl-dict-get result "value"))))

(defun cider-sync-request:inspect-set-max-atom-length (max-length &optional v2)
"Set the max length of nested atoms to MAX-LENGTH,
"DEPRECATED. use `inspect-refresh' op instead.
Set the max length of nested atoms to MAX-LENGTH,
V2 indicates if the entire response should be returned
instead of just its \"value\" entry."
(let ((result (thread-first `("op" "inspect-set-max-atom-length"
Expand All @@ -525,7 +525,8 @@ instead of just its \"value\" entry."
(nrepl-dict-get result "value"))))

(defun cider-sync-request:inspect-set-max-coll-size (max-size &optional v2)
"Set the number of nested collection members to display before truncating.
"DEPRECATED. use `inspect-refresh' op instead.
Set the number of nested collection members to display before truncating.
MAX-SIZE is the new value, V2 indicates if the entire response should be returned
instead of just its \"value\" entry."
(let ((result (thread-first `("op" "inspect-set-max-coll-size"
Expand All @@ -536,7 +537,8 @@ instead of just its \"value\" entry."
(nrepl-dict-get result "value"))))

(defun cider-sync-request:inspect-set-max-nested-depth (max-nested-depth &optional v2)
"Set the level of nesting for collections to display before truncating.
"DEPRECATED. use `inspect-refresh' op instead.
Set the level of nesting for collections to display before truncating.
MAX-NESTED-DEPTH is the new value, V2 indicates if the entire response should be returned
instead of just its \"value\" entry."
(let ((result (thread-first `("op" "inspect-set-max-nested-depth"
Expand Down

0 comments on commit 254e936

Please sign in to comment.