[TxMt] Re: Best approach to add new Scoping rules to grammar

Jacob Rus jacobolus at gmail.com
Mon Feb 12 05:54:04 UTC 2007


Steve Lianoglou <lists at ...> writes:
> I was wondering what the best approach to enable this functionality  
> would be:
> 
> I use reStructuredText as the format of my doc strings in my python  
> files, and so I'd like to enable the reStructuredText snippets,  
> macros, etc. to fire in my python """ ... """ strings.
> 
> The scope of these strings in the Python files are:
>      string.quoted.double.block.python
> 
> Should I just add this scope to all of the commands in the  
> reStructuredText bundle, so all of the scopes for those commands  
> would be changed to:
>      text.restructuredtext, string.quoted.double.block.python
> 
> Or should I change the Python grammar to somehow set those two scopes  
> for the """ ... """ string matching pattern (I'm not sure if you can  
> do that, though).

At the moment, the best way is probably to just edit the python grammar, adding
the text.restructuredtext scope to the strings.  Then you'll also get niceties
like syntax highlighting for reST inside your python strings, etc.

This is far from ideal though, and Allan's scope injection system for textmate 2
should provide a much more elegant method.

* * *

Incidentally, are any other python users bothered by the decision to use reST as
the de facto format for docstrings?  reST really clashes with python's clean
aesthetic for me.

-Jacob




More information about the textmate mailing list