[TxMt] Latex Bundle grammar

Alain Matthes alain.matthes at mac.com
Tue Sep 11 19:43:34 UTC 2007


Le 11 sept. 07 à 19:27, Brad Miller a écrit :

> Alain,
>
> Thanks for the good ideas!
>
> So I think what you are saying is that it would be nice to  
> conditionally include some grammars as a part of the latex grammar  
> depending on which packages you are using.  This would have some  
> very good benefits: 1.  It would keep package grammars like  
> lstlistings from making the plain latex grammar overly long.
> 2.  This might have some speed benefits for editing as well.
> 3.  It would also make it easy for people to incrementally add new  
> scopes to the grammar that are specific to individual packages  
> without having to modify the plain latex grammar.
>
> This is great.  But as far as I know this is not possible in the  
> current version of TM.
>
> Today we have to do things the other way around  For example I  
> would have to make an lstlistings grammar that included latex and  
> tex.  But this is not good at all since it only would allow me to  
> have the specialized grammar for one particular package.
>
> So, until we get to TM 2.0 or later, or someone tells us how to  
> conditionally include grammars, we have to keep adding to the latex  
> grammar for each package that we want to have scoped.
>

yes, you made a correct synthesis of my ideas.

But why conditionally include grammars ??

I'm not a specialist of script, regex etc.... but in a first time
it's possible to build some grammars like

text.tex
text.tex.math
text.tex.beamer
text.tex.listings
text.tex.tikz etc....

And to finish the text.tex.latex by some include like

include = 'text.tex.listings'; ?

Each user can modify the list of the package grammars !


Perhaps I'm wrong ...


About listings, why make a grammar to this package ?

There is a way to turn around the difficulties.

\lstinputlisting[key=value list]{hfile name}

example :

\usepackage{listings}
\lstset{language=C}
...
\begin{document}
\lstinputlisting{main.c}
\end{document}

or you can make that

\lstinputlisting[first=10,last=50]{main.c}

It is the only way for me to use listings because I'm french (I need  
only to
include  latex code but with accents) and it's impossible
to use listings with utf8  actually, so I need to save file with  
latin1 encoding
and to use two encodings latin1 and utf8 is the same file ! (very bad)

I suppose that you need to include java code or python code but there  
are scopes
  to verify the syntax of these languages. So why waste time with a  
difficult grammar and not
  include the sources of codes.

Regards Alain


More information about the textmate mailing list