1

I wish there were a way so that when I mistype a word, flyspell could autocorrect it to the "most likely" correction. When I mistype a word and then hit OPTION-TAB to correct it, flyspell ALMOST ALWAYS picks the correct correction by default as the main suggestion.

However, I want flyspell to do this with every word I mistype, WITHOUT my having to hit OPTION-TAB. Just from hitting the SPACE bar and moving on to the next word.

Is this possible?

1 Answer 1

4

You could use something like this:

(defun  my-flyspell-auto-correct-and-space ()
  (interactive)
  (flyspell-auto-correct-word)    ;; Auto-correct the word at point
  (when (not (or (looking-at " ") ;; If after the correction we are in the
                 (eolp)))         ;; middle of the word, forward to the end
      (forward-word))             ;; of the word.
  (insert " "))                   ;; insert a space

(global-set-key (kbd "SPC") 'my-flyspell-auto-correct-and-space)
2
  • Wow, thank you, this works perfectly, EXCEPT the keybinding. I get: Warning (initialization): An error occurred while loading `/Users/jay/.emacs': error: Key sequence ⇧S ⇧P ⇧C starts with non-prefix key ⇧S Commented Jan 24, 2013 at 23:32
  • @peter My bad, you can use either (global-set-key " " 'my-flyspell-auto-correct-and-space) or (global-set-key (kbd "SPC") 'my-flyspell-auto-correct-and-space)
    – Robin Joy
    Commented Jan 25, 2013 at 9:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .