2015-10-22 47 views
0

我想在GNU Emacs 24.5.1(Mac OS X 11.10)中激活拼寫檢查。我做了以下操作:Emacs使用hunspell進行拼寫檢查:沒有完成拼寫檢查

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.。我怎樣才能使這個工作?

我發現thisthisthis有關的帖子,但還是搞不清楚問題所在。

回答

2

好吧,我想通了:設置環境變量DICTIONARY~/.bash_profile沒有工作,但(setenv "DICTIONARY" "en_US").emacs解決了這個問題。

0

我用此條件加載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的init腳本:

(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"))