Skip to content

Commit

Permalink
Introduce cider-inspect-expr-from-inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
vemv committed Nov 21, 2023
1 parent de341f4 commit d9363de
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 5 additions & 3 deletions cider-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ INVERT inverts the semantics of the function `cider--should-prompt-for-symbol'."

(declare-function cider-complete-at-point "cider-completion")
(declare-function cider-eldoc "cider-eldoc")
(defun cider-read-from-minibuffer (prompt &optional value)
(defun cider-read-from-minibuffer (prompt &optional value skip-colon)
"Read a string from the minibuffer, prompting with PROMPT.
If VALUE is non-nil, it is inserted into the minibuffer as initial-input.
PROMPT need not end with \": \". If it doesn't, VALUE is displayed on the
PROMPT need not end with \": \". If it doesn't, VALUE is displayed on the
prompt as a default value (used if the user doesn't type anything) and is
not used as initial input (input is left empty)."
not used as initial input (input is left empty).
If SKIP-COLON is non-nil, no \": \" is forced at the end of the prompt."
(minibuffer-with-setup-hook
(lambda ()
(set-syntax-table clojure-mode-syntax-table)
Expand All @@ -100,6 +101,7 @@ not used as initial input (input is left empty)."
(let* ((has-colon (string-match ": \\'" prompt))
(input (read-from-minibuffer (cond
(has-colon prompt)
(skip-colon prompt)
(value (format "%s (default %s): " prompt value))
(t (format "%s: " prompt)))
(when has-colon value) ; initial-input
Expand Down
12 changes: 11 additions & 1 deletion cider-inspector.el
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ by clicking or navigating to them by other means."
(define-key map "n" #'cider-inspector-next-inspectable-object)
(define-key map [(shift tab)] #'cider-inspector-previous-inspectable-object)
(define-key map "p" #'cider-inspector-previous-inspectable-object)
(define-key map ":" #'cider-inspect-expr)
(define-key map ":" #'cider-inspect-expr-from-inspector)
(define-key map "f" #'forward-char)
(define-key map "b" #'backward-char)
(define-key map "9" #'cider-inspector-previous-sibling)
Expand Down Expand Up @@ -227,6 +227,16 @@ current buffer's namespace."
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result 'v2))))

(defun cider-inspect-expr-from-inspector ()
"Performs `cider-inspect-expr' in a way that is suitable from the Inspector itself.
In particular, it does not read `cider-sexp-at-point'."
(interactive)
(let* ((ns (cider-current-ns))
(prompt (format "Inspect expression in %s"
(substring-no-properties (funcall cider-repl-prompt-function ns)))))
(cider-inspect-expr (cider-read-from-minibuffer prompt nil 'skip-colon)
ns)))

(defun cider-inspector-pop ()
"Pop the last value off the inspector stack and render it.
See `cider-sync-request:inspect-pop' and `cider-inspector--render-value'."
Expand Down
2 changes: 1 addition & 1 deletion doc/modules/ROOT/pages/debugging/inspector.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ You'll have access to additional keybindings in the inspector buffer
| Opens the url or file at point, if found.

| kbd:[:]
| `cider-inspect-expr`
| `cider-inspect-expr-from-inspector`
| Prompts for a new value, rendering it in the Inspector.

| kbd:[t]
Expand Down

0 comments on commit d9363de

Please sign in to comment.