Emacs和ispell:加载german8时出错

use*_*900 8 emacs elisp

当我在文本模式下使用flyspell-mode时尝试加载"german8"拼写字典时收到此错误消息:

Error in post-command-hook (flyspell-post-command-hook): (error "Error: The file "/usr/lib/aspell/deutsch\" can not be opened for reading.")
Run Code Online (Sandbox Code Playgroud)

我已经检查过,没有/ usr/lib/aspell/deutsch.Ubuntu synaptic包管理器给了我"aspell-de",并没有明确它.

这是我的.emacs中的代码启动了麻烦:

;;switch dictionaries between German and English with F8 key
(defun fd-switch-dictionary()
      (interactive)
      (let* ((dic ispell-current-dictionary)
         (change (if (string= dic "deutsch8") "english" "deutsch8")))
        (ispell-change-dictionary change)
        (message "Dictionary switched from %s to %s" dic change)
        ))

(global-set-key (kbd "<f8>")   'fd-switch-dictionary)
Run Code Online (Sandbox Code Playgroud)

我可以通过简单地启动flyspell-mode然后尝试执行ispell-change-dictionary来重复同样的错误.提供german8,但消息再次出现:

 Error enabling Flyspell mode:
(Error: The file "/usr/lib/aspell/german" can not be opened for reading.)
Run Code Online (Sandbox Code Playgroud)

blu*_*e10 6

我遇到了完全相同的问题,但我找到了一个非常简单的解决方法.我假设

  • 你的Emacs拼写检查器设置为aspell,即 (setq-default ispell-program-name "aspell")

  • 安装适当的aspell字典,例如apt-get install aspell-de.

由于某种原因,字典列表中似乎存在一个错误,即"看到",即执行时可用的字典列表ispell-change-dictionary.选择"deutsch"时会尝试加载"/usr/lib/aspell/deutsch\".但是,看起来aspell字典名称已更改,因为aspell-de现在包含名为的字典de_DE*.我想@Daniel Ralston的回答是为了解决这个问题,但这对我不起作用.我也尝试将实际的字典名称传递给ispell-change-dictionary,但不知怎的,它坚持从自己的列表中获取字典,我从不能说服我的字典确实是正确的.

对我来说有用的是一个简单的符号链接修复.起初我不确定我应该用什么符号链接,因为错误看起来像是试图从名为"deutsch" 的目录加载字典.但事实证明它实际上是在寻找一个典型的aspell .alias文件.所以通过使用这个符号链接

sudo ln -s /usr/lib/aspell/de_DE.alias /usr/lib/aspell/deutsch.alias
Run Code Online (Sandbox Code Playgroud)

我现在可以简单地选择"deutsch"了ispell-change-dictionary.

  • 对我来说,这很有效:我安装了包“aspell-de”(通过 apt,而不是在 Emacs 内),重新启动 Emacs,并选择了德语词典。不需要符号链接。它也不是自动创建的。 (2认同)

Dan*_*ton 1

最近,一些旧的和常用的字典别名似乎已从德语 aspell 包中删除。这使得 emacs 的德语词典定义变得过时。尝试将其添加到您的.emacs

\n\n
(eval-after-load "ispell"\n  \'(add-to-list \'ispell-dictionary-alist\n                \'("deutsch8"\n                   "[a-zA-Z\xc3\xa4\xc3\xb6\xc3\xbc\xc3\x9f\xc3\x84\xc3\x96\xc3\x9c]" "[^a-zA-Z\xc3\xa4\xc3\xb6\xc3\xbc\xc3\x9f\xc3\x84\xc3\x96\xc3\x9c]" "[\']" t\n                  ("-C" "-d" "de_DE-neu.multi")\n                  "~latin1" iso-8859-1)))\n
Run Code Online (Sandbox Code Playgroud)\n