emacs-languagetool / flycheck-languagetool

Flycheck support for LanguageTool
GNU General Public License v3.0
54 stars 8 forks source link

Silently fails/shows outdated errors when current buffer is not saved to a file #5

Closed mavit closed 3 years ago

mavit commented 3 years ago

If a buffer is not visiting a file (i.e., when buffer-file-name is nil) the languagetool Flycheck checker appears to be active, but no errors are highlighted.

If a buffer is visiting a file but that file has not been saved recently (i.e., when (buffer-modified-p) is t), errors are shown for the file as it is on disk, not as it is in the buffer.

jcs090218 commented 3 years ago

Hi, @mavit!

I don't know if this is possible since the package itself works by using the languagetool-commandline.jar file and I don't think the executable accept checking by text and not file. 😕

mavit commented 3 years ago

If you specify - as the filename then it reads from STDIN:

> echo foo | java -jar languagetool-commandline.jar --language en-GB -
Expected text language: English (GB)
Working on STDIN...
1.) Line 1, column 0, Rule ID: UPPERCASE_SENTENCE_START prio=1
Message: This sentence does not start with an uppercase letter.
Suggestion: Foo
foo 
^^^ 
Time: 2485ms for 1 sentences (0.4 sentences/sec)
jcs090218 commented 3 years ago

Cool! Thanks for the information! Just added in 96b4efd754d6d21af345a7300378363f9cfc86cf.

Can you upgrade to the latest version and see if this work for you? Thanks!

mavit commented 3 years ago

I think this will run into trouble if the buffer is larger than ARG_MAX, which varies from platform to platform. Also, on a multi-user system, it will allow other users to use the ps command to snoop on what you're writing.

It's probably better to pass input to the command over standard input directly, perhaps with (start-process ...) and (process-send-string ...).