Skip to content

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

License

Notifications You must be signed in to change notification settings

milouse/flycheck-grammalecte

Repository files navigation

Flycheck-grammalecte

Integrate the french grammar and typography checker Grammalecte with 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

Support using Liberapay Support using Paypal

If you like my work, you can help me a lot by giving me some tip, either through Liberapay or Paypal. Thank you very much!

Installation

https://stable.melpa.org/packages/flycheck-grammalecte-badge.svg

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 Installing Package documentation from the EmacsWiki to know more how to install a package. A manual installation procedure exists too if you prefer.

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

(with-eval-after-load 'flycheck
  (flycheck-grammalecte-setup))

Finally, the last expected step is to download the CLI & Server upstream package. Just enter the following command: M-x grammalecte-download-grammalecte

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[fn:1]. 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 flycheck-grammalecte-find-synonyms-at-point (which will take the word at point to find synonyms and antonyms) or the simpler flycheck-grammalecte-find-synonyms (which will ask you for a word before doing the search). Pro tip: these functions are available even in buffer, which major mode is not in the flycheck-grammalecte-enabled-modes list.

[fn:1] In fact, it is bind only to g in the flycheck-command-map, C-c ! being the flycheck default prefix.

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. Configuration must occurs before calling flycheck-grammalecte-setup. In that case, don’t forget to first require flycheck-grammalecte to prefill its variables. For example:

(with-eval-after-load 'flycheck
  (setq flycheck-grammalecte-report-esp nil)
  (require 'flycheck-grammalecte)
  (add-to-list 'flycheck-grammalecte-enabled-modes 'fountain-mode)
  (grammalecte-download-grammalecte)
  (flycheck-grammalecte-setup))

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:

(use-package flycheck-grammalecte
             :config (flycheck-grammalecte-setup))

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.

(use-package flycheck-grammalecte
             :hook (fountain-mode . flycheck-mode)
             :init
             (setq 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)
             (flycheck-grammalecte-setup))

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:

(flycheck-grammalecte-setup)

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.

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 Grammalecte and the “Dictionnaire Électronique des Synonymes” projects.