Hi,
I've just encountered that the TAB snippet "pl" executed at the very beginning of EACH document REGARDLESS of the set grammar inserts "#!/usr/bin/env perl".
Either the scope setting is wrong
<key>scope</key> <string>L:dyn.caret.begin.document</string>
[What does "L:" mean?]
or the scope parsing is somehow broken.
OSX 10.9.5 - TM 2.0 beta 1
Best, Hans
I can't reproduce this. I put the cursor at the start of my current AsciiDoc document, typed "pl" and tab, and all I got was "pl" and a tab.
m.
On Oct 19, 2014, at 6:24 AM, Hans-Jörg Bibiko bibiko@eva.mpg.de wrote:
Hi,
I've just encountered that the TAB snippet "pl" executed at the very beginning of EACH document REGARDLESS of the set grammar inserts "#!/usr/bin/env perl".
Either the scope setting is wrong
<key>scope</key> <string>L:dyn.caret.begin.document</string>
[What does "L:" mean?]
or the scope parsing is somehow broken.
OSX 10.9.5 - TM 2.0 beta 1
Best, Hans
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
-- matt neuburg, phd = http://www.apeth.net/matt/ pantes anthropoi tou eidenai oregontai phusei Programming iOS 7! http://shop.oreilly.com/product/0636920031017.do iOS 7 Fundamentals! http://shop.oreilly.com/product/0636920032465.do RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
On 19 Oct 2014, at 15:24, Hans-Jörg Bibiko wrote:
I've just encountered that the TAB snippet "pl" executed at the very beginning of EACH document REGARDLESS of the set grammar inserts "#!/usr/bin/env perl".
Either the scope setting is wrong
This is meant as a feature and also works for rb⇥, py⇥, sh⇥, and maybe more.
Ideally TextMate would also switch file type when first line is changed to something that matches the “first line match” of a grammar. That way, if you want to create a new perl script, just ⌘N and enter pl⇥ and you have both the proper shebang and the file type automatically set (giving syntax highlight and an appropriate file name extension when saving).
<key>scope</key> <string>L:dyn.caret.begin.document</string>
[What does "L:" mean?]
L means “left”. The caret is technically between two characters, so we have a scope to the left and right of the caret. By default scope selectors look at what’s right of the caret, but sometimes it’s desired to look to the left instead, or maybe look to both sides, which can be done using B:«selector».
This is mostly when at the begin/end of an element, like string‸ versus ‸string.
In this case we target the “begin of document” attribute scope, which is to the left of the document’s first character. There are similiar attribute scopes for begin/end of line and end of document.
On 19 Oct 2014, at 21:24, Allan Odgaard mailinglist@textmate.org wrote:
On 19 Oct 2014, at 15:24, Hans-Jörg Bibiko wrote:
I've just encountered that the TAB snippet "pl" executed at the very beginning of EACH document REGARDLESS of the set grammar inserts "#!/usr/bin/env perl".
Either the scope setting is wrong
This is meant as a feature and also works for rb⇥, py⇥, sh⇥, and maybe more.
Ideally TextMate would also switch file type when first line is changed to something that matches the “first line match” of a grammar. That way, if you want to create a new perl script, just ⌘N and enter pl⇥ and you have both the proper shebang and the file type automatically set (giving syntax highlight and an appropriate file name extension when saving).
Ok, I see the point of this nice feature, but I wonder why this Perl pl⇥ snippet will be executed and not "my" pl⇥ (since I set the grammar to "my" grammar in beforehand). I thought if you create a tmCommand (or similar), set to a specific grammar source.foo that all keybindings etc. have the priority over "the more general" ones.
<key>scope</key> <string>L:dyn.caret.begin.document</string>
[What does "L:" mean?]
L means “left”.
Ah, thanks for the clarification. Good to know :)
Best, Hans
On 19 Oct 2014, at 21:44, Hans-Jörg Bibiko wrote:
Ok, I see the point of this nice feature, but I wonder why this Perl pl⇥ snippet will be executed and not "my" pl⇥ (since I set the grammar to "my" grammar in beforehand). I thought if you create a tmCommand (or similar), set to a specific grammar source.foo that all keybindings etc. have the priority over "the more general" ones.
The problem is that dynamic scopes (and attribute scopes) are considered more specific than the scopes from the grammar and since the general pl⇥ snippet matches a dynamic scope, it wins over something scoped to a grammar.
In your situation, this definition is undesired, but there are other where it makes sense, and I haven’t yet found a way so that we can have it both ways…