Make hunspell work with emacs and german language
261
To check if the dictionary is listed in the path run hunspell -D
.
It should output something along those lines:
...
/usr/share/hunspell/en_US
/usr/share/hunspell/de_BE
/usr/share/hunspell/de_LU
/usr/share/hunspell/de_DE
...
Next, add your preferred dictionaries to ispell-local-dictionary-alist
in your .emacs
file
(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
In addition to that you can define a function to switch between the german and english dictionaries and bind it to C-c d
for example
(defun switch-dictionary-de-en ()
"Switch german and english dictionaries."
(interactive)
(let* ((dict ispell-current-dictionary)
(new (if (string= dict "deutsch-hunspell") "english-hunspell"
"deutsch-hunspell")))
(ispell-change-dictionary new)
(message "Switched dictionary from %s to %s" dict new)))
(global-set-key (kbd "C-c d") 'switch-dictionary-de-en)
Related videos on Youtube
Author by
grady
Updated on September 18, 2022Comments
-
grady over 1 year
I have a wordpress blog and what I need is a plugin which adds an info box like http://css-tricks.com/examples/ScrollingSidebar/ whose content can be defined when writing an article. Is there something like that out there or do you have ideas how to accomplish that?
So the box is always there, but the content changes for each article.
Thanks!
-
Christian Herenz over 5 yearsNote that the dictonary names are different for hunspell compared to ispell. Instead of
(setq ispell-dictionary "deutsch8")
, you should use(setq ispell-dictionary "de_DE")
. Note, however, that this requires emacs 24.4 or greater. For earlier versions you need add the definitions toispell-local-dictionary-alist
as provided in the accepted answer.
-
-
student about 10 yearsThanks. I think you should add a
(require 'ispell)
before the(add-to-list 'ispell-local...)
line. -
antonio over 9 yearsI think it will not hurt if I add a little comment for those Windows users who might fall on this. In Windows Emacs has the
LANG
environment variable set to the regional settings. It is a good idea to add something like(setenv "LANG" "en_US")
to your init file. This will be your initial dictionary, unless you change it. The defaultLANG
value might be set to something possibly weird (sayENG
), generating an ispell/hunspell error. -
legends2k over 8 years@antonio True, but in my case,
(setenv "DICTIONARY" "en_GB")
worked. -
Christian Herenz over 5 yearsThe creation of custom dictionary entries for hunspell is not required for emacs > 24.