Hi Arash,

>>>>> Arash Esbati <[email protected]> writes:
> 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.

Thank you for raising this issue. I like the idea of increasing
flexibility of environment insertion facility.

> I see two solutions for this:

Both solutions looks feasible.  ...Hm, how about this third one?

(defun LaTeX--env-foo (environment env-func &rest args)
  (funcall env-func environment)
  ;; Instead of the above line, maybe...
  ;; (if (symbolp env-func)
  ;;     (funcall env-func environment)
  ;;   ;; Allow (functionname arg1 arg2 ...) for env-func value:
  ;;   (apply (pop env-func) environment env-func))

  (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)))))

I expect this usage:
(LaTeX-add-environments
  '("bar" LaTeX--env-foo LaTeX-env-label "XXX" ["YYY"])
    ...)

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine

Reply via email to