hunspellをemacsとgermanで使用する

hunspellをemacsとgermanで使用する

hunspellUbuntu 13.04-boxでドイツ語辞書でemacs24を使用したいです。

そのために、以下をインストールしてhunspellファイルhunspell-deに追加しました.emacs

(setq ispell-program-name "hunspell")
(setq ispell-dictionary "deutsch8")

Emacsでファイルを開いて起動すると、flyspell-bufferこのメッセージが表示されますが、Starting new Ispell process [[hunspell::deutsch8]]Emacsバッファをブロックし(マウスが待機を示すロータリーディスクに変わります)、何も表示せずに無限に動作します。それでは、私の構成に何か問題があるのは間違いありません。

2行目なしで動作しますが、英語のテキストにのみ適用されます。

hunspellそれでは、Ubuntu 13.04でemacs24ドイツ語辞書を設定する最良の方法は何ですか?可能なトラップはありますか?

ベストアンサー1

Emacs 24.4以降、ispellパッケージはHunspellとその辞書をすぐにサポートします。したがって、initファイルに次の2行を追加すると、Hunspellをデフォルトのスペルチェッカーに設定し、ドイツ語をデフォルトのスペルチェック言語に設定するのに十分です。

(setq ispell-program-name "hunspell"
      ispell-dictionary   "de_DE")

24.4以前のEmacsバージョンの場合は、次の手順に進みます。

辞書がパスにリストされていることを確認するには、hunspell -D次のように出力する必要があります。

...
/usr/share/hunspell/en_US
/usr/share/hunspell/de_BE
/usr/share/hunspell/de_LU
/usr/share/hunspell/de_DE
...

次に、お気に入りの辞書をファイルに追加します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

これに加えて、ドイツ語と英語の辞書を切り替えてそれらをバインドする機能を定義することもできます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)

おすすめ記事