|
41 | 41 |
|
42 | 42 | (push cider-apropos-buffer cider-ancillary-buffers)
|
43 | 43 |
|
| 44 | +(defcustom cider-apropos-actions '(("display-doc" . cider-doc-lookup) |
| 45 | + ("find-def" . cider--find-var) |
| 46 | + ("lookup-on-grimoire" . cider-grimoire-lookup)) |
| 47 | + "Controls the actions to be applied on the symbol found by an apropos search. |
| 48 | +The first action key in the list will be selected as default. If the list |
| 49 | +contains only one action key, the associated action function will be |
| 50 | +applied automatically. An action function can be any function that receives |
| 51 | +the symbol found by the apropos search as argument." |
| 52 | + :type '(alist :key-type string :value-type function) |
| 53 | + :group 'cider) |
| 54 | + |
44 | 55 | (defun cider-apropos-doc (button)
|
45 | 56 | "Display documentation for the symbol represented at BUTTON."
|
46 | 57 | (cider-doc-lookup (button-get button 'apropos-symbol)))
|
@@ -139,17 +150,15 @@ optionally search doc strings (based on DOCS-P), include private vars
|
139 | 150 |
|
140 | 151 | (defun cider-apropos-act-on-symbol (symbol)
|
141 | 152 | "Apply selected action on SYMBOL."
|
142 |
| - (let ((action (completing-read (format "Choose action to apply to `%s`: " symbol) |
143 |
| - '("display-doc" |
144 |
| - "find-def" |
145 |
| - "lookup-on-grimoire" |
146 |
| - "quit")))) |
147 |
| - (pcase action |
148 |
| - ("display-doc" (cider-doc-lookup symbol)) |
149 |
| - ("find-def" (cider--find-var symbol)) |
150 |
| - ("lookup-on-grimoire" (cider-grimoire-lookup symbol)) |
151 |
| - ("quit" nil) |
152 |
| - (_ (user-error "Unknown action `%s`" action))))) |
| 153 | + (let* ((first-action-key (car (car cider-apropos-actions))) |
| 154 | + (action-key (if (= 1 (length cider-apropos-actions)) |
| 155 | + first-action-key |
| 156 | + (completing-read (format "Choose action to apply to `%s`: " symbol) |
| 157 | + cider-apropos-actions nil nil nil nil first-action-key))) |
| 158 | + (action-fn (cdr (assoc action-key cider-apropos-actions)))) |
| 159 | + (if action-fn |
| 160 | + (funcall action-fn symbol) |
| 161 | + (user-error "Unknown action `%s`" action-key)))) |
153 | 162 |
|
154 | 163 | ;;;###autoload
|
155 | 164 | (defun cider-apropos-select (query &optional ns docs-p privates-p case-sensitive-p)
|
|
0 commit comments