[TxMt] Re: Using „First Line Match” in grammars
Stefan Daschek
stefan at daschek.net
Fri Oct 24 22:04:45 UTC 2014
Am 24.10.14 um 09:24 schrieb Allan Odgaard:
> On 23 Oct 2014, at 11:42, Stefan Daschek wrote:
>
>> When and how is the “First Line Match” setting of language grammars
>> considered?
>
> It is used after checking for explicit bindings (from tm properties).
> The explicit bindings are recorded in the Global.tmProperties when the
> user change language for an open file.
Makes sense! So the precendence is like this?
1. Use explicit binding from Global.tmProperties.
2. If none found, use first line match.
3. If none found, use file types (extension).
If more than one bundle claims a file type by extension, is it “longest
match wins“? (The RSpec bundle uses `_spec.rb` which seems to take
precedence over Ruby's `rb` even for empty files.) And what happens if
two bundles claim the exact same extension? (Both Ruby and Rails claim
`rb`, and apparently the Ruby bundle “wins”.)
> With a *.rb file open you should be able to use ⌃⌘T, switch to settings,
> and then enter ‘filetype’ to find your explicit binding for *.rb → Rails
> in Global.tmProperties (although clicking Edit doesn’t take you to the
> proper line yet).
Great, this has already proven itself very helpful. Thanks!
> Making it work for RSpec files, assuming these still follow the
> file_spec.rb naming convention, you would need to change the setting to:
>
> [ *.rb~*_spec.rb ]
> fileType = source.ruby.rails
Cool – didn't know that it's possible to combine wildcards like this!
More information about the textmate
mailing list