Re: Lua Rocks

From: mitchell <mforal.n....at.gmail.com>
Date: Fri, 11 Jun 2010 07:01:56 -0700 (PDT)

Rob,

On Fri, Jun 11, 2010 at 4:25 AM, Robert <ro....at.web.de> wrote:
> On Wed, Jun 9, 2010 at 5:29 AM, mitchell <mforal.n....at.gmail.com> wrote:
>>
>> I think the wiki is a fine place for it to do. I'm not sure how I feel
>> about hardcoding a 'modules/common/' directory.
>>
>> Mitchell
>>
>
> How about the following:
> First (independently of the loading of user extensions or modules):
> I think it would reduce possible confusion, if the package path would
> be modified like this
>
> -- init.lua
> local paths = {
> _USERHOME..'/core/?.lua',
> _USERHOME..'/modules/?.lua',
> _USERHOME..'/modules/?/init.lua',
> _HOME..'/modules/?.lua',
> _HOME..'/modules/?/init.lua',
> package.path
> }
>
> -- core/init.lua
> package.path = _USERHOME..'/core/?.lua;'.._HOME..'/core/?.lua;'..package.path
>
> Currently one could have e.g. "key_commands.lua" and "events.lua" in
> .textadept/ and then another "key_commands.lua" in .textadept/ext/.
> With "core" on the path it would be more similar to the main directory
> layout.

Why do you need custom core files? The core files are like they sound;
they should be in ta's directory. They are the minimum set of files
necessary to run ta. The user shouldn't be able to easily (and
potentially problematically) modify the core files. Instead manual
modification or symlinking should be necessary. At least the user
knows exactly what is going on.

>
> Second,
> two other ideas for the original question of simplifying adding
> modules/functions etc.:
>
> Automatically loading all *.lua files in ~/.textadept (like currently
> key_commands.lua and snippets.lua), a possible key_commands.lua to be
> loaded last (to make sure all functions are defined).

I don't like this. It goes against ta's principle of customization. I
have a lot of .lua files in my ~/.textadept for testing purposes that
I load manually in my init.lua. Having a blanket load would be very
undesirable. I admit it would be easier for most users to do this, but
I want to retain the sense of control ta gives users with regards to
features. You could argue that adding files to init.lua is the same
amount of hassle as renaming or moving files from ~/.textadept, but I
feel the former is more desirable.

>
> -- In the "if not textadept.user_dofile('init.lua')" block
> for file in lfs.dir(_USERHOME) do
> if file:find('%.lua$') and file ~= 'init.lua' and file ~=
> 'key_commands.lua' then
> textadept.user_dofile(file)
> end
> end
> textadept.user_dofile('key_commands.lua')
>
> Then I could put a file "load_common.lua" in .textadept:
>
> local lfs = require 'lfs'
> local common_modules = _USERHOME..'/modules/common/'
> if lfs.attributes(common_modules) then
> for filename in lfs.dir(common_modules) do
> if filename:find('%.lua$') then
> require('common.'..filename:match('^(.+)%.lua$'))
> end
> end
> end
>
> That way it would be very simple to add things like the supplemental
> comments from the wiki by providing a file with the instruction to
> drop this into .textadept (instead of having to create a personal
> init.lua).

It appears my concept of an init.lua is more complicated than it
should be. I can certainly see how this would be very useful for the
dragging and dropping of extension scripts, but it does not fit into
my vision of ta's extensibility. Perhaps a new system needs to be
created. Maybe we should start a wiki page on ideas? I do have an
extreme aversion to blanket loads of files though. Bad things can
easily happen.

I think you're on to something; it's worth looking into for a
solution.

Regards,
Mitchell

>
> The other and probably simplest possibility would be to always load
> the modules in the "if not textadept.user_dofile('init.lua')" block.
> With the changes in the package path it has become easy to load
> customized core modules - the only reason for a personal init.lua now
> is to not load a module (like menu.lua), but this could probably be
> worked around by loading an "empty" menu.lua?
> Then the user init.lua would be loaded, so people could put every
> customization in it or make it load other files.
> Instructions could then simply read as "Put this in your init.lua" and
> it will work without having to make sure that the core modules are
> correctly required.
>
> Robert
>
> --
> You received this message because you are subscribed to the Google Groups "textadept" group.
> To post to this group, send email to textadept.at.googlegroups.com.
> To unsubscribe from this group, send email to textadept+unsubscribe.at.googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/textadept?hl=en.
>
Received on Fri 11 Jun 2010 - 10:01:56 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:45:53 EST