Skip to content

Repository files navigation

#+title: Flycheck-grammalecte

Integrate the french grammar and typography checker [[http://www.dicollecte.org/][Grammalecte]] with
[[http://www.flycheck.org/][flycheck]] to automatically look for mistakes in your writings. It also
provides an easy way to find synonyms and antonyms for a given word (to
avoid repetitions for example). This package is of very little interest
for other languages.

[[./demo.gif]]

#+html: <a href="https://paypal.me/milouse"><img alt="Support using Paypal" src="https://img.shields.io/badge/Paypal-Support_me-00457C?logo=paypal&labelColor=lightgray"/></a>

If you like my work, you can help me a lot by giving me some tip through
[[https://paypal.me/milouse][Paypal]]. Thank you very much!

* Installation

[[https://stable.melpa.org/#/flycheck-grammalecte][file:https://stable.melpa.org/packages/flycheck-grammalecte-badge.svg]]

[[https://melpa.org/#/flycheck-grammalecte][file:https://melpa.org/packages/flycheck-grammalecte-badge.svg]]

This package has a strong dependency on ~python3~. The installation of
the right version of python is up to you.

/Flycheck grammalecte/ is available on MELPA stable and unstable. Please
read the [[https://www.emacswiki.org/emacs/InstallingPackages][Installing Package documentation]] from the EmacsWiki to know
more how to install a package.

Otherwise, just clone this repository somewhere and load necessary files from
your GNU Emacs config file:

#+begin_src emacs-lisp
cd ~/.emacs.d
git clone https://git.umaneti.net/flycheck-grammalecte
#+end_src

#+begin_src emacs-lisp
(load-file "~/.emacs.d/flycheck-grammalecte/grammalecte.el")
(load-file "~/.emacs.d/flycheck-grammalecte/flycheck-grammalecte.el")
#+end_src

To enable it, simply add the following line somewhere in your GNU Emacs
config file:

#+begin_src emacs-lisp
  (with-eval-after-load 'flycheck
    (flycheck-grammalecte-setup))
#+end_src

Finally, the last expected step is to download the
[[https://grammalecte.net/#download][CLI & Server upstream package]]. Just enter the following command:
~M-x grammalecte-download-grammalecte~.

You can also add it to your Gnu Emacs config file, but be warned that it
might introduce some delay when starting Emacs, due to the http request
made to check the grammalecte version and eventually upgrade of the
package:

#+begin_src emacs-lisp
  (with-eval-after-load 'flycheck
    (grammalecte-download-grammalecte)
    (flycheck-grammalecte-setup))
#+end_src

* Usage

Enable /flycheck/ in a buffer, which major mode is declared in
~flycheck-grammalecte-enabled-modes~, and voilà!

To correct a word or expression at point, you can use the command
~flycheck-grammalecte-correct-error-at-point~, which is bind to
~C-c ! g~ by default. You can also right-click on it and a menu will
popup to let you choose the better correction.

If you are looking for a better word at some place, you can use the
function ~grammalecte-find-synonyms-at-point~ (which will take the word
at point to find synonyms and antonyms) or the simpler
~grammalecte-find-synonyms~ (which will ask you for a word before doing
the search). These functions are always available, even in buffer, which
major mode is not in the ~flycheck-grammalecte-enabled-modes~ list.

* Configuration

** Generic way

All options are accessibles with ~customize~. In GNU Emacs, enter
~M-x customize~, then click on ~Editing~, then ~I18n~, and finally on
~Flycheck Grammalecte~.

You can also set these variables in your GNU Emacs config file with
~setopt~. This can be done before or after the
~flycheck-grammalecte-setup~ call.

#+begin_src emacs-lisp
  (with-eval-after-load 'flycheck
    (flycheck-grammalecte-setup)
    (setopt flycheck-grammalecte-report-esp nil)
    (add-to-list 'flycheck-grammalecte-enabled-modes 'fountain-mode))
#+end_src

Here is a quick reference of the available variables:

- ~flycheck-grammalecte-report-spellcheck~ :: If this variable is set to
     ~nil~, Flycheck will *not* report spellchecking error. Only grammar
     errors will be notified. ~nil~ is the default value as you should
     better use /flyspell/ or /ispell/.
- ~flycheck-grammalecte-report-grammar~ :: If this variable is set to
     ~nil~, Flycheck will *not* report grammar error. Only spellchecking
     errors will be notified. Default is ~t~.
- ~flycheck-grammalecte-report-apos~ :: If this variable is set to
     ~nil~, Flycheck will *not* report typographical apostrophes (’)
     error. This can be useful when your main editor mode manage
     apostrophe by itself (like LaTeX, org-mode export…). Default is
     ~t~.
- ~flycheck-grammalecte-report-nbsp~ :: If this variable is set to
     ~nil~, Flycheck will *not* report non-breakable spaces
     error. This can be useful when your main editor mode manage
     spaces by itself (like LaTeX, org-mode export…). Default is ~t~.
- ~flycheck-grammalecte-report-esp~ :: If this variable is set to
     ~nil~, Flycheck will *not* report useless spaces and tabs error.
     This can be useful when your main editor mode manage spaces by
     itself (like LaTeX, org-mode export…). Default is ~t~.
- ~flycheck-grammalecte-report-typo~ :: If this variable is set to
     ~nil~, Flycheck will *not* report typographic glyphs errors such as
     parenthesis or quotation marks mismatch, use of dots
     instead of ellipsis, use of minus instead of dash, etc.
     Default is ~t~.
- ~flycheck-grammalecte-enabled-modes~ :: This variable stores the list
     of major modes for which /flycheck-grammalecte/ must be
     used. Default is ~'(latex-mode mail-mode markdown-mode message-mode
     mu4e-compose-mode org-mode text-mode)~.
     To add markdown mode use the following line for example:
     ~(add-to-list 'flycheck-grammalecte-enabled-modes 'fountain-mode)~
- ~flycheck-grammalecte-filters~ :: Patterns for which errors in
     matching texts are ignored. See its documentation for
     details. There is also a ~flycheck-grammalecte~filters-by-mode~
     variable, which allow to enable filters only for a given mode.

** With ~use-package~

Here is the minimal working configuration:

#+begin_src emacs-lisp
  (use-package flycheck-grammalecte :defer t
    :config (flycheck-grammalecte-setup))
#+end_src

However, you may want to configure it a little more, and be sure the
Grammalecte python package is always here. Thus the following example
illustrates a more complete scenario. In that one, please take note how the
~flycheck-grammalecte-enabled-modes~ is customized in the ~:config~ section
instead of the ~:init~ section, to be sure the package has been loaded and
thus the list already exists.

#+begin_src emacs-lisp
  (use-package flycheck-grammalecte :defer t
    :hook (fountain-mode . flycheck-grammalecte-setup)
    :custom
    (flycheck-grammalecte-report-apos nil)
    (flycheck-grammalecte-report-esp nil)
    (flycheck-grammalecte-report-nbsp nil)
    :config
    (add-to-list 'flycheck-grammalecte-enabled-modes 'fountain-mode)
    (grammalecte-download-grammalecte))
#+end_src

** Breaking changes

*** Version 2.0

This version comes with a big refactoring, separating Flycheck only stuff from
other usefull functions in two different lisp packages: ~flycheck-grammalecte~
and ~grammalecte~. A long list of variables and functions, which were
previously prefixed by ~flycheck-grammalecte-~ are now prefixed with
~grammalecte-~ and have been moved in a dedicated file. Here is the list of
the most common ones you may already have interacted with:

- variables:
  + ~flycheck-grammalecte--debug-mode~ renamed as ~grammalecte--debug-mode~
  + ~flycheck-grammalecte--directory~ renamed as ~grammalecte--site-directory~
  + ~flycheck-grammalecte-grammalecte-directory~ renamed as ~grammalecte-python-package-directory~
  + ~flycheck-grammalecte-download-without-asking~ renamed as ~grammalecte-download-without-asking~
  + ~flycheck-grammalecte-mode-map~ renamed as ~grammalecte-mode-map~
- functions:
  + ~flycheck-grammalecte--grammalecte-version~ renamed as ~grammalecte--version~
  + ~flycheck-grammalecte--grammalecte-upstream-version~ renamed as ~grammalecte--upstream-version~
  + ~flycheck-grammalecte-kill-ring-save~ renamed as ~grammalecte-kill-ring-save~
  + ~flycheck-grammalecte-save-and-replace~ renamed as ~grammalecte-save-and-replace~
  + ~flycheck-grammalecte-define~ renamed as ~grammalecte-define~
  + ~flycheck-grammalecte-define-at-point~ renamed as ~grammalecte-define-at-point~
  + ~flycheck-grammalecte-find-synonyms~ renamed as ~grammalecte-find-synonyms~
  + ~flycheck-grammalecte-find-synonyms-at-point~ renamed as ~grammalecte-find-synonyms-at-point~
  + ~flycheck-grammalecte-conjugate-verb~ renamed as ~grammalecte-conjugate-verb~
  + ~flycheck-grammalecte-download-grammalecte~ renamed as ~grammalecte-download-grammalecte~

*** Version 1.0

As you may have noticed, the most important change is the introduction
of the function ~flycheck-grammalecte-setup~, which didn't exist
before. If you don't add it to your init file, the checker won't be
added to Flycheck checkers list and will never start. Thus, you are
required now to add the following line *after* your customization to
this package:

#+begin_src emacs-lisp
  (flycheck-grammalecte-setup)
#+end_src

*** Version 0.9

This version changes the default value of
~flycheck-grammalecte-report-spellcheck~ to ~nil~, making now
grammalecte to *not* report spellchecking errors. If you like the old
behavior, you are now required to explicitely set this variable to ~t~.

* Contributing

See [[./CONTRIBUTING.org]]

* Credits

The original package has been written by Guilhem Doulcier.

This package would have not existed without the nice work of the people
behinds the [[https://grammalecte.net/][Grammalecte]] and the [[http://crisco.unicaen.fr/des/synonymes/synonyme][“Dictionnaire Électronique des
Synonymes”]] projects.

About

Fork of flycheck-grammalecte to support Grammalecte v0.6.4+ (Mirror)

Topics

Resources

Contributing

Stars

15 stars

Watchers

4 watching

Forks

Releases

Sponsor this project

Contributors

Languages