[TxMt] ScreenCast! Balance JR Command
thomas Aylott
thomas.42 at gmail.com
Mon Feb 6 14:09:34 UTC 2006
Howdy.
The whole porpoise behind the javascript bundles is to add better
code folding and nested bracket scopes.
I use the JavaScript bracketed proto language which calls my modified
version of the Prototype language (Prototype and Scriptaculous Mod)
which calls the Javascript language.
The practical upshot of all that is that I can give each level of a
nest of brackets a slightly darker background color (As seen in the
javascript section of the screecast using the iLife 05 2 theme) and I
can keep the curly brackets on the same line as the function or
whatever and still be able to fold the section.
Using the Prototype JS language from encytemedia adds some nice
scopes to prototype specific words. Also, the MochiKit (js) language
does the same thing for MochiKit DOM function names and I have the
MochiKit HELP command to look up their functions in a TextMate HTML
window from the API description.
The normal JS language uses:
foldingStartMarker = '^.*\bfunction\s*(\w+\s*)?\([^\)]*\)(\s*\{[^\}]
*)?\s*$';
foldingStopMarker = '^\s*\}';
My version uses:
foldingStartMarker = '(^.*{[^}]*$|^.*\([^\)]*$|^.*/\*(?!.*\*/).*$)';
foldingStopMarker = '(^\s*\}|^\s*\)|^(?!.*/\*).*\*/)';
You can really see the difference on files like the MochiKit 1.2 :
PACKED VERSION where nothing is tabbed properly, because of being
compressed. Personally, I find having the opening curly bracket on
the next line after the function to be truly horrible and unreadable,
but that's just me. ;)
The slightly darker nested brackets are surprisingly addictive. I did
it once, just to see what it would look like & if I could even do it,
but now I just can't work in any deeply nested language without it.
I used to have to think hard and pay attention to what level of the
nest i'm in, but now I never don't know. The normal balance command
is also totally invaluable (if only it worked on nested html/xml
tags, too).
It's not uncommon to see scopes like "source.js.bracketed.prototype
meta.round-brackets.round meta.round-brackets.curly meta.round-
brackets.curly meta.round-brackets.curly meta.round-brackets.curly
meta.round-brackets.curly meta.round-brackets.round" using my version
where the official js version just lists it as "source.js".
I know I should totally change the scope name from meta.round-
brackets.round & …curly. But i'd have to change every bundle that
uses it and every theme that uses it and I just haven't gotten around
(or curly ;) ) to doing it yet.
Anybody have any suggestions on how I should name that? Should it
even start with 'meta'?
Now that I have all this, I secretly wish more languages used curly
brackets.
Thanks. (boy did I honk on for a while, huh)
PS: Yes, porpoise != purpose, that was merely for comedic effect. ;)
I've been trying to adapt the nested scopes thing to ruby's do…end,
if…end, etc… But then I lose the scope for the words themselves.
On Feb 6, 2006, at 4:55 AM, Andreas Wahlin wrote:
> It would also be nice with some explanations for your JavaScript
> bundles and so on on that page :)
> And I also like the x51-something bundle a lot!
>
> Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20060206/158a46b5/attachment.html>
More information about the textmate
mailing list