diff --git a/collects/drracket/private/unit.rkt b/collects/drracket/private/unit.rkt index fff3259d09..6f51d1c35f 100644 --- a/collects/drracket/private/unit.rkt +++ b/collects/drracket/private/unit.rkt @@ -42,7 +42,9 @@ module browser threading seems wrong. mred (prefix-in mred: mred) - mzlib/date) + mzlib/date + + framework/private/aspell) (provide unit@) @@ -3641,10 +3643,16 @@ module browser threading seems wrong. (send item check (and on? (send ed get-spell-check-strings))))] [callback (λ (item evt) - (define ed (get-edit-target-object)) - (define old-val (send ed get-spell-check-strings)) - (preferences:set 'framework:spell-check-on? (not old-val)) - (send ed set-spell-check-strings (not old-val)))]) + (define asp (find-aspell-binary-path)) + (cond + [asp + (define ed (get-edit-target-object)) + (define old-val (send ed get-spell-check-strings)) + (preferences:set 'framework:spell-check-on? (not old-val)) + (send ed set-spell-check-strings (not old-val))] + [else + (message-box (string-constant drscheme) + (string-constant cannot-find-ispell-or-aspell-path))]))]) (new menu:can-restore-menu-item% [label (string-constant complete-word)] [shortcut #\/] diff --git a/collects/framework/private/aspell.rkt b/collects/framework/private/aspell.rkt index 151f2ff48f..42378eeef1 100644 --- a/collects/framework/private/aspell.rkt +++ b/collects/framework/private/aspell.rkt @@ -4,13 +4,27 @@ racket/contract) (provide/contract - [query-aspell (-> (and/c string? (not/c #rx"[\n]")) (listof (list/c number? number?)))]) + [query-aspell (-> (and/c string? (not/c #rx"[\n]")) (listof (list/c number? number?)))] + [find-aspell-binary-path (-> (or/c path? #f))]) (define aspell-candidate-paths '("/usr/bin" "/usr/local/bin" "/bin")) +(define (find-aspell-binary-path) + (define aspell (if (eq? (system-type) 'windows) "aspell.exe" "aspell")) + (define ispell (if (eq? (system-type) 'windows) "ispell.exe" "ispell")) + (or (find-executable-path aspell) + (find-executable-path ispell) + (for/or ([cp aspell-candidate-paths]) + (define c1 (build-path cp aspell)) + (define c2 (build-path cp ispell)) + (or (and (file-exists? c1) + c1) + (and (file-exists? c2) + c2))))) + (define aspell-req-chan (make-channel)) (define aspell-thread #f) (define (start-aspell-thread) @@ -24,17 +38,9 @@ (define (fire-up-aspell) (unless already-attempted-aspell? (set! already-attempted-aspell? #t) - (define asp (or (find-executable-path "aspell") - (find-executable-path "ispell") - (for/or ([cp aspell-candidate-paths]) - (define c1 (build-path cp "aspell")) - (define c2 (build-path cp "ispell")) - (or (and (file-exists? c1) - c1) - (and (file-exists? c2) - c2))))) - (define aspell? (regexp-match? #rx"aspell" (path->string asp))) + (define asp (find-aspell-binary-path)) (when asp + (define aspell? (regexp-match? #rx"aspell" (path->string asp))) (set! aspell-proc (apply process* asp "-a" (if aspell? '("--encoding=utf-8") '()))) (define line (read-line (list-ref aspell-proc 0))) (log-info (format "framework: started speller: ~a" line)) diff --git a/collects/string-constants/private/english-string-constants.rkt b/collects/string-constants/private/english-string-constants.rkt index f7626e31e2..95714b2ff6 100644 --- a/collects/string-constants/private/english-string-constants.rkt +++ b/collects/string-constants/private/english-string-constants.rkt @@ -1686,4 +1686,5 @@ please adhere to these guidelines: ;; (technically, editors that implement color:text<%>) (spell-check-string-constants "Spell Check String Constants") (misspelled-text-color "Misspelled Text Color") ;; in the preferences dialog + (cannot-find-ispell-or-aspell-path "Cannot find the aspell or ispell binary") )