PillFall / languagetool.el

LanguageTool suggestions integrated within Emacs
GNU General Public License v3.0
98 stars 8 forks source link

Issue with ~ path #7

Closed Ergus closed 3 years ago

Ergus commented 3 years ago

Hi:

It seems like the call-process-region' or java has some issues when using~` as the home path.

When I execute:

(apply #'call-process-region 44207 44210
       "java"
       nil
       t
       nil
       '("-jar" "~/languagetool/languagetool-standalone/target/LanguageTool-5.5-SNAPSHOT/LanguageTool-5.5-SNAPSHOT/languagetool-commandline.jar" "-c utf8" "--json -l en"))

I get

Error: Unable to access jarfile ~/languagetool/languagetool-standalone/target/LanguageTool-5.5-SNAPSHOT/LanguageTool-5.5-SNAPSHOT/languagetool-commandline.jar

If I append "/home/user" instead of "~" the problem disappears.

When I try the command in the terminal directly like:

java -jar ~/languagetool/languagetool-standalone/target/LanguageTool-5.5-SNAPSHOT/LanguageTool-5.5-SNAPSHOT/languagetool-commandline.jar it seems to works.

BUT

java "-jar" "~/languagetool/languagetool-standalone/target/LanguageTool-5.5-SNAPSHOT/LanguageTool-5.5-SNAPSHOT/languagetool-commandline.jar"

produces the same error. So the problem seems to be related with the quoting.

PillFall commented 3 years ago

Hi,

The problem stands with Emacs itself and how Emacs-Lisp treats paths. I got a lot of problems with that, and I had an idea of how to patch it, I will implement that in a future version if nothing goes wrong.

That's the reason why I suggest in the documentation to use the full path and not abbrev of it (~ is an abbrev of $HOME). See ReadMe.adoc#L55

When you do

(apply #'call-process-region (point-min) (point-max)
       "java"
       nil
       nil
       nil
       '("-jar" "~/path/languagetool-commandline.jar" "-c" "utf8" "--json" "-l" "en"))

What your computer recieves is a command like

java -jar ~/path/languagetool-commandline.jar -c utf8 --json -l en

But the ~ does not get expanded to /home/user, instead it is searching for a folder named ~ in the current working directory, that's why you are getting that error.

PillFall commented 3 years ago

That should now be fixed. I thought it will break something, but no :sweat_smile:

Ergus commented 3 years ago

Tks