diff options
author | Tijs Mallaerts <mallt@users.noreply.github.com> | 2016-07-10 15:50:20 +0200 |
---|---|---|
committer | Bozhidar Batsov <bozhidar.batsov@gmail.com> | 2016-07-10 16:50:20 +0300 |
commit | 87506dc800f4632f240bcf7ac2de5bb123bdeafe (patch) | |
tree | da481c531d137eda2ec1c951bc454158a85301be /cider-apropos.el | |
parent | d005eaa60aeae3266a8ea7d37c14a6f064fe8204 (diff) |
[Fix #1646] Add option to control apropos actions (#1791)
Diffstat (limited to 'cider-apropos.el')
-rw-r--r-- | cider-apropos.el | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/cider-apropos.el b/cider-apropos.el index 01a6abc6..40f833c7 100644 --- a/cider-apropos.el +++ b/cider-apropos.el @@ -41,6 +41,17 @@ (push cider-apropos-buffer cider-ancillary-buffers) +(defcustom cider-apropos-actions '(("display-doc" . cider-doc-lookup) + ("find-def" . cider--find-var) + ("lookup-on-grimoire" . cider-grimoire-lookup)) + "Controls the actions to be applied on the symbol found by an apropos search. +The first action key in the list will be selected as default. If the list +contains only one action key, the associated action function will be +applied automatically. An action function can be any function that receives +the symbol found by the apropos search as argument." + :type '(alist :key-type string :value-type function) + :group 'cider) + (defun cider-apropos-doc (button) "Display documentation for the symbol represented at BUTTON." (cider-doc-lookup (button-get button 'apropos-symbol))) @@ -139,17 +150,15 @@ optionally search doc strings (based on DOCS-P), include private vars (defun cider-apropos-act-on-symbol (symbol) "Apply selected action on SYMBOL." - (let ((action (completing-read (format "Choose action to apply to `%s`: " symbol) - '("display-doc" - "find-def" - "lookup-on-grimoire" - "quit")))) - (pcase action - ("display-doc" (cider-doc-lookup symbol)) - ("find-def" (cider--find-var symbol)) - ("lookup-on-grimoire" (cider-grimoire-lookup symbol)) - ("quit" nil) - (_ (user-error "Unknown action `%s`" action))))) + (let* ((first-action-key (car (car cider-apropos-actions))) + (action-key (if (= 1 (length cider-apropos-actions)) + first-action-key + (completing-read (format "Choose action to apply to `%s`: " symbol) + cider-apropos-actions nil nil nil nil first-action-key))) + (action-fn (cdr (assoc action-key cider-apropos-actions)))) + (if action-fn + (funcall action-fn symbol) + (user-error "Unknown action `%s`" action-key)))) ;;;###autoload (defun cider-apropos-select (query &optional ns docs-p privates-p case-sensitive-p) |