1

My .emacs file contains the following code to make hunspell work, however I get the following error message when starting flyspell-mode:

Starting new Ispell process hunspell with deutsch-hunspell dictionary...
Error enabling Flyspell mode:
(ispell-phaf: No matching entry for deutsch-hunspell.
)

Any idea of how to fix this?

(add-to-list 'ispell-local-dictionary-alist '("deutsch-hunspell"
                                              "[[:alpha:]]"
                                              "[^[:alpha:]]"
                                              "[']"
                                              t
                                              ("-d" "de_DE"); Dictionary file name
                                              nil
                                              iso-8859-1))

(add-to-list 'ispell-local-dictionary-alist '("english-hunspell"
                                              "[[:alpha:]]"
                                              "[^[:alpha:]]"
                                              "[']"
                                              t
                                              ("-d" "en_US")
                                              nil
                                              iso-8859-1))

(setq ispell-program-name "hunspell"          ; Use hunspell to correct mistakes
      ispell-dictionary   "deutsch-hunspell") ; Default dictionary to use

hunspell -D gives:

 hunspell -D
SEARCH PATH:
.::/usr/share/hunspell:/usr/share/myspell:/usr/share/myspell/dicts:/Library/Spelling:/home/dw/.openoffice.org/3/user/wordbook:.openoffice.org2/user/wordbook:.openoffice.org2.0/user/wordbook:Library/Spelling:/opt/openoffice.org/basis3.0/share/dict/ooo:/usr/lib/openoffice.org/basis3.0/share/dict/ooo:/opt/openoffice.org2.4/share/dict/ooo:/usr/lib/openoffice.org2.4/share/dict/ooo:/opt/openoffice.org2.3/share/dict/ooo:/usr/lib/openoffice.org2.3/share/dict/ooo:/opt/openoffice.org2.2/share/dict/ooo:/usr/lib/openoffice.org2.2/share/dict/ooo:/opt/openoffice.org2.1/share/dict/ooo:/usr/lib/openoffice.org2.1/share/dict/ooo:/opt/openoffice.org2.0/share/dict/ooo:/usr/lib/openoffice.org2.0/share/dict/ooo
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
/usr/share/hunspell/de_DE
/usr/share/hunspell/de_LU
/usr/share/hunspell/de_BE
/usr/share/hunspell/en_US
/usr/share/myspell/dicts/hyph_lt_LT
Can't open affix or dictionary files for dictionary named "en_AU".

I am working on an ubuntu 15.10 box with emacs 24.5.1

student
  • 1,007
  • 9
  • 29

3 Answers3

2

Insert below code into ~/.emacs or ~/.emacs.d/init,

(setq ispell-program-name "hunspell")
(setq ispell-local-dictionary "de_DE")
(setq ispell-local-dictionary-alist
      '(("de_DE" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil nil nil utf-8)))

AFTER above setup, you need turn on flyspell-mode by (flyspell-mode 1).

Please make sure your dictionary is loaded properly. This is hunspell setup instead of Emacs setup.

At Linux, you don't need extra setup (if your dictionaries are installed in a standard location).

At other operating systems, here is the easiest way to hint hunspell where to search the dictionary.

You only need setup environment variable DICPATH by export DICPATH=/usr/share/hunspell/de_DE in Bash (At windows, you can setup environment variable through "Control Panel"). Both de_DE.dic and de_DE.aff should exist in that directory.

Or you just change your locale to de_DE

ivanm
  • 107
  • 5
chen bin
  • 4,781
  • 18
  • 36
  • With this I get: `Error enabling Flyspell mode: (ispell-phaf: No matching entry for nil. )` – student Feb 01 '16 at 08:51
  • set environment variable DICPATH – chen bin Feb 01 '16 at 12:42
  • I have set the DICTPATH in my .profile file and checked it in my emacs session via `getenv`. The directory `/usr/share/hunspell/` contains the file `de_DE.aff` and `de_DE.dic`. Howver I get the same error. – student Feb 02 '16 at 18:00
  • what's your OS? emacs version? – chen bin Feb 02 '16 at 22:51
  • DICPATH is only needed for non-Linux OS. In your case, my original answer is enough. what you can do is re-install hunspell-de-de (maybe dictionary is broken?). Then use my setup at http://github.com/redguardtoo/emacs.d (maybe you mistakenly override emacs default setup?) – chen bin Feb 04 '16 at 01:44
  • @I just pulled your .emacs.d and tested it. With that configuration flyspell worked, but I am not sure if it used hunspell since you seem to have conditional and use hunspell only if installed... Then I tried a minimal .emacs file with your code above but it doesn't work. Any idea for another minimal .emacs file to try? – student Feb 09 '16 at 11:08
  • My linux and emacs version are at the end of my original post. – student Feb 09 '16 at 11:12
  • yeah, I notice that, it should works out of the box on ubuntu. Check my previous comment, set your locale to de_DE and see what happens. – chen bin Feb 10 '16 at 00:30
  • I re-read my notes on http://blog.binchen.org/posts/what-s-the-best-spell-check-set-up-in-emacs.html. It says the hunspell will always search the dictionary specified by your locale (in your case, en_AU) even you don't use it. looks that dictionary is not installed. – chen bin Feb 10 '16 at 00:40
  • 1
    Thanks now it works. There was also another problem: I had the line `(add-hook 'LaTeX-mode-hook 'turn-on-flyspell)` before the dictionaries are setup. Moving this line below the dictionary definitions maked it work. – student Feb 10 '16 at 14:44
  • Yes, you'd better initialize the dictionary at the beginning of ~/.emacs, turn on flyspell in major-mode-hook. – chen bin Feb 11 '16 at 04:15
2

I compiled Emacs today (March 14, 2016) from git, version 25.1.50.1 for Windows 8.1, 64-bit. Run into the same issue. Found this answer by the indefatigable Eli Zaretskii and shortened the code for hunspell to this lines in my .emacs:

(add-to-list 'exec-path "C:/cygwin64/usr/local/bin")
(setq ispell-program-name (executable-find "hunspell"))
(ispell-change-dictionary "de_DE" t)

OK, you see, hunspell was installed at the given path. I set the DICPATH variable to this locations as well. I set the DICTIONARY variable to "de_DE".

It was hard to find where hunspell stored the personal dictionary. I found it eventually at $HOME, the name of the file was hunspell_de_DE.

So it seems the whole installation is a lot easier nowadays.

Keks Dose
  • 508
  • 4
  • 19
  • This solved it for me on Emacs 26.1 on Windows 10. No need to play with the local dictionary when installing with http://sourceforge.net/projects/ezwinports/files – Doctor David Anderson Jul 27 '18 at 09:54
0

What causes the error ispell-phaf: No matching entry ... is the name deutsch-hunspell. By some reason ispell.el assumes that this is a real dictionary name and tries to locate corresponding files, namely deutsch-hunspell.dic and deutsch-hunspell.aff under /usr/share/hunspell directory.

That said, you should use only names found under /usr/share/hunspell/ and only those of them that have an affix file (.aff) that are base dictionaries in hunspell terms (man hunspell for more details).

This does not mean however that if you specify de_DE hunspell will use /usr/share/hunspell/de_DE.{dic,aff} only. You can customize the exact set of dictionaries by means of -d option that will be passed to hunspell. For example, like this:

(setq ispell-local-dictionary-alist
      '(("de_DE" "[[:alpha:]]" "[^[:alpha:]]" "[']" t
         ("-d" "de_DE,de_med") nil iso-8859-1)))
Nik O'Lai
  • 101
  • 2