0

M-x ispell works fine for English. However, when I try to change the dictionary, I run into difficulties.

I did M-x ispell-change-dictionary and selected one of the options (francais) from the list presented. Then when I try to use M-x ispell, I get the following message:

ispell-init-process: Can't open affix or dictionary files for dictionary named "fr_FR".

I have the same problem when I select any language option other than british or american.

I am using emacs on Fedora 33. How do I get ispell to work for other languages than English?

5
  • You need to install the other dictionaries. Did you do that? Feb 4 at 11:05
  • How do I do that?
    – usernumber
    Feb 4 at 14:27
  • Well, one way to do it is to make Emacs use Aspell. First things first, install Aspell: 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 with dnf, 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. Feb 4 at 15:27
  • That worked ! Awesome :)
    – usernumber
    Feb 4 at 17:30
  • Let me turn the comment into an answer and add a bonus function.. Feb 4 at 17:59
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.