diff --git a/CHANGELOG.md b/CHANGELOG.md index b9cc8566c..edf58365f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cider-apropos.el b/cider-apropos.el index 3ba69e089..faf4a346d 100644 --- a/cider-apropos.el +++ b/cider-apropos.el @@ -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 diff --git a/cider-client.el b/cider-client.el index dc98dd448..f6dca5e24 100644 --- a/cider-client.el +++ b/cider-client.el @@ -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"))))