stu*_*ent 9 emacs spell-checking hunspell
我想hunspell
在 ubuntu 13.04-box 上使用 emacs24 和德语词典。
要做到这一点我安装hunspell
和hunspell-de
并添加以下到我的.emacs
文件:
(setq ispell-program-name "hunspell")
(setq ispell-dictionary "deutsch8")
Run Code Online (Sandbox Code Playgroud)
当我在 emacs 中打开一个文件并启动时,flyspell-buffer
我得到了Starting new Ispell process [[hunspell::deutsch8]]
但它阻塞了 emacs 缓冲区(鼠标变成了一个旋转磁盘,指示等待)并且无休止地工作而不显示任何结果。所以我的配置肯定有问题。
没有第二行它可以工作,但仅适用于英文文本。
那么什么是设置的最佳方式hunspell
为emacs24
在Ubuntu 13.04德语字典?是否有任何可能的陷阱?
小智 7
要检查字典是否在路径中列出,请运行hunspell -D
。它应该沿着这些线输出一些东西:
...
/usr/share/hunspell/en_US
/usr/share/hunspell/de_BE
/usr/share/hunspell/de_LU
/usr/share/hunspell/de_DE
...
Run Code Online (Sandbox Code Playgroud)
接下来,将您的首选词典添加到ispell-local-dictionary-alist
您的.emacs
文件中
(add-to-list 'ispell-local-dictionary-alist '("deutsch-hunspell"
"[[:alpha:]]"
"[^[:alpha:]]"
"[']"
t
("-d" "de_DE"); Dictionary file name
nil
iso-8859-1))
(add-to-list 'ispell-local-dictionary-alist '("english-hunspell"
"[[:alpha:]]"
"[^[:alpha:]]"
"[']"
t
("-d" "en_US")
nil
iso-8859-1))
(setq ispell-program-name "hunspell" ; Use hunspell to correct mistakes
ispell-dictionary "deutsch-hunspell") ; Default dictionary to use
Run Code Online (Sandbox Code Playgroud)
除此之外,您可以定义一个函数来在德语和英语词典之间切换并将其绑定到C-c d
例如
(defun switch-dictionary-de-en ()
"Switch german and english dictionaries."
(interactive)
(let* ((dict ispell-current-dictionary)
(new (if (string= dict "deutsch-hunspell") "english-hunspell"
"deutsch-hunspell")))
(ispell-change-dictionary new)
(message "Switched dictionary from %s to %s" dict new)))
(global-set-key (kbd "C-c d") 'switch-dictionary-de-en)
Run Code Online (Sandbox Code Playgroud)