Skip to content

Instantly share code, notes, and snippets.

@yevgenko
Created April 27, 2010 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yevgenko/380491 to your computer and use it in GitHub Desktop.
Save yevgenko/380491 to your computer and use it in GitHub Desktop.
simultaneous spell checking for Russian and English
#!/usr/bin/perl -ln
# aspell wrapper to have spell checking simultaneously for Russian and English
# from http://powerman.name/config/vim.html
# put this code into ~/bin/aspell and make executable
BEGIN {
($OPT = " @ARGV ") =~ s/\s+-d\s+\w+//g;
$IS_APPEND = $OPT =~ /\s-a\s/;
@ARGV = ('-');
umask 077;
open $R,"| /usr/bin/aspell $OPT -d russian --ignore-accents >/tmp/aspell_ru.$$";
open $E,"| /usr/bin/aspell $OPT -d english >/tmp/aspell_en.$$";
}
if ($IS_APPEND) {
if (/^\*/) {
print { /[\xA3\xB3\xC0-\xFF]/ ? $R : $E } $_;
}
else {
print $R $_;
print $E $_;
}
}
else {
print { /[\xA3\xB3\xC0-\xFF]/ ? $R : $E } $_
for split /[^\@0-9_a-zA-Z\xA3\xB3\xC0-\xFF]+/;
}
END {
close $R;
close $E;
system("cat /tmp/aspell_{en,ru}.$$ ; rm /tmp/aspell_{en,ru}.$$");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment