ispellを使用しているときにEmacsの言語を変更するにはどうすればよいですか?
質問
Emacsでispell-bufferコマンドを使用したいと思います。デフォルトでは英語が使用されます。別の辞書(別の言語など)に切り替える簡単な方法はありますか?
解決
次のコマンドは、使用するインストール済み辞書のリストを提案します。
M-x ispell-change-dictionary
通常、 M-x isp-c-d
は上記にも展開されます。
他のヒント
ispell.elファイルから、 ispell
コマンドのいくつかのオプションを指定できます。これは、次のようにファイルの最後にセクションを追加することで発生します。
;; Local Variables:
;; ispell-check-comments: exclusive
;; ispell-local-dictionary: "american"
;; End:
ダブルセミコロンは、現在のモードでコメントの開始を示すことに注意してください。ファイル(プログラミング言語)がJavaの //
などのコメントを導入する方法を反映するように変更する必要があります。
LaTeXファイルの最後で使用できるもの:
%%% Local Variables:
%%% ispell-local-dictionary: "british"
%%% End:
そのファイルにのみ使用される辞書を設定します。
M-x ispell-change-dictionary
を使用し、 TAB
を押して、使用可能な辞書を確認します。
.emacs
にデフォルトの辞書の設定を記述し、特定のモード(必要な場合)でispellを自動的に開始するフックを追加します。
たとえば、英国英語を使用して自動的にispellをAUCTeXで起動します(デフォルトでは英語の辞書はアメリカ英語です)
(add-hook 'LaTeX-mode-hook 'flyspell-mode) ;start flyspell-mode
(setq ispell-dictionary "british") ;set the default dictionary
(add-hook 'LaTeX-mode-hook 'ispell) ;start ispell
ディレクトリごとに言語を変更する場合は、これを .dir-locals.el
ファイルに追加できます。
(ispell-local-dictionary . "american")
.dir-locals.el
ファイルがまだない場合は、次のようになります。
((nil .
((ispell-local-dictionary . "american")))
)
詳細については、ディレクトリ変数に関するemacs wikiページを参照してください。
便宜上(f7).emacsに次を追加しました:
(global-set-key [f7] 'spell-checker)
(require 'ispell)
(require 'flyspell)
(defun spell-checker ()
"spell checker (on/off) with selectable dictionary"
(interactive)
(if flyspell-mode
(flyspell-mode-off)
(progn
(flyspell-mode)
(ispell-change-dictionary
(completing-read
"Use new dictionary (RET for *default*): "
(and (fboundp 'ispell-valid-dictionary-list)
(mapcar 'list (ispell-valid-dictionary-list)))
nil t))
)))
ところで:必要な辞書をインストールすることを忘れないでください。例えば。 debian / ubuntuで、ドイツ語と英語の辞書用:
sudo apt install aspell-de aspell-en