From 98fa40f4a19cd6735574afd97564b34c7bbad053 Mon Sep 17 00:00:00 2001 From: Oleksandr Yakushev Date: Fri, 31 May 2024 15:24:01 +0300 Subject: [PATCH] [inspector] Use inspect-refresh op for dynamic configuration updates --- cider-inspector.el | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/cider-inspector.el b/cider-inspector.el index ad0109739..87b393376 100644 --- a/cider-inspector.el +++ b/cider-inspector.el @@ -294,13 +294,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 OPTS. +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. @@ -327,32 +333,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)) (defun cider-inspector-toggle-view-mode () "Toggle the view mode of the inspector between normal and object view mode." @@ -512,7 +510,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" @@ -523,7 +522,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" @@ -534,7 +534,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" @@ -545,7 +546,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"