Merge remote-tracking branch 'lenormf/fix-spell'

This commit is contained in:
Maxime Coste 2016-10-20 21:52:38 +01:00
commit dcebdd54f3

View File

@ -18,17 +18,19 @@ Formats of language supported:
if [ $# -ge 1 ]; then if [ $# -ge 1 ]; then
if [ ${#1} -ne 2 -a ${#1} -ne 5 ]; then if [ ${#1} -ne 2 -a ${#1} -ne 5 ]; then
echo 'echo -color Error Invalid language code (examples of expected format: en, en_US, en-US)' echo 'echo -color Error Invalid language code (examples of expected format: en, en_US, en-US)'
rm -r $(dirname $kak_opt_spell_tmp_file) rm -r "$(dirname "$kak_opt_spell_tmp_file")"
exit 1 exit 1
else else
options="-l $1" options="-l '$1'"
fi fi
fi fi
sed 's/^/^/' < $kak_opt_spell_tmp_file | aspell -a $options 2>&1 | tee /tmp/spell-out | {
{
sed 's/^/^/' "$kak_opt_spell_tmp_file" | eval "aspell -a $options" 2>&1 | {
line_num=1 line_num=1
regions=$kak_timestamp regions=$kak_timestamp
read line # drop the identification message read line # drop the identification message
while read line; do while read -r line; do
case "$line" in case "$line" in
[\#\&]*) [\#\&]*)
if expr "$line" : '^&' >/dev/null; then if expr "$line" : '^&' >/dev/null; then
@ -42,11 +44,13 @@ Formats of language supported:
;; ;;
'') line_num=$((line_num + 1));; '') line_num=$((line_num + 1));;
\*) ;; \*) ;;
*) printf 'echo -color Error %%{%s}\n' "${line}";; *) printf 'echo -color Error %%{%s}\n' "${line}" | kak -p "${kak_session}";;
esac esac
done done
printf 'set buffer spell_regions %%{%s}' "${regions}" printf 'set "buffer=%s" spell_regions %%{%s}' "${kak_bufname}" "${regions}" \
| kak -p "${kak_session}"
} }
rm -r $(dirname $kak_opt_spell_tmp_file) rm -r $(dirname "$kak_opt_spell_tmp_file")
} </dev/null >/dev/null 2>&1 &
} }
} }