auctex-devel
[Top][All Lists]

## Re: [AUCTeX-devel] Mandatory arguments in TeX/LaTeX and font locking

 From: David Kastrup Subject: Re: [AUCTeX-devel] Mandatory arguments in TeX/LaTeX and font locking Date: Mon, 01 May 2006 21:55:58 +0200 User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Ralf Angeli <address@hidden> writes:

> The font locking code in the multiline-font-lock branch currently
> marks stuff like
> \newcommand\foo{\bar}
> as erroneous because the syntax of \newcommand is specified as
> "*{}[][]{}" (meaning there is a starred version of the command and the
> macro expects a mandatory argument followed by to optional arguments
> followed by a mandatory argument) and the first mandatory argument is
> not braced in the example.
>
> Are braces generally not necessary if only a single macro is
> concerned?  That means for font locking, can we treat the forms
> \newcommand{\foo}{\bar}
> \newcommand{\foo}\bar
> \newcommand\foo{\bar}
> \newcommand\foo\bar
> as being equivalent and correct?

Correct?  No.  Happens to work though, but more by accident than by
design.

\def needs a braced replacement text (I would have expected
\newcommand not to scan the replacement text as a macro argument but
leave this to \def which is not a macro but a primitive).  But since
\newcommand has not been defined as I would have expected, indeed the
latter version works.

The difference between {\foo} and \foo gets ignored all the time: we
need to deal with it.  Switching \bar and {\bar} is almost always the
result of a mistake rather than on purpose, in contrast.

Still, the manual only recommends the braced versions, and in both
instances leaving the braces off happens to work, even though this is
used only for \foo in practice.

--
David Kastrup, Kriemhildstr. 15, 44793 Bochum



reply via email to