Skip to content

Commit 1d6c85b

Browse files
committed
[Fix #699] Prompt for symbol in interactive doc functions
cider-doc, cider-grimoire, jump-to-var and other functions using cider-read-symbol-name were not interactive without a prefix or missing symbol. cider-read-symbol-name now prompts with the symbol at point as a default.
1 parent e96925e commit 1d6c85b

File tree

3 files changed

+28
-38
lines changed

3 files changed

+28
-38
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
* [#953](https://github.com/clojure-emacs/cider/pull/953) Use `sshx` instead of `ssh` in `cider-select-endpoint`
4343
* [#956](https://github.com/clojure-emacs/cider/pull/956) Eval full ns form only when needed.
4444
* Enable annotated completion candidates by default.
45+
* [#1031] (https://github.com/clojure-emacs/cider/pull/1031) Interactive functions prompt with
46+
symbol at point as a default value.
4547

4648
### Bugs fixed
4749

cider-grimoire.el

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
(message "Symbol %s not resolved" symbol)))
5353

5454
;;;###autoload
55-
(defun cider-grimoire-web (query)
55+
(defun cider-grimoire-web ()
5656
"Open the grimoire documentation for QUERY in the default web browser."
57-
(interactive "P")
58-
(cider-read-symbol-name "Symbol: " 'cider-grimoire-web-lookup query))
57+
(interactive)
58+
(cider-read-symbol-name "Grimoire doc for: " 'cider-grimoire-web-lookup))
5959

6060
(defun cider-create-grimoire-buffer (content)
6161
"Create a new grimoire buffer with CONTENT."
@@ -85,9 +85,9 @@
8585
(message "Symbol %s not resolved" symbol)))
8686

8787
;;;###autoload
88-
(defun cider-grimoire (query)
88+
(defun cider-grimoire ()
8989
"Open the grimoire documentation for QUERY in a popup buffer."
90-
(interactive "P")
91-
(cider-read-symbol-name "Symbol: " 'cider-grimoire-lookup query))
90+
(interactive)
91+
(cider-read-symbol-name "Grimoire doc for: " 'cider-grimoire-lookup))
9292

9393
(provide 'cider-grimoire)

cider-interaction.el

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ OTHER-WINDOW is passed to `cider-jamp-to'."
795795

796796
(defun cider-jump-to-var (&optional var line)
797797
"Jump to the definition of VAR, optionally at a specific LINE.
798-
When called interactively, this operates on point, or falls back to a prompt."
798+
When called interactively, prompts with symbol at point."
799799
(interactive)
800800
(cider-ensure-op-supported "info")
801801
(if var
@@ -941,10 +941,10 @@ in the buffer."
941941
(browse-url url)
942942
(error "No Javadoc available for %s" symbol-name)))))
943943

944-
(defun cider-javadoc (query)
945-
"Browse Javadoc on the Java symbol QUERY at point."
946-
(interactive "P")
947-
(cider-read-symbol-name "Javadoc for: " 'cider-javadoc-handler query))
944+
(defun cider-javadoc ()
945+
"Browse Javadoc on the Java symbol at point."
946+
(interactive)
947+
(cider-read-symbol-name "Javadoc for: " 'cider-javadoc-handler))
948948

949949
(defun cider-stdin-handler (&optional buffer)
950950
"Make a stdin response handler for BUFFER."
@@ -1746,17 +1746,9 @@ ready to call."
17461746
(goto-char (- (point-max) 1)))))))
17471747

17481748
(defun cider-read-symbol-name (prompt callback &optional query)
1749-
"Either read a symbol name using PROMPT or choose the one at point.
1750-
Use CALLBACK as the completing read var callback.
1751-
The user is prompted with PROMPT if a prefix argument is in effect,
1752-
if there is no symbol at point, or if QUERY is non-nil."
1753-
(let ((symbol-name (cider-symbol-at-point)))
1754-
(if (not (or current-prefix-arg
1755-
query
1756-
(not symbol-name)
1757-
(equal "" symbol-name)))
1758-
(funcall callback symbol-name)
1759-
(funcall callback (cider-read-from-minibuffer prompt)))))
1749+
"Read a symbol name using PROMPT with a default of the one at point.
1750+
Use CALLBACK as the completing read var callback."
1751+
(funcall callback (cider-read-from-minibuffer prompt (cider-symbol-at-point))))
17601752

17611753
(defun cider-sync-request:toggle-trace-var (symbol)
17621754
"Toggle var tracing for SYMBOL."
@@ -1766,11 +1758,10 @@ if there is no symbol at point, or if QUERY is non-nil."
17661758
"sym" symbol)
17671759
(nrepl-send-sync-request)))
17681760

1769-
(defun cider-toggle-trace-var (query)
1761+
(defun cider-toggle-trace-var ()
17701762
"Toggle var tracing.
1771-
Defaults to the symbol at point. With prefix arg QUERY or no symbol at
1772-
point, prompts for a var."
1773-
(interactive "P")
1763+
Defaults to the symbol at point."
1764+
(interactive)
17741765
(cider-ensure-op-supported "toggle-trace-var")
17751766
(cider-read-symbol-name
17761767
"Toggle trace for var: "
@@ -1781,8 +1772,7 @@ point, prompts for a var."
17811772
(pcase var-status
17821773
("not-found" (message "Var %s not found" sym))
17831774
("not-traceable" (message "Var %s can't be traced because it's not bound to a function" var-name))
1784-
(t (message "Var %s %s" var-name var-status)))))
1785-
query))
1775+
(t (message "Var %s %s" var-name var-status)))))))
17861776

17871777
(defun cider-sync-request:toggle-trace-ns (ns)
17881778
"Toggle namespace tracing for NS."
@@ -1816,16 +1806,15 @@ Defaults to the current ns. With prefix arg QUERY, prompts for a ns."
18161806
(cider-popup-buffer-display buffer t)
18171807
(message "Symbol %s not resolved" symbol)))
18181808

1819-
(defun cider-doc (query)
1820-
"Open a window with the docstring for the given QUERY.
1821-
Defaults to the symbol at point. With prefix arg or no symbol
1822-
under point, prompts for a var."
1823-
(interactive "P")
1824-
(cider-read-symbol-name "Symbol: " 'cider-doc-lookup query))
1809+
(defun cider-doc ()
1810+
"Open a window with the docstring for the given symbol.
1811+
Defaults to the symbol at point."
1812+
(interactive)
1813+
(cider-read-symbol-name "Doc for: " 'cider-doc-lookup))
18251814

1826-
(defun cider-undef (symbol)
1815+
(defun cider-undef ()
18271816
"Undefine the SYMBOL."
1828-
(interactive "P")
1817+
(interactive)
18291818
(cider-ensure-op-supported "undef")
18301819
(cider-read-symbol-name
18311820
"Undefine symbol: "
@@ -1834,8 +1823,7 @@ under point, prompts for a var."
18341823
(list "op" "undef"
18351824
"ns" (cider-current-ns)
18361825
"symbol" sym)
1837-
(cider-interactive-eval-handler (current-buffer))))
1838-
symbol))
1826+
(cider-interactive-eval-handler (current-buffer))))))
18391827

18401828
(defun cider-refresh ()
18411829
"Refresh loaded code."

0 commit comments

Comments
 (0)