Skip to content

Commit e5e745b

Browse files
authored
Inspector: introduce o, : keybindings (#3586)
1 parent 5261886 commit e5e745b

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
### Changes
66

77
- [#3576](https://github.com/clojure-emacs/cider/issues/3576): CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html): display Java class/method/field block tags (Returns/Throws/Params info) when available.
8+
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html#usage): introduce `o` keybinding which performs `cider-inspector-open-thing-at-point`.
9+
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html#usage): introduce `:` keybinding which performs `cider-inspect-expr-from-inspector`.
810
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html): retain [`truncate-lines`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Line-Truncation.html) values across screens.
911
- [#3580](https://github.com/clojure-emacs/cider/issues/3580): `cider-test`: make test vars in [test results reports](https://docs.cider.mx/cider/testing/test_reports.html) clickable.
1012
- As defined in the newly introduced `cider-test-var-keymap` var.

cider-common.el

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,13 @@ INVERT inverts the semantics of the function `cider--should-prompt-for-symbol'."
8484

8585
(declare-function cider-complete-at-point "cider-completion")
8686
(declare-function cider-eldoc "cider-eldoc")
87-
(defun cider-read-from-minibuffer (prompt &optional value)
87+
(defun cider-read-from-minibuffer (prompt &optional value skip-colon)
8888
"Read a string from the minibuffer, prompting with PROMPT.
8989
If VALUE is non-nil, it is inserted into the minibuffer as initial-input.
90-
PROMPT need not end with \": \". If it doesn't, VALUE is displayed on the
90+
PROMPT need not end with \": \". If it doesn't, VALUE is displayed on the
9191
prompt as a default value (used if the user doesn't type anything) and is
92-
not used as initial input (input is left empty)."
92+
not used as initial input (input is left empty).
93+
If SKIP-COLON is non-nil, no \": \" is forced at the end of the prompt."
9394
(minibuffer-with-setup-hook
9495
(lambda ()
9596
(set-syntax-table clojure-mode-syntax-table)
@@ -100,6 +101,7 @@ not used as initial input (input is left empty)."
100101
(let* ((has-colon (string-match ": \\'" prompt))
101102
(input (read-from-minibuffer (cond
102103
(has-colon prompt)
104+
(skip-colon prompt)
103105
(value (format "%s (default %s): " prompt value))
104106
(t (format "%s: " prompt)))
105107
(when has-colon value) ; initial-input

cider-inspector.el

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,22 @@ by clicking or navigating to them by other means."
8989
"\\|[+-.0-9]+") ; nor numbers. Note: BigInts, ratios etc. are interesting
9090
"Regexp of uninteresting and skippable values.")
9191

92+
(defun cider-inspector-open-thing-at-point ()
93+
"Opens the thing at point if found, without prompting."
94+
(interactive)
95+
(if-let ((url (thing-at-point 'url)))
96+
(browse-url url)
97+
(if-let ((filename (thing-at-point 'filename)))
98+
(find-file filename))))
99+
92100
(defvar cider-inspector-mode-map
93101
(let ((map (make-sparse-keymap)))
94102
(set-keymap-parent map cider-popup-buffer-mode-map)
95103
(define-key map (kbd "RET") #'cider-inspector-operate-on-point)
96104
(define-key map [mouse-1] #'cider-inspector-operate-on-click)
97105
(define-key map "l" #'cider-inspector-pop)
98106
(define-key map "g" #'cider-inspector-refresh)
107+
(define-key map "o" #'cider-inspector-open-thing-at-point)
99108
;; Page-up/down
100109
(define-key map [next] #'cider-inspector-next-page)
101110
(define-key map [prior] #'cider-inspector-prev-page)
@@ -112,6 +121,7 @@ by clicking or navigating to them by other means."
112121
(define-key map "n" #'cider-inspector-next-inspectable-object)
113122
(define-key map [(shift tab)] #'cider-inspector-previous-inspectable-object)
114123
(define-key map "p" #'cider-inspector-previous-inspectable-object)
124+
(define-key map ":" #'cider-inspect-expr-from-inspector)
115125
(define-key map "f" #'forward-char)
116126
(define-key map "b" #'backward-char)
117127
(define-key map "9" #'cider-inspector-previous-sibling)
@@ -217,6 +227,16 @@ current buffer's namespace."
217227
(when (nrepl-dict-get result "value")
218228
(cider-inspector--render-value result 'v2))))
219229

230+
(defun cider-inspect-expr-from-inspector ()
231+
"Performs `cider-inspect-expr' in a way that is suitable from the Inspector itself.
232+
In particular, it does not read `cider-sexp-at-point'."
233+
(interactive)
234+
(let* ((ns (cider-current-ns))
235+
(prompt (format "Inspect expression in %s"
236+
(substring-no-properties (funcall cider-repl-prompt-function ns)))))
237+
(cider-inspect-expr (cider-read-from-minibuffer prompt nil 'skip-colon)
238+
ns)))
239+
220240
(defun cider-inspector-pop ()
221241
"Pop the last value off the inspector stack and render it.
222242
See `cider-sync-request:inspect-pop' and `cider-inspector--render-value'."

doc/modules/ROOT/pages/debugging/inspector.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ You'll have access to additional keybindings in the inspector buffer
8484
| `cider-inspector-next-sibling`
8585
| Navigates to the next sibling, within a sequential collection.
8686

87+
| kbd:[o]
88+
| `cider-inspector-open-thing-at-point`
89+
| Opens the url or file at point, if found.
90+
91+
| kbd:[:]
92+
| `cider-inspect-expr-from-inspector`
93+
| Prompts for a new value, rendering it in the Inspector.
94+
8795
| kbd:[t]
8896
| `cider-inspector-tap-current-val`
8997
| Performs `tap>` using the inspector's current value as it argument.

0 commit comments

Comments
 (0)