TextMate and codesearch
Dec 23, 2010 21:17 · 370 words · 2 minute read
The packet is fickle: always I am willing to switch to a new development workflow. Definitely if it’s better. Or even if it’s just different. Lately, I have been exploring use of TextMate. I use to use (and maintain my own version of) wily but given that a a three button mouse is mandatory to efficient use, it is a challenge to use on planes, trains, etc. Other posts will expand on my editor angst — Acme vs Wily and the absence of source highlighting for example. But this is sufficient background for the now.
Anyway, back to TextMate. It has a lovely bundle scheme that permits defining all kinds of interesting new features. I am please to have completed my first new command. It is tiny and needs other components. A small step. But maybe useful. The packet has been working on WebKit. And Google CodeSearch has ever so nicely decided to index WebKit’s source code. So, I made a codesearch command:
#!/usr/local/bin/rc if ( ~ $TM_SELECTED_TEXT ()) { # this is one big URL with a single var injected. open 'http://codesearch.google.com/codesearch?as_q='\ ^$TM_CURRENT_WORD^\ '&btnG=Search+Code&hl=en&vert=chromium&\ filesuggest=&as_lang=&as_filename=&as_class=&\ as_function=&as_case=' } else { # this is one big URL with a single var injected. open 'http://codesearch.google.com/codesearch?as_q='\ ^$TM_SELECTED_TEXT^\ '&btnG=Search+Code&hl=en&vert=chromium&\ filesuggest=&as_lang=&as_filename=&as_class=&\ as_function=&as_case=' }
with input being Selected Text or Scope (Is this right?), bound to ^/. And presto! I can ^/ on a type name and look it up. Extra handy this is in WebKit given the paucity of comments. (They make you weak don’t you know.)
All this material is however merely prelude to the main event. We have a one-directional link here: from TextMate to CodeSearch. What about the other side? That will be more interesting. My general approach will be as follows:
Create textmate URL scheme links in the output of CodeSearch for everything that I could imagine clicking on that would take me back to TextMate. This I can do via a Chrome extension. The details will appear here. Soonish. (And if you follow this blog, you’ll know what kind of precision is associated with this time estimate.)
Use the chrome-duplicate-tab-detector extension to stop tab-itis from expanding for each search. (Or is it feature to have lots?) Maybe it’s a feature.