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

From: Russell Dickenson <>
Date: Mon, 6 May 2013 08:43:01 +1000


Thanks for your feedback. When I opted to create 'post_init.lua' in
~/.textadept/modules/xml/ I thought that this module would be run *after*
the standard XML Textadept module, therefore achieving the result of having
an XML-specific snippet.

Note that I did this as a small step toward understand how Textadept can be
customised. My previous attempts have been flawed because I have simply
been cutting-and-pasting, without trying to understand how things worked.

To answer your first question, no, I didn't have an
~/.textadept/modules/xml/init.lua file. The 'post_init.lua' file is to
*only* custom file, aside from those automatically created by Textadept. I
didn't want this cluttered by anything else, so that troubleshooting was

I renamed my post_init.lua file init.lua but after restarting Textadept and
opening an XML file I got the following error message:

/home/rdickens/.textadept/modules/xml/init.lua:1: attempt to index field
'xml' (a nil value)

Does this mean I need to 'include' the standard XML module? My attempt with
the 'post_init.lua' file was as the documentation states, to have some
custom code run in addition to the standard code.

On 3 May 2013 16:10, Robert <> wrote:

> Hi Russell,
> On Fri, May 3, 2013 at 2:52 AM, Russell Dickenson
> <> 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
> To change subscription settings, send an e-mail to
> To unsubscribe, send an e-mail to

You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Sun 05 May 2013 - 18:43:01 EDT

This archive was generated by hypermail 2.2.0 : Mon 06 May 2013 - 06:34:05 EDT