1

How do I set up Hunspell so that I can add new UTF-8 words (e.g. "Rúdi") to my user local dictionary?

I have a function that allows me to add new words to my local dictionary. It works for adding new words that don't contain UTF-8 characters. But if a word contains a UTF-8 character, Flyspell doesn't remember that the newly added word is correctly spelled.

Here's my setup:

(executable-find "hunspell") 
(setq-default ispell-program-name "hunspell")
(setq ispell-really-hunspell t) 
(setq flyspell-default-dictionary "en_US")

(setq ispell-dictionary "en_US")
(setq ispell-program-name "/usr/local/bin/hunspell")
(setenv "DICTIONARY" "en_US")


(setq ispell-program-name "hunspell")
(eval-after-load "ispell"
  '(progn (defun ispell-get-coding-system () 'utf-8)))

(setq ispell-local-dictionary-alist '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil nil nil utf-8))) 

(setq ispell-extra-args '("-d en_US"))

(flyspell-mode-on)

(defun add-word-to-personal-dictionary ()
  (interactive)
  (let ((current-location (point))
        (word (flyspell-get-word)))
    (when (consp word)
      (flyspell-do-correct 'save nil (car word) current-location (cadr word) (caddr word) current-location))))

If it matters, I'm running Hunspell 1.3.3 on OSX Yosemite.

  • 1
    A small thing: you probably wanted (setq-default ispell-program-name (executable-find "hunspell")) executable-find, if successful, has no side effects, so in your case it doesn't make sense to call it the way you did. – wvxvw Jul 19 '15 at 11:47
  • @wvxvw Wow, thank you. So like this? gist.github.com/incandescentman/00e1be81877514983884 Aside from that does everything look right? – incandescentman Jul 19 '15 at 19:29
  • 1
    Yup, like that, and, to my untrained eye it does look alright :) – wvxvw Jul 20 '15 at 5:24
  • Thanks! By the way, do you know how I can view the list of the words I've added to my local dictionary? – incandescentman Jul 20 '15 at 8:13
  • I use aspell so I don't know where hunspell keeps its personal dictionary, but judging from aspell personal dictionary location I'd be looking in the home directory for a file with a .dic suffix. (The aspell dictionary would normally be something like ~/.aspell.en.pws). Also, you can run hunspell -D to ask it to show all known dictionaries, yours will be one of those). – wvxvw Jul 20 '15 at 12:26
0

Solved. The problem was that in my dictionary file, en_US.aff, the first line incorrectly said SET UTF8. I corrected it to read SET UTF-8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.