summaryrefslogtreecommitdiff
path: root/lib/spellcheck.tcl
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2008-02-21 05:17:18 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2008-02-21 05:22:07 (GMT)
commit827743b2e893a0e81e9286ef12de4c02486e6c5e (patch)
treeecc4652c902ec6d31e98fb8f7498f04a8fb02867 /lib/spellcheck.tcl
parentde83f8cc4cd97c52a0b8a1b1ff4e949129e3a947 (diff)
downloadgit-827743b2e893a0e81e9286ef12de4c02486e6c5e.zip
git-827743b2e893a0e81e9286ef12de4c02486e6c5e.tar.gz
git-827743b2e893a0e81e9286ef12de4c02486e6c5e.tar.bz2
git-gui: Gracefully display non-aspell version errors to users
If the user has somehow managed to make us execute ispell instead of aspell, even though our code is invoking aspell, and ispell is not recognizing the aspell command line options we use to invoke it then we don't want a giant usage message back from ispell. Instead we show the ispell version number, letting the user know we don't actually support that spell checker. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'lib/spellcheck.tcl')
-rw-r--r--lib/spellcheck.tcl26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/spellcheck.tcl b/lib/spellcheck.tcl
index 15b929b..05a1ceb 100644
--- a/lib/spellcheck.tcl
+++ b/lib/spellcheck.tcl
@@ -6,6 +6,8 @@ class spellcheck {
field s_fd {} ; # pipe to ispell/aspell
field s_version {} ; # ispell/aspell version string
field s_lang {} ; # current language code
+field s_prog aspell; # are we actually old ispell?
+field s_failed 0 ; # is $s_prog bogus and not working?
field w_text ; # text widget we are spelling
field w_menu ; # context menu for the widget
@@ -36,6 +38,28 @@ method _connect {pipe_fd} {
if {[gets $pipe_fd s_version] <= 0} {
if {[catch {close $pipe_fd} err]} {
+
+ # Eh? Is this actually ispell choking on aspell options?
+ #
+ if {$s_prog eq {aspell}
+ && [regexp -nocase {^Usage: } $err]
+ && ![catch {
+ set pipe_fd [open [list | $s_prog -v] r]
+ gets $pipe_fd s_version
+ close $pipe_fd
+ }]
+ && $s_version ne {}} {
+ if {{@(#) } eq [string range $s_version 0 4]} {
+ set s_version [string range $s_version 5 end]
+ }
+ set s_failed 1
+ error_popup [strcat \
+ [mc "Unsupported spell checker"] \
+ ":\n\n$s_version"]
+ set s_version {}
+ return
+ }
+
regsub -nocase {^Error: } $err {} err
if {$s_fd eq {}} {
error_popup [strcat [mc "Spell checking is unavailable"] ":\n\n$err"]
@@ -89,7 +113,7 @@ method _connect {pipe_fd} {
}
method lang {{n {}}} {
- if {$n ne {} && $s_lang ne $n} {
+ if {$n ne {} && $s_lang ne $n && !$s_failed} {
set spell_cmd [list |]
lappend spell_cmd aspell
lappend spell_cmd --master=$n