onecrayon / tea-for-espresso

An Espresso Sugar containing Textmate-style Text Editor Actions
http://onecrayon.com/tea/
58 stars 3 forks source link

Find a way to access zen abbreviations using tab completions #50

Open onecrayon opened 15 years ago

onecrayon commented 15 years ago

Will likely need a script to parse the zen dictionary and output action XML for each abbreviation to be run as part of setup.py.

Need to look into whether I can access previous word as part of a tab trigger.

Original discussion thread: http://wiki.macrabbit.com/forums/viewreply/2901/

ttscoff commented 15 years ago

Don't know if it helps, but the way the TextMate bundle for Zen Coding is set up, I can have whatever I want as a trailing tab trigger and it's ignored when the line is processed. I'm just using a comma (,) as the trigger now, so I end a zen coding string with a comma and hit tab…

onecrayon commented 15 years ago

Thanks, I'll take a look at the Textmate implementation! Having a comma-tab (or similar) tab completion that then parses the word before the comma is an interesting idea.

3zzy commented 14 years ago

Checking to see if there's any progress on this functionality? I've been using zen-coding tab-triggers on Textmate for months now but miss the auto-complete. My demo will expire shortly, would love to see this working ASAP. Many thanks!

onecrayon commented 14 years ago

Unfortunately, I'm not going to be able to get this done in the next few days. If you'd like to try the comma-delimited tab trigger, though, here's how to set it up:

  1. Enable custom user actions in Actions->TEA->Preferences
  2. Create this XML file:

    ~/Library/Application Support/Espresso/Support/TextActions/Actions.xml

With these contents:

<?xml version="1.0"?>
<action-recipes>
    <action id="com.onecrayon.TextActions.ExpandTabTrigger" category="actions.text.HTML/tea.insertion">
        <class>TEAforEspresso</class>
        <title>Expand Tab Trigger</title>
        <text-trigger>,</text-trigger>
        <setup>
            <action>word_to_snippet</action>
            <options>
                <dict>
                    <key>default</key>
                    <string>&lt;$SELECTED_TEXT>$1&lt;/$WORD>$0</string>

                    <key>extra_characters</key>
                    <string>_-#.>+*:$!@</string>

                    <key>mode</key>
                    <string>zen</string>

                    <key>undo_name</key>
                    <string>Expand Tab Trigger</string>
                </dict>
            </options>
        </setup>
    </action>
</action-recipes>

Relaunch Espresso twice and you'll be able to type any zen coding snippet followed by comma+tab and it'll expand just like if you'd hit control-comma.

I'd still like to get zen-coding's abbreviations as full tab-triggers (no comma needed), so I'll let you know if/when that makes it into the main TEA plugin.