When you run ispell
, Emacs actually calls an external program that usually requires additional dictionaries to be installed separately. One such program you can use (which is well established and crucially the only one that I know how to set up) is GNU Aspell. Dictionaries for Aspell can be installed with dnf
:
sudo dnf install aspell-fr aspell-de # and so on
(Of course if it's not already installed you need to install Aspell itself first: sudo dnf install aspell
. I think all these commands translate directly for apt
.)
Now you need to tell Emacs to use Aspell instead of the default spell checker. First, call which aspell
from the shell to get the path to Aspell's executable, then set ispell-program-name
to that value in Emacs' init file. In Fedora 33 (and most likely a lot of other distros) Aspell's executable is located at /usr/bin/aspell
, so I'm going to use this value:
(setq ispell-program-name "/usr/bin/aspell")
With Aspell and its dictionaries installed and Emacs set to use them, you should be good to go.
One thing that you may find useful if you switch languages often is this snippet I had found on the EmacsWiki:
;; Quickly switch dictionaries
;; Adapted from DiogoRamos' snippet on https://www.emacswiki.org/emacs/FlySpell#h5o-5
(let ((langs '("francais" "deutch" "english")))
(defvar lang-ring (make-ring (length langs))
"List of Ispell dictionaries you can switch to using ‘cycle-ispell-languages’.")
(dolist (elem langs) (ring-insert lang-ring elem)))
(defun cycle-ispell-languages ()
"Switch to the next Ispell dictionary in ‘lang-ring’."
(interactive)
(let ((lang (ring-ref lang-ring -1)))
(ring-insert lang-ring lang)
(ispell-change-dictionary lang)))
(global-set-key [f10] #'cycle-ispell-languages) ; replaces ‘menu-bar-open’.
It makes F10
change dictionary cycling between the languages listed in the first line.
sudo dnf install aspell
. Find its path:which aspell
, copy it -- most likely it is/usr/bin/aspell
-- into this setting that you have to put in your Emacs init file:(setq ispell-program-name "/usr/bin/aspell")
. Now you should be able to install new dictionaries withdnf
, e.g.sudo dnf install aspell-fr aspell-de
, and so on. I think there are other ways to do that but this is the only one I know.