[TxMt] Re: formal definition of scope selector syntax?

Allan Odgaard mailinglist at textmate.org
Sun Jun 29 11:06:17 UTC 2008


On 27 Jun 2008, at 00:40, Matt Neuburg wrote:

> [...] My last question would then be how all of that
> fits in with what it says in section 13.5 in the online help about  
> ranking
> selectors. I see how one can use those rules to rank two selectors  
> [...]
>
> But how on earth is one to make sense of the concept "the element  
> deepest
> down" when a selector is of the form
>
> a - b | c & d, e - f | g & h
>
> ?? [...]

In practice a numeric score is calculated for a scope selector match.

The score will be 1.0 for full overlap between scope and scope  
selector, 0.0 for no overlap (i.e. empty scope selector), and below  
zero for “negative overlap” (i.e. the scope selector has elements not  
part of the scope). The values between 0.0 and 1.0 are calculated  
corresponding to the rules given in 13.5 (done by effectively  
converting each fragment of the scope to a fraction and have all those  
numbers form a harmonic serie and then add the fractions that  
correspond to fragments matched by the scope selector).

With a numeric score for each scope selector match it is trivial to  
calculate the score of a compound expression. E.g.: score(a | b) =  
max(score(a), score(b)).




More information about the textmate mailing list