Hi all,
we have the situation that many AUCTeX styles bake their own definitions
for inserting environments; mostly for key-val options and other sort of
arguments. The issue is that latex.el offers only `LaTeX-env-args'.
Suppose you want to insert an environment with `LaTeX-env-label' and
also have some other arguments after \begin{evn-name}, then you copy the
definition of `LaTeX-env-label' and fiddle the rest into it.
I see two solutions for this:
1. Extend the functions we have, e.g. take this current definition:
(defun LaTeX-env-label (environment)
"Insert ENVIRONMENT and prompt for label."
(LaTeX-insert-environment environment)
(when (TeX-active-mark)
;; Point is at the end of the region. Move it back to the
;; beginning of the region.
(exchange-point-and-mark)
(indent-according-to-mode))
(when (LaTeX-label environment 'environment)
(LaTeX-newline)
(indent-according-to-mode))
(when (TeX-active-mark)
(indent-region (point) (mark))
;; Restore the positions of point and mark.
(exchange-point-and-mark)))
And turn it into this:
(defun LaTeX--env-parse-args (args)
(when args
(save-excursion
(LaTeX-find-matching-begin)
(end-of-line)
(let ((TeX-exit-mark (or TeX-exit-mark
(make-marker))))
(TeX-parse-arguments args)))))
(defun LaTeX-env-label (environment &rest args)
"Insert ENVIRONMENT and prompt for label."
(LaTeX-insert-environment environment)
(when (TeX-active-mark)
;; Point is at the end of the region. Move it back to the
;; beginning of the region.
(exchange-point-and-mark)
(indent-according-to-mode))
(when (LaTeX-label environment 'environment)
(LaTeX-newline)
(indent-according-to-mode))
(when (TeX-active-mark)
(indent-region (point) (mark))
;; Restore the positions of point and mark.
(exchange-point-and-mark))
(LaTeX--env-parse-args args))
2. Introduce new function like this:
(defun LaTeX--env-parse-args (args)
(when args
(save-excursion
(LaTeX-find-matching-begin)
(end-of-line)
(let ((TeX-exit-mark (or TeX-exit-mark
(make-marker))))
(TeX-parse-arguments args)))))
(defun LaTeX-env-label-args (environment &rest args)
(LaTeX-env-label environment)
(LaTeX--env-parse-args args))
WDYT?
Best, Arash