Skip to content

Commit 19d23e0

Browse files
[inspector] Use inspect-refresh op for dynamic configuration updates (#3691)
1 parent 5f79b02 commit 19d23e0

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Changes
1010

11+
- [#3691](https://github.com/clojure-emacs/cider/pull/3691): Deprecate `cider-sync-request:inspect-set-*` functions in favor of generic `inspect-refresh` op.
1112
- Bump the injected `cider-nrepl` to [0.49.0](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0490-2024-06-02).
1213

1314
### Bugs fixed

cider-inspector.el

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,19 @@ See `cider-sync-request:inspect-next-sibling' and `cider-inspector--render-value
294294
(cider-inspector--render-value result 'v2)
295295
(cider-inspector-next-inspectable-object 1))))
296296

297+
(defun cider-inspector--refresh-with-opts (&rest opts)
298+
"Invokes `inspect-refresh' op with supplied extra OPTS.
299+
Re-renders the currently inspected value."
300+
(let ((result (cider-nrepl-send-sync-request `("op" "inspect-refresh" ,@opts)
301+
cider-inspector--current-repl)))
302+
(when (nrepl-dict-get result "value")
303+
(cider-inspector--render-value result 'v2))))
304+
297305
(defun cider-inspector-refresh ()
298306
"Re-render the currently inspected value.
299307
See `cider-sync-request:inspect-refresh' and `cider-inspector--render-value'"
300308
(interactive)
301-
(let ((result (cider-sync-request:inspect-refresh 'v2)))
302-
(when (nrepl-dict-get result "value")
303-
(cider-inspector--render-value result 'v2))))
309+
(cider-inspector--refresh-with-opts))
304310

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

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

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

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

357355
(defun cider-inspector-toggle-view-mode ()
358356
"Toggle the view mode of the inspector between normal and object view mode."
@@ -515,6 +513,7 @@ instead of just its \"value\" entry."
515513
"Set the page size in paginated view to PAGE-SIZE,
516514
V2 indicates if the entire response should be returned
517515
instead of just its \"value\" entry."
516+
(declare (obsolete "use `inspect-refresh' op instead." "1.15.0"))
518517
(let ((result (thread-first `("op" "inspect-set-page-size"
519518
"page-size" ,page-size)
520519
(cider-nrepl-send-sync-request cider-inspector--current-repl))))
@@ -526,6 +525,7 @@ instead of just its \"value\" entry."
526525
"Set the max length of nested atoms to MAX-LENGTH,
527526
V2 indicates if the entire response should be returned
528527
instead of just its \"value\" entry."
528+
(declare (obsolete "use `inspect-refresh' op instead." "1.15.0"))
529529
(let ((result (thread-first `("op" "inspect-set-max-atom-length"
530530
"max-atom-length" ,max-length)
531531
(cider-nrepl-send-sync-request cider-inspector--current-repl))))
@@ -537,6 +537,7 @@ instead of just its \"value\" entry."
537537
"Set the number of nested collection members to display before truncating.
538538
MAX-SIZE is the new value, V2 indicates if the entire response should be returned
539539
instead of just its \"value\" entry."
540+
(declare (obsolete "use `inspect-refresh' op instead." "1.15.0"))
540541
(let ((result (thread-first `("op" "inspect-set-max-coll-size"
541542
"max-coll-size" ,max-size)
542543
(cider-nrepl-send-sync-request cider-inspector--current-repl))))
@@ -548,6 +549,7 @@ instead of just its \"value\" entry."
548549
"Set the level of nesting for collections to display before truncating.
549550
MAX-NESTED-DEPTH is the new value, V2 indicates if the entire response should be returned
550551
instead of just its \"value\" entry."
552+
(declare (obsolete "use `inspect-refresh' op instead." "1.15.0"))
551553
(let ((result (thread-first `("op" "inspect-set-max-nested-depth"
552554
"max-nested-depth" ,max-nested-depth)
553555
(cider-nrepl-send-sync-request cider-inspector--current-repl))))

0 commit comments

Comments
 (0)