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

From: Russell Dickenson <russelldickenson.att.gmail.com>
Date: Wed, 8 May 2013 07:02:41 +1000

Mitchell,

OK - I am confused again. :(

In your latest email message you say that the use of post_init.lua is
custom modules which either supplement or replace functionality defined in
Textadept's own modules. You also make it clear that you should not create
an init.lua *and* an post_init.lua. But earlier in this thread you said :

<quote>
Sure. When you want to customize the behavior for specific languages, you
would normally create a language specific module in your
*~/.textadept/modules/[lang]/* folder. Such a module needs to have an
*init.lua* file (this is standard Lua practice) that is run when Textadept
loads the module. Even if that directory exists, Textadept will not
recognize it as a module unless it has an *init.lua* in it. Only when such
a module is detected does Textadept then run a *post_init.lua* file. In
your case, no XML module was detected so your *post_init.lua* file was
never run.
</quote>

So how can a post_init.lua file be loaded automatically by Textadept if
there is no init.lua in the same directory?

On 8 May 2013 06:37, Mitchell <m.att.foicica.com> wrote:

> Russell,
>
>
> On Wed, 8 May 2013, Russell Dickenson wrote:
>
> Mitchell,
>>
>> Ah, thankyou for explaining the role of "init.lua". I should have pointed
>> out at the start that I had started from a clean, fresh installation of
>> Textadept and so had no customisation alrready in place. I *do* intend
>> making use of an XML tag auto-closure script/module but I am taking baby
>> steps at the moment. The aim of enabling XML-specific has been to
>> understand a little better how Textadept works, rather than my previous
>> "cut-and-paste" approach.
>>
>> Can you give me a sample use case for a "post_init.lua" file? In the wiki
>> an example is given of language-specific snippets, the task I took as my
>> "Textadept 101" test. I can't understand why anyone would create an
>> init.lua and post_init.lua file.
>>
>
> Consider this use case:
>
> Textadept comes with a Lua language-specific module with predefined
> snippets. However, you want to add your own snippets to those predefined
> ones. Moreover, you want to take advantage of the existing Lua module's
> tools like Adeptsense and auto-"end" completion. You could copy the Lua
> module into your *~/.textadept/modules/* directory and add your custom
> snippets. However, each time Textadept is released, you will have to keep
> track of any module changes and update your copy -- a tedious and
> error-prone process. Enter *post_init.lua*. If you create a
> *~/.textadept/modules/lua/**post_init.lua* file with your custom snippet,
> you can have your cake and eat it too: the default Lua language-specific
> module will be loaded as well as your snippets from *post_init.lua* :)
>
> Note: under normal circumstances, nobody should be creating an *init.lua*
> and a *post_init.lua*. The latter is to take advantage of existing
> functionality. The former is for creating non-existant functionality.
>
>
> Cheers,
> Mitchell
> --
> 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.
>
>

-- 
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 Tue 07 May 2013 - 17:02:41 EDT

This archive was generated by hypermail 2.2.0 : Wed 08 May 2013 - 06:53:25 EDT