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

2

37

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.

Whitcomb answered 28/2, 2014 at 22:37 Comment(3)
Is the function flyspell-correct-word-before-point defined, try calling it with (C-c $) with point on the incorrect word, it gives an option to save the word.Menell
Is there a way to do this without navigating through a drop-down menu?Whitcomb
Is there a way to add a compound like "half-hearted" ? Only "hearted" gets the wiggly red underline and flyspell tries to add "hearted" to the dictionary.Barth
M
56

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))))
Menell answered 1/3, 2014 at 15:45 Comment(2)
But where is the new word saved to?Gussi
@strongwillow, in ~/.aspell.LANG.pws, for aspell or ~/.ispell_DICTNAME for ispell. See emacs.stackexchange.com/questions/17237/…Obstructionist
O
19

You can probably use M-$ to open suggestions, then i to save to dictionary. You'd be prompted for confirmation.

Source

Ophiuchus answered 15/5, 2018 at 7:13 Comment(2)
that's three steps, whereas the accepted solution above is one stepWhitcomb
to avoid confirmation and just save it: (setq ispell-silently-savep t)Epicene

© 2022 - 2024 — McMap. All rights reserved.