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
This commit is contained in:
parent
bdff5e8379
commit
4787361d7f
|
@ -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 #\/]
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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")
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user