Skip to content

Commit

Permalink
Support special forms for apropos and Grimoire
Browse files Browse the repository at this point in the history
Add `apropos-special-form` button type

Default to `clojure.core` ns for Grimoire; this is necessary for special forms,
which do not have ns. Grimoire defaults to `clojure.core`.
  • Loading branch information
xiongtx committed Jun 16, 2017
1 parent 238c60c commit cf92441
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### New Features

* [#2012](https://github.com/clojure-emacs/cider/pull/2007): Support special forms in `cider-apropos` and `cider-grimoire-lookup`.
* [#2007](https://github.com/clojure-emacs/cider/pull/2007): Fontify code blocks from `cider-grimoire` if possible.
* [#1990](https://github.com/clojure-emacs/cider/issues/1990): Add new customation variable `cider-save-files-on-cider-refresh` to allow auto-saving buffers when `cider-refresh` is called.
* Add new function `cider-load-all-files`, along with menu bar update.
Expand Down
9 changes: 9 additions & 0 deletions cider-apropos.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ the symbol found by the apropos search as argument."
:group 'cider
:package-version '(cider . "0.13.0"))

(define-button-type 'apropos-special-form
'apropos-label "Special form"
'apropos-short-label "s"
'face 'apropos-misc-button
'help-echo "mouse-2, RET: Display more help on this special form"
'follow-link t
'action (lambda (button)
(describe-function (button-get button 'apropos-symbol))))

(defun cider-apropos-doc (button)
"Display documentation for the symbol represented at BUTTON."
(cider-doc-lookup (button-get button 'apropos-symbol)))
Expand Down
7 changes: 5 additions & 2 deletions cider-grimoire.el
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ opposite of what that option dictates."
(current-buffer)))

(defun cider-grimoire-lookup (symbol)
"Look up the grimoire documentation for SYMBOL."
"Look up the grimoire documentation for SYMBOL.
If SYMBOL is a special form, the clojure.core ns is used, as is
Grimoire's convention."
(if-let ((var-info (cider-var-info symbol)))
(let ((name (nrepl-dict-get var-info "name"))
(ns (nrepl-dict-get var-info "ns"))
(ns (nrepl-dict-get var-info "ns" "clojure.core"))
(url-request-method "GET")
(url-request-extra-headers `(("Content-Type" . "text/plain"))))
(url-retrieve (cider-grimoire-url name ns)
Expand Down

0 comments on commit cf92441

Please sign in to comment.