[TxMt] Lucky Linking Trio

Brett Terpstra brett at circlesixdesign.com
Sun Sep 24 03:47:18 UTC 2006


These are my three variations of the "Lucky Linking" idea, where the command
searches Google with the selected text and returns the "I'm feeling lucky"
result as a link.

I have modified all three commands so that they require no extra support
files, but they do require some standard libraries that I made assumptions
that everyone would have.  If I'm wrong, let me know.

The Get Title from URL variation is just an improvement on iamrice.org's
version.  The regex is a little more flexible, and it returns a link with a
title attribute.

The Google modification incorporates the Get Title command and grabs the
title from the "Lucky Link", using the updated regex, and inserts it as a
title attribute in the link.

The Wikipedia version goes a few steps further and scrapes the pages with a
quick regex to determine if it's a final destination or another search page
(or disambiguation page).  It provides a dropdown menu when there are
multiple results.  It will also detect if there is a redirect and put the
correct link and title into the link while leaving your original text alone.
This should allow you to quickly see if it got off on the wrong track.

I am no good at either programming or regular expressions ;-).  I do my best
to fool people.  But I am eager to learn from my mistakes, so if you do take
the time to look at these, please give me as much feedback as you can.  I'll
lap it up like a puppy.

Cheers!

Brett

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Get Title of URL.tmCommand
Type: application/octet-stream
Size: 1357 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20060923/d47fd0de/attachment.tmCommand>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Lookup Word / Selection on Wikipedia and link.tmCommand
Type: application/octet-stream
Size: 4664 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20060923/d47fd0de/attachment-0001.tmCommand>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Lookup Word / Selection on Google and Link.tmCommand
Type: application/octet-stream
Size: 1741 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20060923/d47fd0de/attachment-0002.tmCommand>


More information about the textmate mailing list