[TxMt] Latex Bundle grammar

Brad Miller bmiller at luther.edu
Tue Sep 11 21:18:37 UTC 2007


On 9/11/07, Alain Matthes <alain.matthes at mac.com> wrote:
>
>
> But why conditionally include grammars ??


Because then you could base which grammars are included based on which
packages are included in each document.  Suppose that this actually worked:

{    name = 'meta.package.latex';
            match = '^\usepackage{lstlisting}'
            patterns = ( { include = 'text.tex.latex.lstlisting'; } );
        },

or even better
{    name = 'meta.package.latex';
            match = '^\usepackage{(lstlisting)}'
            patterns = ( { include = 'text.tex.latex.$1'; } );
        },

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 !


I think this is where we differ.  I don't think we want each user to be
modifying the latex grammar to decide which packages to include. For one
thing it will be different for each different project.  So, I"m either going
to end up including everything all the time, or I'm going to drive myself
crazy modifying the latex grammar every time I work on a different writing
project.  Plus most users don't want to go anywhere near editing the grammar
file!


>
> About listings, why make a grammar to this package ?


Because lstlistings is the best package I've found for including source
code, and since I'm writing CS textbooks, I do that a lot.  If you can
recommend a better one I would be happy to look at it!  But really, most of
the grammar for the package is only concerned with then command and then
including the grammar for the particular source code that is inside the
lstlistings environment.


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}

I know  about this feature of lstlisting but I like to have the code right
there to look at as I'm writing.  I guess its a writing style issue but I
tried your method for a while and I did not like it at all.



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 don't understand about the problem with utf8.  My latex source files are
all encoded as utf8 documents and I don't have any problem with lstlistings.


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.


Again, the lstlisting grammar includes source.java or source.python.  In
fact by my calculations the number of lines in the latex grammar dedicated
to the listing package is only 47 lines out of 494 total.



Regards Alain
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20070911/f82a7e12/attachment.html>


More information about the textmate mailing list