emacs on mac os x, how to get spell check to work

筅森魡賤 提交于 2019-11-30 04:49:41

Here's a working solution:

  • Install Homebrew
  • brew install emacs --with-cocoa --with-gnutls
  • brew install aspell
  • open -a Emacs
  • M-x ispell

Enjoy!

I use aspell from Homebrew. Simply:

brew install aspell --with-lang-en

Then, make sure your brew bin directory is in your Emacs exec-path variable. If you use /usr/local as your brew prefix then it will just work since that path is included in exec-path by default. Otherwise you'll need this somewhere in your .emacs:

  (setq exec-path (append "/path/to/brew/bin" exec-path)))

You can also accomplish the same thing using the customize interface with "M-x customize-variable RET exec-path RET" and then using the gui to add a path.

This will work on any Emacs, including the one from Emacs for Mac OS X, the one from brew, or the system Emacs.

Here is a MacPorts solution to the problem. (Credits to this link)

$ sudo port install aspell

Then install one of aspell's dictionaries for the respective language support

$ sudo port install aspell-dict-en

Then add the following line to your init.el or .emacs file.

(setq ispell-program-name "/opt/local/bin/aspell")

It worked for me.

Note: "sudo ports install ispell" works as well, but it is not as efficient and flexible as aspell.

Lincoln Randall McFarland

Making a symbolic link in /usr/bin on OS X 10.12 (Sierra) is not permitted or necessary (or a good idea).

[iMac ~]$ sudo ln -s /usr/local/bin/ispell /usr/bin/ispell
ln: /usr/bin/ispell: Operation not permitted

I used that hack for years, but was finally forced to figure out the right solution when the last upgrade deleted it. I used homebrew to install ispell and apsell and would get which ever one I set in ~/.emacs with

[iMac ~]$ cat ~/.emacs
(setq ispell-program-name "/usr/local/bin/aspell")

There is a similar discussion of this here.

-lrm

I build on the answers by katspaugh, David Caldwell, and Ébe Isaac, and made it work with the latest versions.

Install aspell, for example with brew:

brew install aspell

brew symlinks to /usr/local/bin and you can verify the installation:

$ which aspell
/usr/local/bin/aspell

Now tell Emacs about this location, e.g. adding this line in ~/.emacs:

(setq ispell-program-name "/opt/local/bin/aspell")

Launch M-x ispell in a buffer and it works.

To install with ports, see other answers.

It also works if you use fink instead than home-brew. ispell will be in /sw/bin and the string to add to .emacs file will be:

(setq ispell-program-name "/sw/bin/ispell")

Installing aspell, and adding (setq ispell-program-name "/usr/local/bin/aspell") in the init.el does not work for me. I had to make a symbolic link sudo ln -s /usr/local/bin/aspell /usr/bin/ispell, then emacs flyspell-mode works OK.

Emacs installed with brew cask install emacs will come with a built in spell checker called m-x ispell.

You have to do two things to get this to work.

  1. brew install aspell or maybe brew install aspell --with-lang-en

  2. go to emacs and evaluate this function or better yet put it in your init file (setq ispell-program-name "/usr/local/bin/aspell")

Note: the location of aspell can be found using which aspell in macOS terminal which should be equal tot step 2. above.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!