• Stars
    star
    360
  • Rank 117,917 (Top 3 %)
  • Language
    Emacs Lisp
  • License
    GNU General Publi...
  • Created over 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LanguageTool for Emacs

langtool.el

Install:

Install LanguageTool version 3.0 or later (and java) https://languagetool.org/

Put this file into load-path'ed directory, and byte compile it if desired. And put the following expression into your ~/.emacs.

(require 'langtool)

Or use Melpa (https://melpa.org/)

NOTE (2023-01-25)

Confirmed working on following environment

Java

java --version

openjdk 17.0.4 2022-07-19
OpenJDK Runtime Environment (build 17.0.4+8-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.4+8-Debian-1deb11u1, mixed mode, sharing)

LanguageTool

Can be downloaded from here

java -jar languagetool-commandline.jar --version

LanguageTool version 6.0 (2022-12-29 12:13:11 +0000, e44dbb0)

Settings (required):

langtool.el have 3 types of client.

  1. Command line

This setting should be set, if you use rest of clients, to get full of completion support. And you should be set the variables before load this library.

(setq langtool-language-tool-jar "/path/to/languagetool-commandline.jar")
(require 'langtool)

Alternatively, you can set the classpath where LanguageTool's jars reside (e.g. ArchLinux):

(setq langtool-java-classpath
      "/usr/share/languagetool:/usr/share/java/languagetool/*")
(require 'langtool)

You can set a script that hold java setting (e.g. Gentoo):

(setq langtool-bin "/path/to/your/langtool")
(require 'langtool)
  1. HTTP server & client

You can use HTTP server implementation. This is very fast after listen server, but has security risk if there are multiple user on a same host.

(setq langtool-language-tool-server-jar "/path/to/languagetool-server.jar")

You can change HTTP server port number like following.

(setq langtool-server-user-arguments '("-p" "8082"))
  1. HTTP client

If you have running HTTP LanguageTool server instance on any machine:

(setq langtool-http-server-host "localhost"
      langtool-http-server-port 8082)

Now testing although, that running instance is working under HTTPSServer or via general ssl support (e.g. nginx) following may be working. Again, this is now testing, so please open issue when the ssl/tls connection is not working.

(setq langtool-http-server-stream-type 'tls)

Optional settings

  • Key binding if you desired.
(global-set-key "\C-x4w" 'langtool-check)
(global-set-key "\C-x4W" 'langtool-check-done)
(global-set-key "\C-x4l" 'langtool-switch-default-language)
(global-set-key "\C-x44" 'langtool-show-message-at-point)
(global-set-key "\C-x4c" 'langtool-interactive-correction)
  • Default language is detected by LanguageTool automatically. Please set langtool-default-language if you need specific language.
(setq langtool-default-language "en-US")

Otherwise, invoke M-x langtool-check with C-u (universal-argument)

  • Currently GNU java version is not working. Please change the variable to your favorite java executable.
(setq langtool-java-bin "/path/to/java")
  • Maybe your LanguageTool have launcher. (e.g. Gentoo) You need to set langtool-bin. See #24
(setq langtool-bin "/usr/bin/languagetool")
  • Maybe you want to specify your mother tongue.
(setq langtool-mother-tongue "en")
  • To customize LanguageTool commandline arguments.
(setq langtool-java-user-arguments '("-Dfile.encoding=UTF-8"))

You can also make the variable to buffer local like following:

(add-hook '**SOME**-mode-hook
          (lambda () (set (make-local-variable 'langtool-java-user-arguments)
                         '("-Dfile.encoding=UTF-8"))))

NOTE: Although there is no good example, langtool-user-arguments is a similar custom variable.

Usage:

  • To check current buffer and show warnings.
M-x langtool-check

Check with different language. You can complete supported language with C-i/TAB

C-u M-x langtool-check
  • To correct marker follow LanguageTool suggestions.
M-x langtool-correct-buffer
  • Go to warning point you can see a report from LanguageTool. Otherwise:
M-x langtool-show-message-at-point
  • You can optionally use extension package langtool-popup in this repository. To show automatically popup the cursor.

  • To finish checking. All langtool marker is removed.

M-x langtool-check-done

More Repositories

1

Emacs-wgrep

Writable grep buffer and apply the changes to files
Emacs Lisp
508
star
2

Emacs-imagex

Emacs image extensions
Emacs Lisp
51
star
3

Emacs-erefactor

Emacs-Lisp refactoring utilities
Emacs Lisp
26
star
4

Emacs-esqlite

sqlite file manipulate utilities
Emacs Lisp
24
star
5

Emacs-image-diredx

image-dired extension
Emacs Lisp
20
star
6

Emacs-pcsv

Emacs Lisp
15
star
7

auto-highlight-symbol-mode

automatic highlighting current symbol minor mode
Emacs Lisp
14
star
8

Gauche-net-twitter

Twitter API access library for Gauche
Scheme
11
star
9

Emacs-shelldoc

Shell command editing support with man page.
Emacs Lisp
11
star
10

Emacs-gosh-mode

Gauche editing extensions for Emacs scheme-mode
Emacs Lisp
10
star
11

Gauche-dbd-sqlite3

sqlite3 module
Scheme
8
star
12

Emacs-kaesar

Another AES algorithm encrypt/decrypt string with password.
Emacs Lisp
6
star
13

Gauche-net-oauth

OAuth library for Gauche
Scheme
5
star
14

japanlaw.el

Emacs 電子六法
Emacs Lisp
5
star
15

Emacs-color-dired

Emacs Lisp
5
star
16

Emacs-Lisp

My miscellaneous Emacs-Lisp
Emacs Lisp
5
star
17

Emacs-rectplus

Emacs Lisp
4
star
18

Gauche-net-oauth2

OAuth2 library for Gauche
Scheme
4
star
19

smart-log.el

Major mode with intepretting miscellaneous time format
Emacs Lisp
4
star
20

Gauche-dbd-sqlite

Another sqlite binding for gauche
Scheme
3
star
21

Emacs-image-archive

Image thumbnails in archive file
Emacs Lisp
3
star
22

Emacs-slideview

Slideshow
Emacs Lisp
3
star
23

Emacs-twittering-stream

Stream extensions for twittering-mode
Emacs Lisp
3
star
24

Emacs-piki

piki editing mode for Emacs
Emacs Lisp
3
star
25

Emacs-guid

Simple GUID/UUID generator/updator
Emacs Lisp
2
star
26

Emacs-cipher

AES cipher for Emacs
Emacs Lisp
2
star
27

Emacs-openssl-cipher

Cipher utilities using openssl
Emacs Lisp
2
star
28

Emacs-findwalker

Emacs Lisp
2
star
29

Emacs-fsvn

Subversion frontend for Emacs
Emacs Lisp
2
star
30

Emacs-gather

Gather string in buffer
Emacs Lisp
2
star
31

bs2sxml

BeautifulSoup to sxml (Gauche)
Scheme
2
star
32

PuyoPuyoMisc

test
C#
1
star
33

git-test

Emacs Lisp
1
star
34

Gauche-gis-hubeny

Calculate distance between 2 latitude/longitude
Scheme
1
star
35

Gauche-net-hatena

Hatena access library for Gauche
Scheme
1
star
36

Gauche-rfc-3339

RFC3339 (Date and Time on the Internet: Timestamps)
Scheme
1
star
37

mhc-gcal

1
star
38

Haskell-Test

Haskell
1
star
39

Gauche-net-yamareco

ヤマレコ api
Scheme
1
star
40

Emacs-jcalendar

Calendar extension for japanese
Emacs Lisp
1
star