2015-12-17 05:07:09 +01:00
|
|
|
decl -hidden range-faces spell_regions
|
|
|
|
decl -hidden str spell_tmp_file
|
|
|
|
|
|
|
|
def spell %{
|
|
|
|
try %{ addhl ranges 'spell_regions' }
|
|
|
|
%sh{
|
|
|
|
file=$(mktemp -d -t kak-spell.XXXXXXXX)/buffer
|
|
|
|
echo "write ${file}"
|
|
|
|
echo "set buffer spell_tmp_file ${file}"
|
|
|
|
}
|
|
|
|
%sh{
|
2015-12-24 23:04:17 +01:00
|
|
|
sed -i 's/^/^/' $kak_opt_spell_tmp_file
|
2015-12-17 05:07:09 +01:00
|
|
|
aspell -a < $kak_opt_spell_tmp_file 2>&1 | {
|
|
|
|
line_num=1
|
|
|
|
regions=$kak_timestamp
|
|
|
|
while read line; do
|
|
|
|
case $line in
|
|
|
|
\&*)
|
2016-01-10 21:41:46 +01:00
|
|
|
begin=$(printf %s "$line" | cut -d ' ' -f 4 | sed 's/:$//')
|
2016-01-16 20:10:37 +01:00
|
|
|
;&
|
2015-12-17 05:07:09 +01:00
|
|
|
'#'*)
|
2016-01-10 21:41:46 +01:00
|
|
|
word=$(printf %s "$line" | cut -d ' ' -f 2)
|
2016-01-16 20:10:37 +01:00
|
|
|
begin=${begin:-$(printf %s "$line" | cut -d ' ' -f 3)}
|
2015-12-17 05:07:09 +01:00
|
|
|
end=$((begin + ${#word}))
|
|
|
|
# echo "echo -debug -- line: $line_num, word: $word, begin: $begin, end: $end"
|
|
|
|
regions="$regions:$line_num.$begin,$line_num.$end|Error"
|
|
|
|
;;
|
|
|
|
'') ((++line_num)) ;;
|
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
echo "set buffer spell_regions %{$regions}"
|
|
|
|
}
|
|
|
|
rm -r $(dirname $kak_opt_spell_tmp_file)
|
|
|
|
}
|
|
|
|
}
|