From 48d2de53d512f23af342ca2697a943f4a339df25 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 29 May 2016 20:02:47 -0500 Subject: [PATCH] ispell (not aspell) doesn't seem to deal correctly with non-ASCII words so just don't try to spell check them unless we know we have aspell --- gui-lib/framework/private/aspell.rkt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gui-lib/framework/private/aspell.rkt b/gui-lib/framework/private/aspell.rkt index 3bc94527..6d0e3302 100644 --- a/gui-lib/framework/private/aspell.rkt +++ b/gui-lib/framework/private/aspell.rkt @@ -95,6 +95,7 @@ (define aspell-proc #f) (define already-attempted-aspell? #f) (define current-dict #f) + (define is-actually-aspell? #f) (define (fire-up-aspell) (unless already-attempted-aspell? @@ -105,6 +106,8 @@ (define line (with-handlers ((exn:fail? exn-message)) (read-line (list-ref aspell-proc 0)))) (asp-log (format "framework: started speller: ~a" line)) + (when (regexp-match? #rx"[Aa]spell" line) + (set! is-actually-aspell? #t)) (when (and (string? line) (regexp-match #rx"[Aa]spell" line)) @@ -129,7 +132,12 @@ (close-output-port (list-ref aspell-proc 1)) (close-input-port (list-ref aspell-proc 3)) (proc 'kill) - (set! aspell-proc #f)) + (set! aspell-proc #f) + (set! is-actually-aspell? #f)) + + (define (is-ascii? l) + (for/and ([s (in-string l)]) + (<= (char->integer s) 127))) (let loop () (sync @@ -147,7 +155,9 @@ (sync (channel-put-evt resp-chan resp) nack-evt)) (cond - [aspell-proc + [(and aspell-proc + (or is-actually-aspell? + (is-ascii? line))) (define stdout (list-ref aspell-proc 0)) (define stdin (list-ref aspell-proc 1))