Another unproductive day at the office yields more of my usual tricks.
I was writing a blog post and realized that I often want to link to an article I've written myself. This tends to be a good practice, even if just to keep new visitors delving a little deeper into your site. But none of the current linking tools in TextMate were especially good at handling this. So I started problem solving.
Solution 1: Lookup Word/Selection on blog and link. This command was my first idea. It's just a modification of the google lucky linking command that takes your selection, lets you choose which blog from your endpoints and then runs a google search with a site:your.blog.com in the search string. So it's limited to results from your own site, and links to the first result returned.
Solution 2: That wasn't effective enough. Posts aren't always on Google if they're too old or too new and there was no control over which post was chosen. So I modified the Fetch Recent Posts command to insert a link to the chosen post. If you run it without any input it will ask you for the text of the link.
Solution 3: That wasn't complicated enough. This last solution is for Wordpress users only, I'm afraid, but it's a doozy. The plugin included here is a heavily modified version of the Related Posts plugin. It runs a FULLTEXT search on your posts with your selected text and returns relevant posts in an array. The whole thing is an XMLRPC hook. No hacking required. I finally figured out how to do this today, so I'm going to modify my Ultimate Tag Warrior hack to be a plugin as well. I'll get to that later. There's a command with this called "Link to Related Posts" that will query the database and present the related posts in a dropdown.