Skip to content

Commit

Permalink
[#1541] Add versions of the apropos commands using completing read
Browse files Browse the repository at this point in the history
Basically instead of seeing the results in a dedicated buffer, you'll
now see them in the minibuffer.
  • Loading branch information
bbatsov committed Mar 20, 2016
1 parent 66eb1bb commit 25ce804
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 28 additions & 0 deletions cider-apropos.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 <query> 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

0 comments on commit 25ce804

Please sign in to comment.