Hi Jim,

Jim via General discussion about AUCTeX <[email protected]> writes:

> In ConTeXt there are commands with mandatory arguments that are
> nonetheless surrounded by [], rather than {}.
>
> I have tried various incantations, but I have not discovered any way
> to make a [] argument mandatory but not have {} added as well.
>
> For example, I can get '[' without making it appear an optional
> argument with (TeX-arg-literal "["), but then I get {}.
>
> Is there some solution to this that someone can tell me about?

I'm also not aware of any pre-fabed function in AUCTeX for this.  But
you can easily build your own like this:

--8<---------------cut here---------------start------------->8---
(defun ConTeXt-arg-mandatory-in-brackets (optional &rest args)
  "Parse its arguments but use square brackets when they are inserted."
  (let ((TeX-arg-opening-brace LaTeX-optop)
        (TeX-arg-closing-brace LaTeX-optcl))
    (if (equal (length args) 1)
        (TeX-parse-argument optional (car args))
      (TeX-parse-argument optional args))))
--8<---------------cut here---------------end--------------->8---

This is based on `TeX-arg-free' which is defined as:

--8<---------------cut here---------------start------------->8---
(defun TeX-arg-free (optional &rest args)
  "Parse its arguments but use no braces when they are inserted."
  (let ((TeX-arg-opening-brace "")
        (TeX-arg-closing-brace ""))
    (if (equal (length args) 1)
        (TeX-parse-argument optional (car args))
      (TeX-parse-argument optional args))))
--8<---------------cut here---------------end--------------->8---

HTH.  Best, Arash

Reply via email to