Assuming you are using flyspell
, yes it is possible!
The package flyspell-babel.el should do exactly what you want: read inline language changes for babel, and start a flyspell
process for that language.
According to the documentation:
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.
Therefore, you may have to make your other language change commands, such as \foreignquote
, known to flyspell-babel
.
This package requires the package flyspell-multi.el
(no known link at the moment) or ispell-multi.el
to start several flyspell
processes at the same time, to avoid slowdowns when scrolling through a file with language changes.
Installation instructions
Put the files flyspell-babel.el
and flyspell-multi.el
somewhere in the load-path and add the following lines to your .emacs
:
(autoload 'flyspell-babel-setup "flyspell-babel")
(add-hook 'latex-mode-hook 'flyspell-babel-setup)
To add support for other commands, add the following lines to your .emacs
:
(add-to-list 'flyspell-babel-command-alist ("hyphenquote" "hyphenquote"))
(add-to-list 'flyspell-babel-command-alist ("foreignquote" "foreignquote"))
(add-to-list 'flyspell-babel-environment-alist ("hyphenrules" "hyphenrules"))
All credit goes to Peter Heslin, the author of these two packages.
If you want to use the color
value of the font-latex-fontify-sectioning
variable add the following code to your .emacs
(setq font-latex-fontify-sectioning 'color)
You must use 'color
and not 'color'
because the '
character is used to quote the next Lisp symbol and Emacs would interpret 'color'
as the color'
symbol, but AUCTeX doesn't accept that value for the font-latex-fontify-sectioning
variable.
Instead, if you want to set font-latex-fontify-sectioning
to 1 use
(setq font-latex-fontify-sectioning 1.0)
Setting font-latex-fontify-sectioning
to 1.
doesn't work because in Emacs Lisp 1.
is an integer (see Integer Type on the GNU Emacs Lisp Reference Manual) and (setq font-latex-fontify-sectioning 1)
doesn't work either due to a bug (now fixed) inside the current (11.87) stable version of AUCTeX.
Best Answer
This can be done by using language specific hooks in AUCTeX. To automatically load the Danish ispell dictionary when a document includes
\usepackage[danish]{babel}
put the following in your .emacs: