diff --git a/CHANGELOG.md b/CHANGELOG.md index edf58365f..967419cdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Javadoc commands take into account the variable `clojure.java.javadoc/*remote-javadocs*`. * Javadoc also works on classes of the AmazonAWS Java SDK. * Apropos commands now accept lists of space-separated words as arguments, in addition to regular expressions (similar to Emacs's own apropos commands). +* [#1541](https://github.com/clojure-emacs/cider/issues/1541): New commands `cider-apropos-select` and `cider-apropos-documentation-select`. ## 0.11.0 / 2016-03-03 diff --git a/cider-apropos.el b/cider-apropos.el index faf4a346d..6ad560d2a 100644 --- a/cider-apropos.el +++ b/cider-apropos.el @@ -130,6 +130,34 @@ sensitive." (cider-ensure-op-supported "apropos") (cider-apropos (read-string "Search for Clojure documentation (a regular expression): ") nil t)) +;;;###autoload +(defun cider-apropos-select (query &optional ns docs-p privates-p case-sensitive-p) + "Similar to `cider-apropos', but presents the results in a completing read." + (interactive + (cons (read-string "Search for Clojure symbol (a regular expression): ") + (when current-prefix-arg + (list (let ((ns (completing-read "Namespace (default is all): " (cider-sync-request:ns-list)))) + (if (string= ns "") nil ns)) + (y-or-n-p "Search doc strings? ") + (y-or-n-p "Include private symbols? ") + (y-or-n-p "Case-sensitive? "))))) + (cider-ensure-connected) + (cider-ensure-op-supported "apropos") + (if-let ((summary (cider-apropos-summary + query ns docs-p privates-p case-sensitive-p)) + (results (mapcar (lambda (r) (nrepl-dict-get r "name")) + (cider-sync-request:apropos query ns docs-p privates-p case-sensitive-p)))) + (cider-doc-lookup (completing-read (concat summary ": ") results)) + (message "No apropos matches for %S" query))) + +;;;###autoload +(defun cider-apropos-documentation-select () + "Shortcut for (cider-apropos-select nil t)." + (interactive) + (cider-ensure-connected) + (cider-ensure-op-supported "apropos") + (cider-apropos (read-string "Search for Clojure documentation (a regular expression): ") nil t)) + (provide 'cider-apropos) ;;; cider-apropos.el ends here