[TxMt] invoking a snippet from a snippet

Ed Singleton singletoned at gmail.com
Tue Nov 14 13:55:17 UTC 2006


On 14/11/06, Allan Odgaard <throw-away-1 at macromates.com> wrote:
> On 13. Nov 2006, at 15:04, Ed Singleton wrote:
>
> > I'd also really like to be able to reference tab-stops from the first
> > snippet in the second snippet.
>
> How would that work?

Well, using a (grossly oversimplified) use case of a html form.  Let's
say you have a form snippet and lots of field snippets.

Sometimes you want to prepend the id of the form to the id of the fields:

<form id="my_form">
 <input id="my_form_field_1">
...

You would activate the form snippet, fill various tab stops then come
to put in a field.  Activate that snippet, which would automatically
prepend the id of the form to the id of the field.  When you reach
tabstop $0 of the field snippet, it then carries on with the tabstops
from the form snippet.

I was assuming you would have to use named tab stops rather than
numbered ones (${foo} rather than $1) or maybe there would be a syntax
for saying something like ${parent.1}.

I guess really, as python is my main language, I'm thinking in terms
of python's scoping and namespaces, so that you can use variables with
the same name as those in a higher scope without any problems, but if
you haven't named one in the current scope, it access the one from a
higher scope.

A way to 'fake' it would be just to allow tabstops to create temporary
variables that existed for the length of the snippet (and were
accessible to sub-snippets).  Something like ${1>$MY_FORM_ID}

Hope this makes at least some sense.

Ed



More information about the textmate mailing list