Re: [code] I need help adding a language-specific snippet

From: Robert <rob.g.att.web.de>
Date: Fri, 3 May 2013 08:10:09 +0200

Hi Russell,

On Fri, May 3, 2013 at 2:52 AM, Russell Dickenson
<russelldickenson.att.gmail.com> wrote:
> In this case I wanted to better understand how to customise the handling of
> a specific file type. I read the following text and thought, "OK, I'll try
> adding a snippet that is specific to XML."
>
> "Similarly, you can use post_init.lua to change the module’s compile and run
> commands, load more Adeptsense tags, and add additional key bindings and
> snippets (instead of in ~/.textadept/init.lua)."
>
> I created in ~/.textadept/modules/xml/ a file named "post_init.lua", with
> the contents:
>
> snippets.xml['hi'] = 'hello there'
>
> I then open an existing XML file, which is properly recognised by TA as of
> type "xml" and I type the snippet "hi", then press [Tab]. The snippet is not
> converted to the text "hello there".
>
> Where am I going wrong here?

do you still have a file '.textadept/modules/xml/init.lua'? The
post_init.lua files are loaded after a language module in your
'.textadept/modules/' or in Textadepts 'modules' directory (Lua, Cpp
or one of the official modules) has been found.

So, if you want to extend Brian's module (to not have to update your
stuff if there is an update to Brian's module) your snippet should
work, if you want to start from scratch you need to start your own
language module in '.textadept/modules/xml'.

If you just need a few snippets you can place your code in 'init.lua'
as well, as it is just adding to the global snippet table.

Cheers,
Robert

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Fri 03 May 2013 - 02:10:09 EDT

This archive was generated by hypermail 2.2.0 : Fri 03 May 2013 - 06:30:24 EDT