[TxMt] regular expression error in texMate.py

Brad Miller bonelake at gmail.com
Sat Nov 10 14:08:18 UTC 2007


On Nov 9, 2007, at 10:42 PM, Fernando Diaz wrote:

> I'm sure why these should override user-specified engines but the  
> following packages are checked for when using texMate.py,
>
>   latexIndicators = ['pstricks' , 'xyling' , 'pst-asr' , 'OTtablx' ,  
> 'epsfig' ]
>   xelatexIndicators = ['xunicode', 'fontspec']
>
> Unfortunately, the regular expression that detects packages is
>
> 	'([^%]|^)\\usepackage(\[[\w, \-]+\])?\{([\w\-]+)\}'
>
> which detects commented packages including anything (eg, spaces)  
> after the '%'.  Seems like the following may make more sense
>
> 	'(^[^%]*)\\usepackage(\[[\w, \-]+\])?\{([\w\-]+)\}'
>

Thanks,  I thought I had fixed that at some point.

However, your suggestion does not quite work either because I'm doing  
the matching inside a re.findall  where I've read the entire file into  
a single string.  In that case the only instance of ^ is at the very  
beginning of the file.  So substituting \n for ^ in your suggestion  
works.  I've also got to make the [^%]* non greedy.   I think you may  
also have been working with a slightly out of date version of texMate  
since I had just recently modified this regular expression to  
correctly detect \usepackage{x,y}  and the , was missing in the third  
capture group.  Here's what I ended up with that appears to work.   
I'll commit this today sometime.

r'(\n[^%]*?)\\usepackage(\[[\w, \-]+\])?\{([\w,\-]+)\}'


Brad

> ---------------------
> Fernando Diaz
> Department of Computer Science
> University of Massachusetts
> Amherst, MA 01003
> ---------------------
> tel: (413) 545-3059
> fax: (413) 545-1789
> ---------------------
> email: fdiaz at cs.umass.edu
> home: http://ciir.cs.umass.edu/~fdiaz
>
>
>
>
>
> ______________________________________________________________________
> 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




More information about the textmate mailing list