Adding support for environment are very much like adding support for TeX macros, except that each environment normally only take one argument, an environment hook. The example is again a short version of `latex.el'.
(TeX-add-style-hook "latex" (function (lambda () (LaTeX-add-environments '("document" LaTeX-document-hook) '("enumerate" LaTeX-item-hook) '("itemize" LaTeX-item-hook) '("list" LaTeX-list-hook)))))
The only hook that is general useful is
LaTeX-item-hook, which is
used for environments that contains items. It is completely up to the
environment hook to insert the environment, but the function
LaTeX-insert-environment may be to some help. The hook will be
called with the name of the environment as its first argument, and extra
arguments can be provided by adding them to list after the hook.
If a environment is defined multiple times, AUC TeX will chose the one with the longest definition. Thus, if you have a enumerate style file, and want it to replace the standard LaTeX enumerate hook above, you could define an `enumerate.el' file as follows, and place it in the appropriate style directory.
(TeX-add-style-hook "latex" (function (lambda () (LaTeX-add-environments '("enumerate" LaTeX-enumerate-hook foo))))) (defun LaTeX-enumerate-hook (environment &optional ignore) ...)
foo will be passed to
the second argument, but since we only added it to overwrite the
definition in `latex.el' it is just ignored.
Function: LaTeX-add-environments env ...
Add each env to list of loaded environments.
Function: LaTeX-insert-environment env [ extra ]
Insert environment of type env, with optional argument extra.