PillFall / languagetool.el

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

Ignored errors come back with the next server query.  #13

Closed andreyorst closed 1 year ago

andreyorst commented 1 year ago

What version of Emacs are you running?

GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.17.4) of 2022-10-23

What version of LanguageTool are you running?

LanguageTool version 5.7 (2022-03-28 18:24:41 +0000, 35d0d40)

What version of this package are you running?

1.1.0

What is the current behaviour?

When pressing <kbd>C-i</kbd> on some errors, after editing the buffer all of them come back.

What is you expect to happen?

Ignored errors stay ignored until the server is shut down

What do you do to get this bug?

A file with the following contents:

Foobar is bar.
Foobar is qux.
Foobar is quux.

Is highlighted like this:

Screenshot from 2022-11-01 21-37-03

After I call languagetool-correct-buffer and press C-i on all mistakes, the highlighting goes away:

Screenshot from 2022-11-01 21-37-01

But after a short delay it comes back:

Screenshot from 2022-11-01 21-37-03

andreyorst commented 1 year ago

There's another package for language-tool which doesn't have this problem, though it seems abandoned, and has some other bugs.

PillFall commented 1 year ago

Hi @andreyorst,

I checked mhayashi1120/Emacs-langtool before, as this package is based on it but diverges from the beginning (that is why is not a fork).

As far as I know, and taking a deep look into mhayashi1120 code, he didn't remove the current instance of the match, but instead, disables the whole rule, which could lead to unpleasant results.

For example,

Take the text:

You mai find all the things in Premium apb

LanguageTool will find two errors in en-GB (mai and apb), but if you decide to ignore mai, adding its rule ID to the list of ignored rules (MORFOLOGIK_RULE_EN_GB), you will also ignore apb as it shares the same rule ID.

This will be implemented in the future, as I know it leads to that confusion of being ignored and reappearing, but I will NOT follow the approach from mhayashi1120 code.

I got some ideas on how to implement this. And will do it soon.

andreyorst commented 1 year ago

I checked mhayashi1120/Emacs-langtool before, as this package is based on it but diverges from the beginning (that is why is not a fork).

Ah, sorry, I didn't know that. Your package really is an improvement over the older one.

LanguageTool will find two errors in en-GB (mai and apb), but if you decide to ignore mai, adding its rule ID to the list of ignored rules (MORFOLOGIK_RULE_EN_GB), you will also ignore apb as it shares the same rule ID.

This will be implemented in the future, as I know it leads to that confusion of being ignored and reappearing, but I will NOT follow the approach from mhayashi1120 code.

I got some ideas on how to implement this. And will do it soon.

It didn't occur to me, but yes, this is indeed a problem to disable the rule altogether. I wonder if this can be done similarly to how Flyspell handles this problem.

In Flyspell you can add an unknown word to a current buffer, and it will create a comment like # LocalWords: mai apb to the current buffer, and then ignore all words that are stored in this comment.

(ideally, it would be great to support LocalWords directly, as I often use Flyspell when language-tool is unavailable)

PillFall commented 1 year ago

Just added support to ispell LocalWords, and I notice that issues with more than two words are interpreted with no problems, but could lead to other issues. As far as I tested, there are none for now.

The package will add and take account of the LocalWords in the current buffer. Take for example:

LanguageTool is your intelligent writing assistant for all common browsers and word processors. Write or paste your text here too have it checked continously.

# Local Variables: # languagetool-correction-language: "en-GB" # End:

LanguageTool marks too have and continously. If you ignore continously, and recheck the buffer, you will get:

LanguageTool is your intelligent writing assistant for all common browsers and word processors. Write or paste your text here too have it checked continously.

# Local Variables: # languagetool-correction-language: "en-GB" # End:

# LocalWords: continously

And then if you ignore too have and recheck, you will get.

LanguageTool is your intelligent writing assistant for all common browsers and word processors. Write or paste your text here too have it checked continously.

# Local Variables: # languagetool-correction-language: "en-GB" # End:

# LocalWords: continously too have

And the issues are successfully ignored. Will merge to master in a couple of days.

PillFall commented 1 year ago

Add a similar behaviour as the LanguageTool extension, in c023cd6.

You can now choose between:

I believe this is the best approach as it is both flexible and robust.