[SVN] scope and naming elements

Jeroen van der Ham jeroen at je-ju.net
Mon May 16 09:45:37 UTC 2005


On 16-05-2005 07:54, Eric Hsu wrote:
> Well, if I set my theme to style comment.line, and the Perl.tmbundle 
> has a comment.line entry, then shouldn't a parsed item in a perl file 
> be colored and parsed correctly? What technical purpose does the  final
> .perl serve? Or do we read scope from it (that would be weird...)?

Consider using those comments in a LaTeX source environment (i.e. you
write a paper and include some source code with perl comment lines in it)

Then you may want to colour the perl part differently than the latex
comments.

But besides that, it's always useful to have more tags in there to
distinguish things than less...

> 
> Basically, I don't understand how in the new scheme the language 
> element name hierarchy interacts with scope. I doubly don't  understand
> how nested languages act. I don't have strong feelings  about it... I
> just want to be cooperative.

That's funny actually, because if you nest languages, than the scope
almost doubles ;)

Seriously, consider the LaTeX example above, that has a scope of
text.latex. So everything in the LaTeX file will always have a scope of
"text.latex ...."
Now if we use the (theoretical) example from above, then we do
\begin{listing} in the latex source and everything after that has a scope
of "text.latex source.perl " This is because there is a rule defined in
the latex syntax for \begin{listing} ... \end{listing}[1].

So the scope is basically a stack showing which matches are piled up on
top of eachother.

A bit more difficult is the way function declarations are matched,
consider for example a Python function declaration:

def aFunctionName(arg1, arg2):

Then that whole line is matched as "source.python
declaration.function.py", but we used grouping in there as well and gave
different groups different names as well. So the "def" has a scope of
"source.python declaration.function.py keyword.built-in.py"

But the best way to find out how it really works in your own files is by
using the show scope command, which is in the language definition bundle,
 default shortcut key: ctrl-shift-T

Jeroen.

-- 
            <http://www.je-ju.net/~jeroen/blog/>



More information about the textmate-dev mailing list