Skip to content

Commit

Permalink
Make it possible to pass to the apropos commands a list of
Browse files Browse the repository at this point in the history
space-separated words

This is pretty much how Emacs's apropos works. The list of words
is converted to a regexp behind the scenes.
  • Loading branch information
bbatsov committed Mar 19, 2016
1 parent 7f0b7a8 commit 66eb1bb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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).

## 0.11.0 / 2016-03-03

Expand Down
7 changes: 5 additions & 2 deletions cider-apropos.el
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@
;;;###autoload
(defun cider-apropos (query &optional ns docs-p privates-p case-sensitive-p)
"Show all symbols whose names match QUERY, a regular expression.
The search may be limited to the namespace NS, and may optionally search doc
strings, include private vars, and be case sensitive."
QUERY can also be a list of space-separated words (e.g. take while) which
will be converted to a regular expression (like take.+while) automatically
behind the scenes. The search may be limited to the namespace NS, and may
optionally search doc strings, include private vars, and be case
sensitive."
(interactive
(cons (read-string "Search for Clojure symbol (a regular expression): ")
(when current-prefix-arg
Expand Down
19 changes: 10 additions & 9 deletions cider-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -789,15 +789,16 @@ If CALLBACK is nil, use `cider-load-file-handler'."
"Send \"apropos\" request for regexp QUERY.
Optional arguments include SEARCH-NS, DOCS-P, PRIVATES-P, CASE-SENSITIVE-P."
(let ((response (cider-nrepl-send-sync-request
`("op" "apropos"
"session" ,(cider-current-session)
"ns" ,(cider-current-ns)
"query" ,query
,@(when search-ns `("search-ns" ,search-ns))
,@(when docs-p '("docs?" "t"))
,@(when privates-p '("privates?" "t"))
,@(when case-sensitive-p '("case-sensitive?" "t"))))))
(let* ((query (replace-regexp-in-string "[ \t]+" ".+" query))
(response (cider-nrepl-send-sync-request
`("op" "apropos"
"session" ,(cider-current-session)
"ns" ,(cider-current-ns)
"query" ,query
,@(when search-ns `("search-ns" ,search-ns))
,@(when docs-p '("docs?" "t"))
,@(when privates-p '("privates?" "t"))
,@(when case-sensitive-p '("case-sensitive?" "t"))))))
(if (member "apropos-regexp-error" (nrepl-dict-get response "status"))
(user-error "Invalid regexp: %s" (nrepl-dict-get response "error-msg"))
(nrepl-dict-get response "apropos-matches"))))
Expand Down

0 comments on commit 66eb1bb

Please sign in to comment.