Skip to content

Commit 4787361

Browse files
committed
show a dialog box saying that aspell/ispell cannot be
found instead of just silently not checking the spelling also, fix a bug in that case that used to cause drracket to just crash
1 parent bdff5e8 commit 4787361

3 files changed

Lines changed: 31 additions & 16 deletions

File tree

collects/drracket/private/unit.rkt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ module browser threading seems wrong.
4242
mred
4343
(prefix-in mred: mred)
4444

45-
mzlib/date)
45+
mzlib/date
46+
47+
framework/private/aspell)
4648

4749
(provide unit@)
4850

@@ -3641,10 +3643,16 @@ module browser threading seems wrong.
36413643
(send item check (and on? (send ed get-spell-check-strings))))]
36423644
[callback
36433645
(λ (item evt)
3644-
(define ed (get-edit-target-object))
3645-
(define old-val (send ed get-spell-check-strings))
3646-
(preferences:set 'framework:spell-check-on? (not old-val))
3647-
(send ed set-spell-check-strings (not old-val)))])
3646+
(define asp (find-aspell-binary-path))
3647+
(cond
3648+
[asp
3649+
(define ed (get-edit-target-object))
3650+
(define old-val (send ed get-spell-check-strings))
3651+
(preferences:set 'framework:spell-check-on? (not old-val))
3652+
(send ed set-spell-check-strings (not old-val))]
3653+
[else
3654+
(message-box (string-constant drscheme)
3655+
(string-constant cannot-find-ispell-or-aspell-path))]))])
36483656
(new menu:can-restore-menu-item%
36493657
[label (string-constant complete-word)]
36503658
[shortcut #\/]

collects/framework/private/aspell.rkt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,27 @@
44
racket/contract)
55

66
(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))])
89

910
(define aspell-candidate-paths
1011
'("/usr/bin"
1112
"/usr/local/bin"
1213
"/bin"))
1314

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+
1428
(define aspell-req-chan (make-channel))
1529
(define aspell-thread #f)
1630
(define (start-aspell-thread)
@@ -24,17 +38,9 @@
2438
(define (fire-up-aspell)
2539
(unless already-attempted-aspell?
2640
(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))
3742
(when asp
43+
(define aspell? (regexp-match? #rx"aspell" (path->string asp)))
3844
(set! aspell-proc (apply process* asp "-a" (if aspell? '("--encoding=utf-8") '())))
3945
(define line (read-line (list-ref aspell-proc 0)))
4046
(log-info (format "framework: started speller: ~a" line))

collects/string-constants/private/english-string-constants.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,4 +1686,5 @@ please adhere to these guidelines:
16861686
;; (technically, editors that implement color:text<%>)
16871687
(spell-check-string-constants "Spell Check String Constants")
16881688
(misspelled-text-color "Misspelled Text Color") ;; in the preferences dialog
1689+
(cannot-find-ispell-or-aspell-path "Cannot find the aspell or ispell binary")
16891690
)

0 commit comments

Comments
 (0)