1

I seem to be unable to configure hunspell to work within emacs. I have hunspell 1.7.0 and emacs 25.3. Supposedly, emacs should be able to find hunspell by default, but it seems that it is unable to find all the dictionaries, actually, it seems to be only to find "default" dictionary and returns 'nil'. I have tried the functions named on the comments here, namely ispell-find-hunspell-dictionaries and it seems that I do not have that function or I do not know how to acces it. Also I do now know how to acces hunspell-dictionary-alist and ispell-local-dictionary-alist I also tried the solutions suggested elsewhere, namely to put something like this in .emacs:

;; Set $DICPATH to "$HOME/Library/Spelling" for hunspell.
(setenv
 "DICPATH"
  "/usr/share/hunspell")
;; Tell ispell-mode to use hunspell.
(setq-default 
  ispell-program-name
  "/usr/bin/hunspell")

Or something like this:

(setq ispell-program-name (executable-find "hunspell")
      ispell-dictionary "en_GB")

But they also seem not work. I still have no access to the dictionaries. I need to be able to choose dictionaries in english (both british and us variants), spanish (mexican), german (de) and portugues (Brazil). I cannot seem to grasp the solutions pointed here, and how to modify the extra entrances in .emacs for all the mentionated languages.

wpkzz
  • 121
  • 4
  • 1
    There is a bug that prevents this from working with hunspell 1.7 and older emacs, unfortunately. See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=33493 and https://www.reddit.com/r/emacs/comments/ahysvb/having_flyspell_hunspell_issues_read_here_finally/ – Erik Hetzner Jul 03 '19 at 19:08

2 Answers2

1

A few points here. When you say "I have tried the functions named on the comments here, namely ispell-find-hunspell-dictionaries and it seems that I do not have that function or I do not know how to access it," I'm guessing you are trying to do something with it in your initialization file. However, since this function is not autoloaded, you have to (require 'ispell) to get access to it. Try invoking (with M-:):

(progn
  (require 'ispell)
  (message "%S" (ispell-find-hunspell-dictionaries))
  t)

...and see what it tells you in the *Messages* buffer.

The second thing: DICPATH (according to the man page for hunspell) refers to where the application will look for custom dictionaries, but actually, if you want to explicitly set a dictionary, you can use the DICTIONARY environment variable. Your question is a little confusing, though, because you code in /usr/share/hunspell, but comment that you're looking for $HOME/Library/Spelling.

The last item is that Emacs actually does what you are doing in your set-default:

(defcustom ispell-program-name
  (or (executable-find "aspell")
      (executable-find "ispell")
      (executable-find "hunspell")
      "ispell")
  "Program invoked by \\[ispell-word] and \\[ispell-region] commands."
  :type 'string
  :set (lambda (symbol value)
         (set-default symbol value)
         (if (featurep 'ispell)
             (ispell-set-spellchecker-params)))
  :group 'ispell)

However, it doesn't seem like you're having an issue with finding hunspell (what does C-h ispell-program-name tell you the value is? is Emacs finding aspell first?), but with changing the settings.

You should also know that you can interactively change the dictionary for your current buffer (or all buffers with a prefix command) by invoking M-x ispell-change-dictionary. No require commands needed.

cyberbisson
  • 887
  • 1
  • 6
  • 17
0

See my answer https://emacs.stackexchange.com/a/22311/202

You need test cli program hunspell first

chen bin
  • 4,781
  • 18
  • 36