[txmt-dev] Re: Question about PlugIns

Caleb Land caleb.land at gmail.com
Mon Jan 28 19:41:34 UTC 2013


I have some more information about how the plugin works.

Some background
The Emmet plugin is the new name for the ZenCoding plugin. It gives some utility methods for writing HTML and CSS.

It lets you type a shorthand syntax and then expand it with a keyboard shortcut. It's kinda like a beefed up snippet.

I can type "table>tr*3>td*3" and hit ^E and it will create a table with three rows and three columns.

It works on selections or if the cursor is at the end of the Emmet expression.  

How it works
From what I can tell, when an Emmet expand action is executed, it looks at the carret position/selection and determines if the selection contains a valid expansion expression (or if the text proceeding the carret is a valid expression if there is no selection).

When the plugin is ready to perform the expansion, it tells TM to select the contents of the expansion expression, and calls `insertSnippetWithOptions` to replace the contents it with the expanded contents.

So, in a nutshell it needs to be able to:

* get/set the selection
* get/set the carret position
* get the contents of the editor as a string
* get the type of file being edited
* optionally get the name of the file being edited

I appreciate the help. Fixing this plugin would be a big win for TM2 front end web developers.

-Caleb


On Monday, January 28, 2013 at 11:35 AM, Caleb Land wrote:

> It looks like the plugin needs information about the selection in the editor.
>  
> It needs to be able go get the start position/end position and the contents of the selection
>  
> It also needs the "TM_SCOPE" so it can detect what kind of file is being edited.  
>  
> Thanks for the help.
>  
> -Caleb
>  
>  
> On Sunday, January 27, 2013 at 3:54 AM, Allan Odgaard wrote:
>  
> > On Jan 26, 2013, at 21:43, Caleb Land <caleb.land at gmail.com (mailto:caleb.land at gmail.com)> wrote:
> >  
> > > […] It uses the result to access:
> > >  
> > > TM_LINE_NUMBER
> > > TM_LINE_INDEX
> > >  
> >  
> >  
> > Is all you need the position of the caret?
> >  
> > _______________________________________________
> > textmate-dev mailing list
> > textmate-dev at lists.macromates.com (mailto:textmate-dev at lists.macromates.com)
> > http://lists.macromates.com/listinfo/textmate-dev
> >  
> >  
> >  
>  
>  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate-dev/attachments/20130128/7911129d/attachment.html>


More information about the textmate-dev mailing list