1

I have trouble getting spellchecking to work with Emacs 24.2.1 and Hunspell 1.3.2 on Windows XP.

I have read the help about spelling in the built in manual and searched the internet where I found advice to include these lines to my ~/.emacs.d/init.el file.

(setq ispell-dictionary-alist
   '((nil ; default
      "[a-zäöüßA-ZÄÖÜ]" "[^a-zäöüßA-ZÄÖÜ]" "[']" t
      ("-d" "C:\\Dokumente und Einstellungen\\ojones\\Eigene Dateien\\dictionaries\\de_DE_frami" "-i" "utf-8") nil utf-8)
     ("english"
      "[A-Za-z]" "[^A-Za-z]" "[']" nil
      ("-d" "en_GB") nil utf-8)
     ("german"
      "[a-zäöüßA-ZÄÖÜ]" "[^a-zäöüßA-ZÄÖÜ]" "[']" t
      ("-d" "'C:\\Dokumente und Einstellungen\\ojones\\Eigene Dateien\\dictionaries\\de_DE_frami'" "-i" "utf-8") nil utf-8)
     ("british"
      "[A-Za-z]" "[^A-Za-z]" "[']" nil
      ("-d" "en_GB") nil utf-8)))
(eval-after-load "ispell"
    (progn
      (setq ispell-dictionary "german"
        ispell-extra-args '("-a" "-i" "utf-8") ; aspell doesn't understand -i utf-8, hunspell needs it
        ispell-silently-savep t)))
(setq ispell-program-name "C:\\Dokumente und Einstellungen\\ojones\\Eigene Dateien\\hunspell-mingw-1.3.2-win32\\bin\\hunspell.exe")

where I made changes regarding the path to the affix and dictionary files and the hunspell.exe.

I verified that hunspell works, by executing it on the command line.

When I type M-x ispell in emacs I get the following error message

Can't open affix or dictionary flies for dictionary named "german".
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)

I tried changing the path to the affix and dictionary files in my init.el to just the name of the affix and dic name, i.e. "de_DE_frami" since hunspell knows where to find them, but it didn't help in emacs.

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
Florian Mans
  • 83
  • 1
  • 7

3 Answers3

1

I'm getting closer to the solution.

Because Emacs overwrites the variable ispell-dictionary-alist after M-x ispell I changed my approach to using ispell-local-dictionary-alist. Here is what my ~/.emacs.d/init.el looks like now:

(setq ispell-program-name "C:\\Dokumente und Einstellungen\\ojones\\Eigene Dateien\\hunspell-mingw-1.3.2-win32\\bin\\hunspell.exe")

(setq ispell-local-dictionary-alist
 '(("en_GB"
    "[[:alpha:]]"
    "[^[:alpha:]]"
    "[']" nil ("-r") nil utf-8)
   ("de_DE_frami"
    "[a-zäöüßA-ZÄÖÜ]" "[^a-zäöüßA-ZÄÖÜ]" "[']" nil
    ("-r") nil utf-8)))

When I start Emacs I have to change the dictionary by M-x ispell-change-dictionary and then choosing e.g. de_DE_frami.

That works. But it still dosen't work correctly. I got this error while checking the whole text in the buffer with M-x ispell:

Ispell misalignment: word `Einf\303' point 118; probably incompatible versions

It has a Problem with the word "Einführung". I guess the "ü" is the problem. Checking the word by M-$ I get this error message:

Ispell and its process have different character maps

Any suggestions?

Florian Mans
  • 83
  • 1
  • 7
  • After tracing the problem to the odd behaviour that the variable `ispell-dictionary-alist` is overwritten after `M-x ispell` I figured out that this post [link](http://stackoverflow.com/questions/11626363/interactive-spell-checking-programs-available-for-emacs/11630019#11630019) is of relevance. It describes the similar problem (and now I understand it) and says that this is a bug in debian-ispell.el. – Florian Mans Jan 11 '13 at 17:10
0

Single backslashes in string literals are definitely wrong: in elisp, they are escapes, and either assigning a special meaning to the following character, or quoting that character.

Replace \ with \\: "C:\\Dokumente.....". Also make sure that your init.el is really loaded, by doing C-h v ispell-dictionary-alistEnter and checking the value of `ispell-dictionary-alist.

Anton Kovalenko
  • 20,999
  • 2
  • 37
  • 69
  • Thanks for your help. I already use double backslashes. I have made some changes that helped a bit. But it still doesn't work correctly. I have edited my question accordingly to my changes and posted it as an answer. – Florian Mans Jan 11 '13 at 10:11
  • Now `"'C:\\Dokumente..."` has extra apostrophes at the beginning and the end. Normally there's no need to quote command arguments if command is represented as a list of strings. Did you added apostrophes because it did not work without them? And btw, does it work with en_GB dictionary with your current settings? – Anton Kovalenko Jan 11 '13 at 10:14
  • Thanks, I changed that, see my "answer" to my original question. Doesn't work with en_GB. – Florian Mans Jan 11 '13 at 13:15
0

I made some changes to my init.el and now the error message that the affix and dictionary files can't be opened does no longer appear. But I get a new error.

Here is my modified init.el

(setq ispell-dictionary-alist
 '((nil ; default 
    "[a-zäöüßA-ZÄÖÜ]" "[^a-zäöüßA-ZÄÖÜ]" "[']" t
    ("-d" "de_DE_frami") nil utf-8)
   ("en_GB"
    "[A-Za-z]" "[^A-Za-z]" "[']" nil
    ("-d" "en_GB") nil utf-8)
   ("de_DE_frami"
    "[a-zäöüßA-ZÄÖÜ]" "[^a-zäöüßA-ZÄÖÜ]" "[']" t
    ("-d" "de_DE_frami") nil utf-8)))
