Emacs-langtool icon indicating copy to clipboard operation
Emacs-langtool copied to clipboard

being aware of the environment

Open Jiehong opened this issue 14 years ago • 8 comments

When typing something else than just text, let's say a LaTeX document, langtool is not aware of the LaTeX syntaxe and found a lot of small errors due to that. It would be great if it would deal with environments only and ignore LaTeX commands for example.

Actually, I don't really think it's possible since LanguageTool isn't aware of the syntax... so, it's more a question: is that possible without too much work or not really ?

Jiehong avatar Sep 23 '11 04:09 Jiehong

Very difficult for me ;-)

But, sometimes I am considering some ways of to solve this problem. Programming comment, quoted string and etc..

mhayashi1120 avatar Sep 25 '11 09:09 mhayashi1120

For LaTeX, one could just use 'detex -c' on the current buffer before passing it on to langtool. This command strips away all latex markup. 'detex' is included in TeXLive package (texlive-extra-utils on Debian). An example to follow can be found here: http://ftp.sunet.se/pub/gnu/emacs-lisp/archive/diction.el

ghost avatar Nov 29 '12 14:11 ghost

This is also an issue with org-mode files, as initial indentation, code in BEGIN..END blocks and properties are all flagged.

howardabrams avatar Mar 30 '15 23:03 howardabrams

Same here with asciidoc and code blocks. Maybe ignoring some warnings if the incriminated hunk matches a regex would do the trick

jnavila avatar Aug 17 '15 20:08 jnavila

The LanguageTool API provides the AnnotatedTextBuilder class to check text with markup (https://languagetool.org/development/api/org/languagetool/markup/AnnotatedTextBuilder.html). I'm not sure how this would integrate with Emacs, though.

krobbins avatar Oct 23 '15 22:10 krobbins

I would love to see this implemented :smile:

nashamri avatar Jan 23 '17 16:01 nashamri

The problem with detex is that I couldn't make him replace non-text thing with spaces, losing the correct word positions... But I made it work by copying the buffer, replacing the non-text parts with spaces using regex, launching langtool and this modified buffer and displaying the results on the original buffer. Proper implementation should include a user-defined list of regexp to clean the file. Does it look like a good solution for you ?

galaunay avatar Mar 20 '17 11:03 galaunay

I also wanted Langtool to ignore LaTeX so I implemented a small package that allows you to tell Langtool to ignore certain regions of text based on their font. I used this effectively to stop Langtool from complaining about stuff in LaTeX math-mode and also LaTeX comments. See here https://github.com/cjl8zf/langtool-ignore-fonts. Perhaps one day this could be added to the Emacs Langtool package.

cjl8zf avatar Feb 16 '21 18:02 cjl8zf