2015-12-02 14:23:39 +00:00
#+TITLE : Spell Checking layer
2015-08-11 18:00:16 +00:00
2019-05-02 21:49:30 +00:00
#+TAGS : checker|layer
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description ][Description ]]
2017-09-12 09:02:31 +00:00
- [[#features ][Features: ]]
2017-05-22 14:16:12 +00:00
- [[#install ][Install ]]
- [[#layer ][Layer ]]
- [[#spell-checker-configuration ][Spell Checker Configuration ]]
- [[#disabling-by-default ][Disabling by default ]]
- [[#enabling-auto-dictionary-mode ][Enabling auto-dictionary-mode ]]
2017-09-12 09:02:31 +00:00
- [[#enabling-multi-dictionary-support-with-hunspell ][Enabling multi-dictionary support with hunspell ]]
2017-05-22 14:16:12 +00:00
- [[#enable-auto-completion-popup ][Enable auto-completion popup ]]
2018-12-05 03:03:03 +00:00
- [[#key-bindings ][Key bindings ]]
2018-08-26 21:34:34 +00:00
- [[#spell-checking-transient-state ][Spell Checking Transient-state ]]
2017-09-12 09:02:31 +00:00
- [[#known-issues ][Known issues ]]
2015-08-11 18:00:16 +00:00
* Description
2018-02-16 18:44:54 +00:00
This layer provides spell checking capabilities to Spacemacs.
2015-08-11 18:00:16 +00:00
2017-09-12 09:02:31 +00:00
** Features:
2018-02-16 18:44:54 +00:00
- Buffer-wide spell checking via external command (ispell, hunspell, aspell) run through [[http://www-sop.inria.fr/members/Manuel.Serrano/flyspell/flyspell.html ][Flyspell ]].
- Spell as you type
- Optional correction popups, controlled by =enable-flyspell-auto-completion= variable.
- [[https://github.com/nschum/auto-dictionary-mode ][Auto dictionary mode ]] for some languages.
2017-09-12 09:02:31 +00:00
2015-08-11 18:00:16 +00:00
* Install
** Layer
2016-01-06 05:21:55 +00:00
To use this configuration layer, add it to your =~/.spacemacs= . You will need to
add =spell-checking= to the existing =dotspacemacs-configuration-layers= list in this
file.
2015-08-11 18:00:16 +00:00
** Spell Checker Configuration
The built-in Emacs variable that controls which external spell-checking program
2015-09-28 06:05:18 +00:00
is used is =ispell-program-name= , which can be set in your
=dotspacemacs/user-init= function if you do not like the default. It will give
priority to =aspell= if it is installed on your system. Another important
variable to be aware of is =ispell-dictionary= which will control the default
dictionary used by =ispell-program-name= (instead of using this variable you can
also use the key binding ~SPC S d~ ).
2015-08-11 18:00:16 +00:00
2015-08-28 11:02:20 +00:00
** Disabling by default
2015-10-20 13:05:24 +00:00
By default, =spell-checking= is enabled in all available major modes and may be
2015-08-28 11:02:20 +00:00
toggled off with ~SPC t S~ . You can default this to off by setting the variable
=spell-checking-enable-by-default= to =nil= :
#+BEGIN_SRC emacs-lisp
2018-09-19 03:54:47 +00:00
(setq-default dotspacemacs-configuration-layers
'((spell-checking :variables spell-checking-enable-by-default nil)))
2015-08-28 11:02:20 +00:00
#+END_SRC
2015-08-11 18:00:16 +00:00
2015-11-01 16:27:44 +00:00
** Enabling auto-dictionary-mode
=auto-dictionary-mode= tries to detect the current language from the buffer
content, and activate the corresponding dictionary. You can enable it by setting
the variable =spell-checking-enable-auto-dictionary= to something other than
=nil= :
#+BEGIN_SRC emacs-lisp
2018-09-19 03:54:47 +00:00
(setq-default dotspacemacs-configuration-layers
'((spell-checking :variables spell-checking-enable-auto-dictionary t)))
2015-11-01 16:27:44 +00:00
#+END_SRC
2015-11-02 07:25:28 +00:00
Some people encountered bugs with =auto-dictionary-mode= , especially in *daemon
mode* where new =emacsclient= open directly freezed. If so, no other workaround
have been found yet than disabling =auto-dictionary-mode= completely.
Not all languages are supported by =auto-dictionary-list= . The supported
languages are listed in the =adict-language-list= variable, that can be checked
with =spacemacs/describe-variable= . For convenience, here is the list of
currently supported language:
| Language |
|-------------------|
| catalan |
| classical greek |
| danish |
| english |
| esperanto |
| french |
| german |
| hindi |
| hungarian |
| modern greek |
| norwegian bokmål |
| norwegian nynorsk |
| portuguese |
| romanian |
| slovak |
| slovene |
| spanish |
| swedish |
2017-09-12 09:02:31 +00:00
** Enabling multi-dictionary support with hunspell
If your language is not supported by auto-dictionary feature or you author
2019-02-23 11:24:34 +00:00
multi-lingual documents you might be compelled to use hunspell’ s multi-dictionary
2017-09-12 09:02:31 +00:00
mode. For example to enable it for pl_PL and en_GB dictionaries you could put
following code in your dotspacemacs/user-config section in your configuration
file:
#+BEGIN_SRC emacs-lisp
2018-09-19 03:54:47 +00:00
(with-eval-after-load "ispell"
(setq ispell-program-name "hunspell")
;; ispell-set-spellchecker-params has to be called
;; before ispell-hunspell-add-multi-dic will work
(ispell-set-spellchecker-params)
(ispell-hunspell-add-multi-dic "pl_PL,en_GB")
(setq ispell-dictionary "pl_PL,en_GB"))
2017-09-12 09:02:31 +00:00
#+END_SRC
2018-09-19 03:54:47 +00:00
One caveat is you need quite modern ispell.el for above to work. It’ s been
2017-09-12 09:02:31 +00:00
tested with version coming from Emacs 25.2 repository.
2016-06-02 02:52:05 +00:00
** Enable auto-completion popup
To enable auto-completion popup when the point is idle on a misspelled word
set the layer variable =enable-flyspell-auto-completion= to t:
#+BEGIN_SRC emacs-lisp
2018-09-19 03:54:47 +00:00
(setq-default dotspacemacs-configuration-layers
'((spell-checking :variables enable-flyspell-auto-completion t)))
2016-06-02 02:52:05 +00:00
#+END_SRC
2018-12-05 03:03:03 +00:00
* Key bindings
2015-08-11 18:00:16 +00:00
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2018-10-05 06:35:35 +00:00
|-----------------+----------------------------------------|
2018-09-13 20:13:33 +00:00
| ~SPC S a b~ | Add word to dict (buffer) |
| ~SPC S a g~ | Add word to dict (global) |
| ~SPC S a s~ | Add word to dict (session) |
| ~SPC S b~ | Flyspell whole buffer |
| ~SPC S c~ | Flyspell correct |
| ~SPC u SPC S c~ | Flyspell correct all errors one by one |
| ~SPC S d~ | Change dictionary |
| ~SPC S n~ | Flyspell goto next error |
| ~SPC t S~ | Toggle flyspell |
2017-09-12 09:02:31 +00:00
2018-08-26 21:34:34 +00:00
** Spell Checking Transient-state
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2018-08-26 21:34:34 +00:00
|-------------+--------------------------------------------------|
2018-09-03 18:58:38 +00:00
| ~SPC S . b~ | Rerun spell check for the whole buffer |
| ~SPC S . d~ | Change dictionary |
| ~SPC S . n~ | Go to next spelling error |
| ~SPC S . c~ | Correct word under cursor |
| ~SPC S . t~ | Toggle spell check |
| ~SPC S . q~ | Quit transient state |
| ~SPC S . Q~ | Quit transient state and disable =flyspell-mode= |
2018-09-13 20:13:33 +00:00
| ~SPC S . B~ | Add word to dict (buffer) |
| ~SPC S . G~ | Add word to dict (global) |
| ~SPC S . S~ | Add word to dict (session) |
2018-08-26 21:34:34 +00:00
2017-09-12 09:02:31 +00:00
* Known issues
Vim-empty-lines layer seems incompatible with spell-checking inside org-mode. If
2018-09-19 03:54:47 +00:00
you experience “Args out of range” error message when invoking ~SPC S c~ inside
org-mode buffer then check if you don’ t have vim-empty-lines layer enabled and
2017-09-12 09:02:31 +00:00
disable it.