Skip to content

Commit 4c1f867

Browse files
author
Antoine Brand
committed
* Added a helm interface to all the things return by xref-index
1 parent 1803029 commit 4c1f867

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
@@ -36,6 +36,7 @@
3636
[(uq cmd)
3737
(eq? 'unquote (syntax-e #'uq))
3838
(case (syntax-e #'cmd)
39+
[(apropos) (elisp-println (scribble-decl-list))]
3940
[(run) (put/stop (rerun (~a (read))))]
4041
[(top) (put/stop (rerun #f))]
4142
[(def) (def (read))]

racket-mode.el

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

141+
(require 'helm)
142+
143+
(defun helm-racket-apropos-init ()
144+
(with-current-buffer (helm-candidate-buffer 'global)
145+
(dolist (elem (racket--eval/sexpr ",apropos"))
146+
(insert (car elem) "\n"))))
147+
148+
(defun helm-racket-apropos-match-part (candidate)
149+
candidate)
150+
151+
(defun helm-racket-apropos-action (candidate)
152+
(racket--do-describe candidate t))
153+
154+
(defvar helm-source-racket-apropos
155+
'((name . "Search throught racket defining symbol")
156+
(init . helm-racket-apropos-init)
157+
(candidates-in-buffer)
158+
(get-line . buffer-substring)
159+
(match-part . helm-racket-apropos-match-part)
160+
(action . helm-racket-apropos-action)))
161+
162+
(defun helm-racket-apropos ()
163+
"Equivalent of helm-apropos but for the racket installed documentation"
164+
(interactive)
165+
(helm :sources 'helm-source-racket-apropos :buffer "*helm racket apropos*"))
166+
141167
;;;###autoload
142168
(define-derived-mode racket-mode prog-mode
143169
"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)