Skip to content

Commit 61cec32

Browse files
author
Antoine Brand
committed
* Added a helm interface to all the things return by xref-index
1 parent eb2c3c7 commit 61cec32

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

cmds.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
[(uq cmd)
4141
(eq? 'unquote (syntax-e #'uq))
4242
(case (syntax-e #'cmd)
43+
[(apropos) (elisp-println (scribble-decl-list))]
4344
[(run) (run put/stop rerun)]
4445
[(top) (top put/stop rerun)]
4546
[(def) (def (read))]

racket-mode.el

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,32 @@ http://www.gnu.org/licenses/ for details.")
144144
(set (make-local-variable 'imenu-syntax-alist)
145145
'(("+-*/.<>=?!$%_&~^:" . "w"))))
146146

147+
(require 'helm)
148+
149+
(defun helm-racket-apropos-init ()
150+
(with-current-buffer (helm-candidate-buffer 'global)
151+
(dolist (elem (racket--eval/sexpr ",apropos"))
152+
(insert (car elem) "\n"))))
153+
154+
(defun helm-racket-apropos-match-part (candidate)
155+
candidate)
156+
157+
(defun helm-racket-apropos-action (candidate)
158+
(racket--do-describe candidate t))
159+
160+
(defvar helm-source-racket-apropos
161+
'((name . "Search throught racket defining symbol")
162+
(init . helm-racket-apropos-init)
163+
(candidates-in-buffer)
164+
(get-line . buffer-substring)
165+
(match-part . helm-racket-apropos-match-part)
166+
(action . helm-racket-apropos-action)))
167+
168+
(defun helm-racket-apropos ()
169+
"Equivalent of helm-apropos but for the racket installed documentation"
170+
(interactive)
171+
(helm :sources 'helm-source-racket-apropos :buffer "*helm racket apropos*"))
172+
147173
;;;###autoload
148174
(define-derived-mode racket-mode prog-mode
149175
"Racket"

scribble.rkt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
#lang racket/base
22

33
(require racket/file
4+
racket/list
45
racket/match
56
scribble/xref
67
setup/xref
78
(only-in xml xml->xexpr element xexpr->string)
89
(only-in html read-html-as-xml))
910

10-
(provide scribble-doc/html)
11+
(provide scribble-doc/html
12+
scribble-decl-list)
13+
14+
(define (scribble-decl-list)
15+
(define xref (fix-load-collections-xref))
16+
(map entry-words (xref-index xref)))
1117

1218
(module+ test
1319
(require rackunit))
@@ -27,8 +33,16 @@
2733
(define-values (path anchor) (binding->path+anchor stx))
2834
(and path anchor (scribble-get-xexpr path anchor)))
2935

36+
(define fix-xref #f)
37+
38+
(define (fix-load-collections-xref)
39+
(when (not fix-xref)
40+
(set! fix-xref (load-collections-xref))
41+
(void (xref-index fix-xref)))
42+
fix-xref)
43+
3044
(define (binding->path+anchor stx)
31-
(define xref (load-collections-xref))
45+
(define xref (fix-load-collections-xref))
3246
(define tag (and (identifier? stx)
3347
(xref-binding->definition-tag xref stx 0)))
3448
(cond [tag (xref-tag->path+anchor xref tag)]

0 commit comments

Comments
 (0)