diff --git a/cmds.rkt b/cmds.rkt index f781f01a..d23358c7 100644 --- a/cmds.rkt +++ b/cmds.rkt @@ -40,6 +40,7 @@ [(uq cmd) (eq? 'unquote (syntax-e #'uq)) (case (syntax-e #'cmd) + [(apropos) (elisp-println (scribble-decl-list))] [(run) (run put/stop rerun)] [(top) (top put/stop rerun)] [(def) (def (read))] diff --git a/racket-mode.el b/racket-mode.el index 507d86c2..35f60553 100644 --- a/racket-mode.el +++ b/racket-mode.el @@ -144,6 +144,35 @@ http://www.gnu.org/licenses/ for details.") (set (make-local-variable 'imenu-syntax-alist) '(("+-*/.<>=?!$%_&~^:" . "w")))) + +(when (require 'helm nil 't) + + (when (fboundp 'helm-candidate-buffer) + (defun racket-helm-apropos-init () + (with-current-buffer (helm-candidate-buffer 'global) + (dolist (elem (racket--eval/sexpr ",apropos")) + (insert (car elem) "\n"))))) + + (defun racket-helm-apropos-match-part (candidate) + candidate) + + (defun racket-helm-apropos-action (candidate) + (racket--do-describe candidate t)) + + (defvar helm-source-racket-apropos + '((name . "Search throught racket defining symbol") + (init . racket-helm-apropos-init) + (candidates-in-buffer) + (get-line . buffer-substring) + (match-part . racket-helm-apropos-match-part) + (action . racket-helm-apropos-action))) + + (when (fboundp 'helm) + (defun racket-helm-apropos () + "Equivalent of helm-apropos but for the racket installed documentation" + (interactive) + (helm :sources 'helm-source-racket-apropos :buffer "*helm racket apropos*")))) + ;;;###autoload (define-derived-mode racket-mode prog-mode "Racket" diff --git a/scribble.rkt b/scribble.rkt index c2c0eec5..8681e98d 100644 --- a/scribble.rkt +++ b/scribble.rkt @@ -1,13 +1,19 @@ #lang racket/base (require racket/file + racket/list racket/match scribble/xref setup/xref (only-in xml xml->xexpr element xexpr->string) (only-in html read-html-as-xml)) -(provide scribble-doc/html) +(provide scribble-doc/html + scribble-decl-list) + +(define (scribble-decl-list) + (define xref (load-collections-xref)) + (map entry-words (xref-index xref))) (module+ test (require rackunit))