in Emacs flyspell-mode, how to add new word to dictionary?

incandescentman picture incandescentman · Feb 28, 2014 · Viewed 7.9k times · Source

In Aquamacs in flyspell-mode, when flyspell flags a word as misspelled, I can right-click to add the word to my dictionary if it is in fact correctly spelled.

In GNU Emacs on OSX, when flyspell-mode highlights a word it thinks is misspelled, how can I add the word to the dictionary? Looking at the documentation, I do not see a function like flyspell-learn-word or ispell-add-word-to-personal-dictionary.

Answer

user2053036 picture user2053036 · Mar 1, 2014

The function you are looking for is flyspell-correct-word-before-point. By default it is bound to the keys C-c$. Move your point to the incorrect word and execute the command. You will get a popup-menu with possible corrections and an option to save the word to you dictionary.

If you want a single command to save the current word, this is what I was able to extract from flyspell.el

(defun my-save-word ()
  (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))))