|
4 | 4 | racket/contract) |
5 | 5 |
|
6 | 6 | (provide/contract |
7 | | - [query-aspell (-> (and/c string? (not/c #rx"[\n]")) (listof (list/c number? number?)))]) |
| 7 | + [query-aspell (-> (and/c string? (not/c #rx"[\n]")) (listof (list/c number? number?)))] |
| 8 | + [find-aspell-binary-path (-> (or/c path? #f))]) |
8 | 9 |
|
9 | 10 | (define aspell-candidate-paths |
10 | 11 | '("/usr/bin" |
11 | 12 | "/usr/local/bin" |
12 | 13 | "/bin")) |
13 | 14 |
|
| 15 | +(define (find-aspell-binary-path) |
| 16 | + (define aspell (if (eq? (system-type) 'windows) "aspell.exe" "aspell")) |
| 17 | + (define ispell (if (eq? (system-type) 'windows) "ispell.exe" "ispell")) |
| 18 | + (or (find-executable-path aspell) |
| 19 | + (find-executable-path ispell) |
| 20 | + (for/or ([cp aspell-candidate-paths]) |
| 21 | + (define c1 (build-path cp aspell)) |
| 22 | + (define c2 (build-path cp ispell)) |
| 23 | + (or (and (file-exists? c1) |
| 24 | + c1) |
| 25 | + (and (file-exists? c2) |
| 26 | + c2))))) |
| 27 | + |
14 | 28 | (define aspell-req-chan (make-channel)) |
15 | 29 | (define aspell-thread #f) |
16 | 30 | (define (start-aspell-thread) |
|
24 | 38 | (define (fire-up-aspell) |
25 | 39 | (unless already-attempted-aspell? |
26 | 40 | (set! already-attempted-aspell? #t) |
27 | | - (define asp (or (find-executable-path "aspell") |
28 | | - (find-executable-path "ispell") |
29 | | - (for/or ([cp aspell-candidate-paths]) |
30 | | - (define c1 (build-path cp "aspell")) |
31 | | - (define c2 (build-path cp "ispell")) |
32 | | - (or (and (file-exists? c1) |
33 | | - c1) |
34 | | - (and (file-exists? c2) |
35 | | - c2))))) |
36 | | - (define aspell? (regexp-match? #rx"aspell" (path->string asp))) |
| 41 | + (define asp (find-aspell-binary-path)) |
37 | 42 | (when asp |
| 43 | + (define aspell? (regexp-match? #rx"aspell" (path->string asp))) |
38 | 44 | (set! aspell-proc (apply process* asp "-a" (if aspell? '("--encoding=utf-8") '()))) |
39 | 45 | (define line (read-line (list-ref aspell-proc 0))) |
40 | 46 | (log-info (format "framework: started speller: ~a" line)) |
|
0 commit comments