[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Emacs and hunspell



Johann Spies [28.03.2019, 10:38 +0200]:
> I, so far, did not manage to use hunspell with emacs.  After reading a lot
> on the internet, inter alia emacs-wiki and stackexchange and trying out
> different recipes, still no success.
>
> My latest effort in .emacs:
>
> (with-eval-after-load "ispell"
>   (setq ispell-program-name "hunspell")
>   (setq ispell-dictionary "af_ZA")
>   ;; ispell-set-spellchecker-params has to be called
>   ;; before ispell-hunspell-add-multi-dic will work
>   (ispell-set-spellchecker-params)
>   (ispell-hunspell-add-multi-dic "af_ZA,en_ZA"))
>
> (setq ispell-program-name (executable-find "hunspell")
>       ispell-dictionary "af_ZA")
> produces the following error message when trying to use the spell process:
>
> ispell-get-decoded-string: No data for dictionary "af_ZA" in
> ‘ispell-local-dictionary-alist’ or ‘ispell-dictionary-alist’

This is how I managed to make it work for me; what follows is in my
init.el file:

  ;;-- Spelling --
  (with-eval-after-load "ispell"
    (setq ispell-program-name (executable-find "hunspell")
          ispell-skip-html t
          ispell-local-dictionary-alist
          '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']"
             nil ("-d" "en_US") nil utf-8)
            ("it_IT" "[[:alpha:]]" "[^[:alpha:]]" "[-]"
             nil ("-d" "it_IT") nil utf-8)
            ("fr_FR" "[[:alpha:]]" "[^[:alpha:]]" "[-]"
             nil ("-d" "fr_FR") nil utf-8)
            ("de_DE" "[[:alpha:]]" "[^[:alpha:]]" "[-]"
             nil ("-d" "de_DE") nil utf-8))
        ispell-dictionary "en_US"))

I use those four languages, but only one at a time.  I tried to adapt my
configuration to a multi-dictionary setup by adding one more item in
ispell-local-dictionary-alist like this:

  ("de_DE,it_IT" "[[:alpha:]]" "[^[:alpha:]]" "[-]"
   nil ("-d" "de_DE,it_IT") nil utf-8)

then, when I use the function ispell-change-dictionary, I can choose
"de_DE,it_IT" from the list of available options and hunspell uses both
dictionaries at the same time.

Keep in mind that there is also bug #916227 [1] related to how emacs
finds installed dictionaries; it is still open but there is a patch
pending.

[1]  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916227

> From what I have read emacs (1:26.1+1-3.2) should just work with hunspell
> even if you just set the last two lines of the above configuration.
> However, it does not seem to pick up the dictionaries.
>
> How do I get it to work?
>
> Regards
> Johann

Hope this helps, best regards.

Alfredo


Reply to: