[TxMt] Linking Commands

Allan Odgaard throw-away-1 at macromates.com
Sun Mar 4 17:05:19 UTC 2007


On 4. Mar 2007, at 14:15, Brett Terpstra wrote:

> have you had any time to take a look at the linking commands that  
> will allow for easy insertion of Markdown, HTML, etc?  I've been  
> playing with the Yahoo-Ruby interface and have some new commands  
> that allow for searching/linking in different areas (news, videos,  
> urls) and finding related suggestions.  I don't want to bother  
> sharing it with my same old HTML tag insertion if there's a linking  
> library of some sort on the way...

I gave this a quick shot today, attached is a HyperLink Creator bundle.

There is one command (a dummy Feeling Lucky) which reads the  
TM_LINK_FORMAT environment variable, and uses the value of this  
variable as an ERb template, feeding ERb with a title and url  
variable, when expanding it.

I have then added a setting for this variable for both HTML and  
Markdown, and thus, depending on which language you are in, the  
Feeling Lucky command will insert proper code (I also made a fallback  
which causes an error message to be inserted).

Since the templates are ERb they can be made smart, e.g. about  
whether or not the link has a title / explanation (info attribute). I  
made the output of the Feeling Lucky command insert as snippet, so  
the format templates should expect to have full snippet syntax (which  
is why they call e_sn for the url/title).

We may need to refine this slightly, but I think this is overall a  
good solution for separating logic and view.

A minor problem is that it is not clear which scope the command(s)  
should be active in. I.e. should we just hardcode a scope selecting  
the languages we know have the TM_LINK_FORMAT set, or scope it  
globally? Or maybe we don’t actually need an activation for these  
commands (beyond menu and ⌃⌘T), so this won’t be a problem…


-------------- next part --------------
A non-text attachment was scrubbed...
Name: HyperLink Creator.zip
Type: application/zip
Size: 3799 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20070304/9005259e/attachment.zip>


More information about the textmate mailing list