[OS X Emacs] using Mac system spelling autocorrection?

David Reitter david.reitter at gmail.com
Thu Feb 23 19:47:15 EST 2012


On Feb 23, 2012, at 6:55 PM, Peter Salazar wrote:

> You're right! And so it is. It looks like ispell is configured correctly. And when I mistype a word in Aquamacs, it appears in red and I can right-click and Aquamacs shows me nice suggestions.  
> 
> What I SHOULD have asked is: how do I get Aquamacs to automatically REPLACE mistyped words the way other OSX apps do (and the way abbrevs does)? 
> 
> Example: In TextEdit, if I type wihtout, it gets automatically changed to without. 

I see.

Aquamacs can't do this as of now, but what you can do is press M-Tab after a word that's been highlighted (flyspell mode has to be on = Check Spelling as you Type).  That'll correct it, and you can cycle through different alternatives.

That said, it wouldn't be hard to implement some sort of fully automatic correction.   
If someone here can do it, I'd be happy to integrate it with Aquamacs.  I don't have time to figure out the details at the moment.

Flyspell already has the code in place to make this happen.  The following code is a proof-of-concept, although important bits don't work (I find it unusable).

(defun my-flyspell-auto-correct-word (beg end corrections)
  ;; "corrections" is, at times, incorrect (bug!)
  (let ((alternative (car (ns-spellchecker-get-suggestions (buffer-substring beg end)))))
    (when alternative
      (undo-boundary) ;; this does not work
      (save-excursion
	(delete-region beg end)
	(let ((transient-mark-mode t))
	  (funcall flyspell-insert-function alternative)))
      ;; 'remove-highlighting
      ;; M-tab afterwords also fails to work.
      ;; Undo fails to work.
      nil)))

(add-hook 'flyspell-incorrect-hook 'my-flyspell-auto-correct-word)


--
http://aquamacs.org -- Aquamacs: Emacs on Mac OS X
http://aquamacs.org/donate -- Could we help you? Return the favor and support the Aquamacs Project!




More information about the MacOSX-Emacs mailing list