Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs and ispell: error loading german8

Tags:

emacs

elisp

I get this error message when I try to load "german8" spelling dictionary while using flyspell-mode in text-mode:

Error in post-command-hook (flyspell-post-command-hook): (error "Error: The file "/usr/lib/aspell/deutsch\" can not be opened for reading.")

I've checked and there is no /usr/lib/aspell/deutsch. Ubuntu synaptic package manager offered me "aspell-de" and that didn't clear it.

Here's the code in my .emacs that started the trouble:

;;switch dictionaries between German and English with F8 key
(defun fd-switch-dictionary()
      (interactive)
      (let* ((dic ispell-current-dictionary)
         (change (if (string= dic "deutsch8") "english" "deutsch8")))
        (ispell-change-dictionary change)
        (message "Dictionary switched from %s to %s" dic change)
        ))

(global-set-key (kbd "<f8>")   'fd-switch-dictionary)

I can repeat this same error by simply starting flyspell-mode then trying to do ispell-change-dictionary. german8 is offered, but the message appears again:

 Error enabling Flyspell mode:
(Error: The file "/usr/lib/aspell/german" can not be opened for reading.)
like image 784
user2054900 Avatar asked Mar 11 '13 19:03

user2054900


2 Answers

I was having exactly the same problem, but I have found a very simple workaround. I assume

  • your Emacs spell checker is set to aspell, i.e., (setq-default ispell-program-name "aspell")

  • the appropriate aspell dictionary is installed, for example by apt-get install aspell-de.

For some reason there seems to be a bug in the list of dictionaries that ispell "sees", i.e., the list of dictionaries that are available when you perform ispell-change-dictionary. When selecting "deutsch" it tries to load "/usr/lib/aspell/deutsch\". However it looks like the aspell dictionary names have changed, since aspell-de now contains dictionaries called de_DE*. I guess the idea of @Daniel Ralston's answer is to fix this, but this didn't work for me. I also tried to pass the actual dictionary names to ispell-change-dictionary, but somehow it insisted on getting a dictionary from its own list and I never could convince it that my dictionary is indeed correct.

What is working for me though is a simple symlink fix. At first I wasn't sure what I'm supposed to symlink, because the error looks like it was trying to load the dictionary from a directory called "deutsch". But it turned out that it is actually looking for a typical aspell .alias file. So by using this symlink

sudo ln -s /usr/lib/aspell/de_DE.alias /usr/lib/aspell/deutsch.alias

I can now simply chose "deutsch" in ispell-change-dictionary.

like image 171
bluenote10 Avatar answered Sep 28 '22 09:09

bluenote10


Recently, some old and oft-used dictionary aliases seem to have been removed from the German aspell package. This has made emacs' German dictionary definitions obsolete. Try adding this to your .emacs:

(eval-after-load "ispell"
  '(add-to-list 'ispell-dictionary-alist
                '("deutsch8"
                   "[a-zA-ZäöüßÄÖÜ]" "[^a-zA-ZäöüßÄÖÜ]" "[']" t
                  ("-C" "-d" "de_DE-neu.multi")
                  "~latin1" iso-8859-1)))
like image 37
Daniel Ralston Avatar answered Sep 28 '22 08:09

Daniel Ralston