feat!: rewrite spell-checking section
This includes some prose rewriting, as well as an update to the code to take advantage of a custom Aspell dictionary.
This commit is contained in:
parent
ad0b2cda72
commit
4e2b5484b0
1 changed files with 40 additions and 15 deletions
55
config.org
55
config.org
|
|
@ -2311,33 +2311,58 @@ The default Nix file template is for a NixOS module. This is nice when you're wr
|
|||
|
||||
#+call: confpkg("Pkg: ispell")
|
||||
|
||||
Doom Emacs sets up spell-checking with ~ispell~ (Emacs-internal tool) and =aspell= (external tool) for us, which is nice. We just need to set which dictionary to use:
|
||||
Keeping with its general theme of flexibility at the cost of pain, Emacs's spell-checking functionality requires several different packages to be installed, as well as an external spell-checking program to interface with. Let's set all these up in order:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(after! ispell
|
||||
(setq ispell-dictionary "en_US"))
|
||||
*** Aspell
|
||||
|
||||
The recommended external spell-checker is GNU Aspell, which takes a dictionary of words in a particular language and uses it to spell-check a text file. The default English dictionary is named =en_US=; I've created my own dictionary file based on it named =en_US-custom= with Aspell's multi-dictionary feature.
|
||||
|
||||
#+begin_src sh
|
||||
# en_US-custom.multi
|
||||
add en_US-w_accents.multi
|
||||
add en-computers.rws
|
||||
add en_US-science.rws
|
||||
#+end_src
|
||||
|
||||
We also need to generate a plain-text dictionary for some ~ispell~ functionality, which is annoying, but I haven't figured out a way around it. I could use my automated nix-build system for this, but in this case it's easier to just put it in the usual location.
|
||||
*** Ispell
|
||||
|
||||
Now that we have our new-and-improved template registry system, we can add new file templates as we please.
|
||||
The most basic spell-checker package in Emacs is the built-in ~ispell~. This package doesn't actually provide any of the standard front-end of a spell-checker you would expect from a modern text editor, it just manages Aspell. It's a good start, though.
|
||||
|
||||
First, we need to give it our custom dictionary:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defvar ~/plaintext-dict (expand-file-name "ispell/dict.plain" doom-data-dir)
|
||||
"File location of a plaintext wordlist for spellchecking.")
|
||||
(setq ispell-dictionary "en_US-custom")
|
||||
#+end_src
|
||||
|
||||
We then also need a plain-text dictionary for certain features, like spelling correction. This is annoying, but easy to implement with some light scripting.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defvar ~/plaintext-dict
|
||||
(expand-file-name (concat "ispell/" ispell-dictionary ".txt")
|
||||
doom-data-dir)
|
||||
"File location of a plain-text wordlist for spell-checking.")
|
||||
|
||||
(unless (file-readable-p ~/plaintext-dict)
|
||||
(shell-command-to-string
|
||||
(concat
|
||||
"aspell -l en_US dump master > " ~/plaintext-dict ";"
|
||||
"aspell -d en-computers.rws dump master >> " ~/plaintext-dict ";"
|
||||
"aspell -d en_US-science.rws dump master >> " ~/plaintext-dict ";")))
|
||||
(concat "aspell -d '" ispell-dictionary "' dump master > " ~/plaintext-dict)))
|
||||
|
||||
(after! ispell
|
||||
(setq ispell-alternate-dictionary ~/plaintext-dict))
|
||||
(setq ispell-alternate-dictionary ~/plaintext-dict)
|
||||
#+end_src
|
||||
|
||||
Now that we have this word list, we can also plug it into ~cape-dict~ and get proper spelling completion!
|
||||
Ispell also manages our personal dictionary, which it places in a reasonable default position.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Don't ask for confirmation to save to personal dictionary
|
||||
(setq ispell-silently-savep t)
|
||||
#+end_src
|
||||
|
||||
*** ~spell-fu~
|
||||
|
||||
In order to modernize our spell-checker, we need the ubiquitous red squiggly lines to indicate incorrectly spelled words. The package ~spell-fu~ is serviceable for this purpose.
|
||||
|
||||
*** ~cape~
|
||||
|
||||
We now have spelling correction working, but no spelling completion. The package ~cape~ offers in-buffer completion for various things, including for dictionary words. We just need to provide it the plain-text dictionary we created earlier.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(after! cape
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue