1

我想在 GNU Emacs 24.5.1(在 Mac OS X 11.10 上)中激活拼写检查。我做了以下事情:

1) brew install hunspell
2) cd ~/Library/Spelling
   wget http://cgit.freedesktop.org/libreoffice/dictionaries/plain/en/en_US.aff
   wget http://cgit.freedesktop.org/libreoffice/dictionaries/plain/en/en_US.dic

hunspell -D从终端正确运行)。在~/.bash_profile我设置export DICTIONARY=en_US和我的~/.emacs节目中:

;; Activate Hunspell
(when (executable-find "hunspell")
  (setq-default ispell-program-name "/usr/local/bin/hunspell")
  (setq ispell-really-hunspell t))

;; Activate flyspell
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'message-mode-hook 'flyspell-mode)
(setq flyspell-issue-message-flag nil)
(mapcar (lambda (mode-hook) (add-hook mode-hook 'flyspell-prog-mode))
    '(c-mode-common-hook R-mode-hook emacs-lisp-mode-hook))

但是,当我打开任何.txt文件时,我看不到带下划线的拼写检查错误或任何内容......并且M-x ispell显示ispell-parse-hunspell-affix-file: ispell-phaf: No matching entry for nil.. 我怎样才能让它工作?

我找到了这个这个以及这个相关的帖子,但仍然无法找出问题所在。

4

2 回答 2

3

好的,我想通了: 设置环境变量DICTIONARYin~/.bash_profile不起作用,但放入(setenv "DICTIONARY" "en_US")解决.emacs了问题。

于 2015-10-22T21:18:28.543 回答
2

我用它来有条件地加载hunspell是否flyspell可以通过use-package使用en_GB字典加载。

终端命令:

brew install hunspell
cd ~/Library/Spelling/
wget http://cgit.freedesktop.org/libreoffice/dictionaries/plain/en/en_GB.aff
wget http://cgit.freedesktop.org/libreoffice/dictionaries/plain/en/en_GB.dic
ln -s en_GB.dic english.dic
ln -s en_GB.aff english.aff

然后在我的 Emacs 初始化脚本中:

  (use-package flyspell
    :hook ((text-mode . flyspell-mode)
           (prog-mode . flyspell-prog-mode))
    :config
    (when (executable-find "hunspell")
      (setq ispell-program-name (executable-find "hunspell"))
      (setq ispell-really-hunspell t)
      (setenv "DICTIONARY" "english"))
    (setq ispell-dictionary "english"))
于 2018-01-22T12:00:19.060 回答