Homepage: http://www.dur.ac.uk/p.j.heslin/Software/Emacs
Author: Peter Heslin
Updated:
Switch flyspell language according to LaTeX
This package examines the LaTeX code around point to discover the language of the current text, and then it caches that value in a text-property. This means that, if you modify or add a Babel command to change the language of some text, the current language may be out of sync with the cached value. In this case, you can just stop typing for a bit, and the surrounding text will be re-parsed, and the new, correct language should be determined. The length of time that Emacs is idle before this re-parsing happens is configurable via the variable flyspell-babel-delay (default is 5 seconds). The parsing done by this package has its limits limited, and so it will not work with arbitrary LaTeX code. I hope that these restrictions will not in practice impinge on the typical usage of most people. The first language declaration is usually determined by the final language option passed to the babel \usepackage command, which takes effect after \begin{document}. Thereafter, you can switch the declared language with \selectlanguage statements, otherlanguage environments, and \foreignlanguage commands. You can also define your own language-switching commands, and register these with flyspell-babel. This package does not understand complex LaTeX constructs, such as \input. If you want to set the default language for a particular file (for example, one that has no Babel declaration, but is going to be \input into a file that does), you can just put a redundant \selectlanguage declaration at the start of the file. You can limit the scope of a \selectlanguage declaration by putting an opening brace immediately before it, and flyspell-babel will respect that scoping, but not otherwise, since that would make the task of parsing too complex. By default, an ispell dictionary is invoked with the same name as the current Babel language or dialect, which works in many cases. If your ispell has a different name for that language, you have two options. You can make ispell recognize the Babel name by adding symlinks under that name in your Ispell directory. Alternatively, you can customize flyspell-babel-to-ispell-alist, which maps Babel languages and dialects to Ispell language names. If you map a language to 'nil, that means not to spell-check that language, which can be useful for languages without an ispell dictionary.