Triggering actions through snippet activation


#1

My current understanding is that snippets are simple text expanders. I wonder if it is possible/useful to allow snippets to be installed along with packages and allow them to trigger actions from them.

This would allow snippets to behave much more intelligently by leveraging javascript and the whole editor api.

Alternatively one may allow packages actions to be triggered by the tab key. I played a bit with the editor trying to build a package that activated when a dash was followed by a tab. With the current implementation associating - tab to a key binding forces the user to hit - twice when the action is not needed. So this is not a viable solution.

Motivating example: in TM2 I wrote a simple script to expand - into a number of dashes. The number, the position, and other subtleties depended on the context (e.g., 30- expanded into 30 dashes, if there was any other text before it the snippet expanded above AND below the text, it dealt properly with comments, etc.).

It appears to me that nothing similar could be supported in Atom using the exact same key binding (i.e., a tab after a dash). Am I wrong?