checkers/spell: add support for using enchant

This commit is contained in:
Jussi Timperi 2020-08-26 13:57:06 +03:00
parent 1c99aed0c0
commit 1a3326be53
No known key found for this signature in database
GPG key ID: D45BB8A65A7A058F
3 changed files with 39 additions and 16 deletions

View file

@ -33,7 +33,7 @@ loaded last*, before =:config= modules.
* :checkers * :checkers
+ syntax =+childframe= - Live error/warning highlights + syntax =+childframe= - Live error/warning highlights
+ spell =+everywhere +aspell +hunspell= - Spell checking + spell =+everywhere +aspell +hunspell +enchant= - Spell checking
+ grammar - TODO + grammar - TODO
* :completion * :completion

View file

@ -11,6 +11,7 @@
- [[#prerequisites][Prerequisites]] - [[#prerequisites][Prerequisites]]
- [[#aspell][Aspell]] - [[#aspell][Aspell]]
- [[#hunspell][Hunspell]] - [[#hunspell][Hunspell]]
- [[#enchant][Enchant]]
- [[#features][Features]] - [[#features][Features]]
- [[#configuration][Configuration]] - [[#configuration][Configuration]]
- [[#changing-how-quickly-spell-fu-spellchecks-after-changes][Changing how quickly spell-fu spellchecks after changes]] - [[#changing-how-quickly-spell-fu-spellchecks-after-changes][Changing how quickly spell-fu spellchecks after changes]]
@ -23,7 +24,7 @@
- [[#troubleshooting][Troubleshooting]] - [[#troubleshooting][Troubleshooting]]
* Description * Description
This modules provides spellchecking powered by =aspell= or =hunspell=. This modules provides spellchecking powered by =aspell=, =hunspell= or =enchant=.
Spellcheck is automatically loaded in many ~text-mode~ derivatives, which Spellcheck is automatically loaded in many ~text-mode~ derivatives, which
includes ~org-mode~, ~markdown-mode~, the Git Commit buffer (from magit), includes ~org-mode~, ~markdown-mode~, the Git Commit buffer (from magit),
@ -37,6 +38,7 @@ This module has no dedicated maintainers.
but supports multiple languages and dictionaries. but supports multiple languages and dictionaries.
+ =+aspell= Use =aspell= as a backend for correcting words. + =+aspell= Use =aspell= as a backend for correcting words.
+ =+hunspell= Use =hunspell= as a backend for correcting words. + =+hunspell= Use =hunspell= as a backend for correcting words.
+ =+enchant= Use =enchant-2= as a backend for correcting words.
+ =+everywhere= Spell check in programming modes as well (in comments). + =+everywhere= Spell check in programming modes as well (in comments).
** Plugins ** Plugins
@ -50,14 +52,15 @@ This module has no dedicated maintainers.
+ [[https://gitlab.com/ideasman42/emacs-spell-fu][spell-fu]] + [[https://gitlab.com/ideasman42/emacs-spell-fu][spell-fu]]
* Prerequisites * Prerequisites
This module requires one of =aspell= or =hunspell= installed on your system and This module requires one of =aspell=, =hunspell= or =enchant-2=
in your ~PATH~. They also need dictionaries for your language(s). installed on your system and in your ~PATH~.
They also need dictionaries for your language(s).
#+begin_quote #+begin_quote
If you *are not* using =+flyspell=, you will need aspell (and a dictionary) If you *are not* using =+flyspell=, you will need aspell (and a dictionary)
installed whether or not you have =+hunspell= enabled. This is because installed whether or not you have =+hunspell= or =+enchant= enabled.
=spell-fu= does not support generating the word list with anything other than This is because =spell-fu= does not support generating the word list
=aspell= yet. with anything other than =aspell= yet.
#+end_quote #+end_quote
** Aspell ** Aspell
@ -77,8 +80,23 @@ installed whether or not you have =+hunspell= enabled. This is because
** TODO Hunspell ** TODO Hunspell
** Enchant
+ Ubuntu: ~apt-get install enchant-2~
+ Arch Linux: ~pacman -S enchant~
+ NixOS:
#+BEGIN_SRC nix
{
environment.systemPackages = with pkgs; [
enchant
];
}
#+END_SRC
Enchant is just a wrapper for other spelling libraries
and you will need to have at least one of the supported backends installed as well.
* Features * Features
+ Spell checking and correction using =aspell= or =hunspell=. + Spell checking and correction using =aspell=, =hunspell= or =enchant=.
+ Ignores source code inside org or markdown files. + Ignores source code inside org or markdown files.
+ Lazily spellchecking recent changes only when idle. + Lazily spellchecking recent changes only when idle.
+ Choosing suggestions using completion interfaces (=ivy= or =helm=). + Choosing suggestions using completion interfaces (=ivy= or =helm=).

View file

@ -16,15 +16,17 @@
'("#\\+BEGIN_SRC" . "#\\+END_SRC") '("#\\+BEGIN_SRC" . "#\\+END_SRC")
'("#\\+BEGIN_EXAMPLE" . "#\\+END_EXAMPLE")) '("#\\+BEGIN_EXAMPLE" . "#\\+END_EXAMPLE"))
;; Enable either aspell or hunspell. ;; Enable either aspell, hunspell or enchant.
;; If no module flags are given, enable either aspell or hunspell if their ;; If no module flags are given, enable either aspell, hunspell or enchant
;; binary is found. ;; if their binary is found.
;; If one of the flags `+aspell' or `+hunspell' is given, only enable that ;; If one of the flags `+aspell', `+hunspell' or `+enchant' is given,
;; spell checker. ;; only enable that spell checker.
(pcase (cond ((featurep! +aspell) 'aspell) (pcase (cond ((featurep! +aspell) 'aspell)
((featurep! +hunspell) 'hunspell) ((featurep! +hunspell) 'hunspell)
((featurep! +enchant) 'enchant)
((executable-find "aspell") 'aspell) ((executable-find "aspell") 'aspell)
((executable-find "hunspell") 'hunspell)) ((executable-find "hunspell") 'hunspell)
((executable-find "enchant-2") 'enchant))
(`aspell (`aspell
(setq ispell-program-name "aspell" (setq ispell-program-name "aspell"
ispell-extra-args '("--sug-mode=ultra" ispell-extra-args '("--sug-mode=ultra"
@ -58,7 +60,10 @@
(`hunspell (`hunspell
(setq ispell-program-name "hunspell")) (setq ispell-program-name "hunspell"))
(_ (doom-log "Spell checker not found. Either install `aspell' or `hunspell'")))) (`enchant
(setq ispell-program-name "enchant-2"))
(_ (doom-log "Spell checker not found. Either install `aspell', `hunspell' or `enchant'"))))
;; ;;