Re: Lua Rocks

From: Robert <ro....at.web.de>
Date: Fri, 14 May 2010 12:34:47 +0200

On Fri, May 14, 2010 at 10:37 AM, Jay <robert.jay.go....at.gmail.com> wrote:
> Yeah, you're probably right this should work as well, and it's
> easier :)
>
> Using lfs to get all the files makes things makes things easier than
> having to add requires each time. And modules/common does seem like a
> good candidate for this

The snippets I posted are basically the ones used for generating the
lexer list in mime_types.lua.So there it works very well.

I'm not sure if it would be good (as I proposed) to mix modules and
files that basically add to tables like "keys" or "snippets", maybe
having a place for them would be better. "userfiles", "dofiles"...?
Alternatively, maybe any .lua file in ./textadept could be run trough
user_dofile. Currently there is init.lua, "session"and, if you have
one of those, mime_types.conf, "theme", snippets.lua and
key_commands.lua.
Then, you would only need an init.lua if you don't want to load a
module (like menu) and this would not change the current behaviour
with the loading of ~/.textadept/snippets.lua and
~/.textadept/key_commands.lua.
So in ta's init.lua after loading the core extension modules

local lfs = require 'lfs'
for f in lfs.dir(_USERHOME..'/modules/common/') do
  if f:find('%.lua$') then
    require('common.'..f:match('^(.+)%.lua$'))
  end
end

for f in lfs.dir(_USERHOME) do
  if f:find('%.lua$') and f ~= 'init.lua' then
    textadept.user_dofile(f)
  end
end

That way user key_commands would get loaded after the functions have
been defined in modules/common. I attached a patch file, if anyone
would like to try this out. I don't know maybe there are unwanted side
effects. The ~/.textadept directory is on the package path as well,
I'm not sure if that could be a problem, probably only if you put a
file called textadept.lua there.

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 14 May 2010 - 06:34:47 EDT

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