-
Notifications
You must be signed in to change notification settings - Fork 12
/
yalafi-emacs
56 lines (49 loc) · 1.19 KB
/
yalafi-emacs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#
# interface between Emacs-langtool and yalafi.shell
# - collect all options passed by Emacs-langtool
# - languagetool-commandline.jar is a bit picky with repeated options
# - under Cygwin: correct name of temp file
#
# LT's base directory
#
ltdir=~/lib/LanguageTool-4.7
# comment out to use languagetool-commandline
#
use_server="--server my"
opts=x
lang=en-GB
while [ $# -gt 1 ]
do
if [ X$1 == X-l ]
then
# languagetool-commandline does not like multiple language specs
shift
lang=$1
elif [ X$1 == X-c ]
then
# languagetool-commandline does not like multiple encoding specs
# (yalafi.shell already includes --encoding utf-8)
shift
else
opts+="$1 "
fi
shift
done
repl_file='
import re
import sys
file = sys.argv[1]
file = re.sub(r"\\", r"/", file)
file = re.sub(r"^(.):/", r"/cygdrive/\1/", file)
sys.stdout.write(file)
'
if [[ "$OS" =~ Windows ]]
then
# under Cygwin: correct name of temp file
file=$(python -c "$repl_file" $1)
else
file=$1
fi
python -m yalafi.shell $use_server --output plain --language $lang \
--lt-directory $ltdir --lt-options "$opts" $file 2>/dev/null