How can I change the language in Emacs when using ispell?
The following command proposes a list of installed dictionaries to use:
M-x ispell-change-dictionary
Usually, M-x isp-c-d
expands to the above also.
From the file ispell.el you may specify some options for the ispell
commands. This happens by adding a section to the end of your file like this:
;; Local Variables:
;; ispell-check-comments: exclusive
;; ispell-local-dictionary: "american"
;; End:
Note the double semicolon marks the start of comments in the current mode. It should probably be changed to reflect the way your file (programming language) introduces comments, like //
for Java.
At the end of a LaTeX file you can use:
%%% Local Variables:
%%% ispell-local-dictionary: "british"
%%% End:
that will set the dictionary to be used just for that file.
Use M-x ispell-change-dictionary
and hit TAB
to see what dictionary are available for you.
Then write the setting of default dictionary in your .emacs
, and add a hook to start ispell automatically for you specific mode (if you want).
For instance, start ispell in AUCTeX automatically using British English (by default English dictionary is American English)
(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
If you want to change the language on a per-directory basis, you can add this to a .dir-locals.el
file:
(ispell-local-dictionary . "american")
If you have no .dir-locals.el
file already, it will look like this:
((nil .
((ispell-local-dictionary . "american")))
)
See the emacs wiki page about directory variables for more information.