(eval-after-load "ispell"
  (progn
    (setq ispell-dictionary "de_DE_frami"
          ispell-extra-args '("-a" "-i" "utf-8") ; aspell doesn't understand -i utf-8, hunspell needs it
          ispell-silently-savep t)))
(setq ispell-program-name "C:\\Dokumente und Einstellungen\\ojones\\Eigene Dateien\\hunspell-mingw-1.3.2-win32\\bin\\hunspell.exe")

I changed the names of the dictionaries in the ispell-dicationary-alist to the names they have, e.g. I changed "german" to "de_DE_frami". I made sure the dictionary and affix files are saved in a place where hunspell finds them (I verified that by executing hunspell on the command line, it works).

Now when I start ispell by M-x ispell there is no error message and I see an ispell process using M-x list-processes:

Process: ispell

Status: run

Buffer: --

TTY: --

Command: C:\Dokumente und Einstellungen...\hunspell.exe -a -d de_DE_frami -i nil -a -i utf-8

But it dosen't work as far as I can tell. No words are identified as misspelled (I included some for testing purpose). When I turn on flyspell by M-x flyspell-mode there is this error message:

Error in post-command-hook (flyspell-post-command-hook): (error "No data for dictionary \"de_DE_frami\", neither in 'ispell-local-dictionary-alist' nor in 'ispell-dictionary-alist'")

Checking that the variable ispell-dicationary-alist contains what is specified in my init-el by typing "ispell-dicationary-alist" in the scratch buffer and pressing C-j at the end of that line, I get this unexpected text:

(("hebrew" "[\340\341\342\343\344\345\346\347\350\351\353\352\354\356\355\360\357\361\362\364\363\367\366\365\370\371\372]" "[^\340\341\342\343\344\345\346\347\350\351\353\352\354\356\355\360\357\361\362\364\363\367\366\365\370\371\372]" "" nil ("-B") nil cp1255) ("svenska" "[A-Za-z\345\344\366\351\340\374\350\346\370\347\305\304\326\311\300\334\310\306\330\307]" "[^A-Za-z\345\344\366\351\340\374\350\346\370\347\305\304\326\311\300\334\310\306\330\307]" "[']" nil ("-C") "~list" iso-8859-1) ("slovenian" "[A-Za-z\301\304\311\315\323\332\324\300\305\245\335\256\251\310\317\253\322\341\344\351\355\363\372\364\340\345\265\375\276\271\350\357\273\362]" "[^A-Za-z\301\304\311\315\323\332\324\300\305\245\335\256\251\310\317\253\322\341\344\351\355\363\372\364\340\345\265\375\276\271\350\357\273\362]" "" nil ("-B" "-d" "slovenian") nil iso-8859-2) ("slovak" "[A-Za-z\301\304\311\315\323\332\324\300\305\245\335\256\251\310\317\253\322\341\344\351\355\363\372\364\340\345\265\375\276\271\350\357\273\362]" "[^A-Za-z\301\304\311\315\323\332\324\300\305\245\335\256\251\310\317\253\322\341\344\351\355\363\372\364\340\345\265\375\276\271\350\357\273\362]" "" nil ("-B") nil iso-8859-2) ("russianw" "[\300\301\302\303\304\305\250\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\334\333\332\335\336\337\340\341\342\343\344\345\270\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\374\373\372\375\376\377]" "[^\300\301\302\303\304\305\250\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\334\333\332\335\336\337\340\341\342\343\344\345\270\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\374\373\372\375\376\377]" "" nil nil nil windows-1251) ("russian" "[\341\342\367\347\344\345\263\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\370\371\377\374\340\361\301\302\327\307\304\305\243\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\330\331\337\334\300\321]" "[^\341\342\367\347\344\345\263\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\370\371\377\374\340\361\301\302\327\307\304\305\243\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\330\331\337\334\300\321]" "" nil nil nil koi8-r) ("portugues" "[a-zA-Z\301\302\307\311\323\340\341\342\351\352\355\363\343\347\372]" "[^a-zA-Z\301\302\307\311\323\340\341\342\351\352\355\363\343\347\372]" "[']" t ("-C") "~latin1" iso-8859-1) ("polish" "[A-Za-z\241\243\246\254\257\261\263\266\274\277\306\312\321\323\346\352\361\363]" "[^A-Za-z\241\243\246\254\257\261\263\266\274\277\306\312\321\323\346\352\361\363]" "[.]" nil nil nil iso-8859-2) ("norsk7-tex" "[A-Za-z{}\'^]" "[^A-Za-z{}\\'^]" "[\"]" nil ("-d" "norsk") "~plaintex" iso-8859-1) ("norsk" "[A-Za-z\305\306\307\310\311\322\324\330\345\346\347\350\351\362\364\370]" "[^A-Za-z\305\306\307\310\311\322\324\330\345\346\347\350\351\362\364\370]" "[\"]" nil nil "~list" iso-8859-1) ("nederlands8" "[A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]" "[^A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]" "[']" t ("-C") nil iso-8859-1) ("nederlands" "[A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]" "[^A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]" "[']" t ("-C") nil iso-8859-1) ...)

Whereas when Emacs is frehly started my init.el correctly sets the variable ispell-dictionary-alist.

Hope this helps in tracking the problem down.

Best Oliver

Florian Mans
  • 83
  • 1
  • 7