Re: [code] [textadept] I want to contribute

From: Robert Gieseke <rob.g.att.web.de>
Date: Tue, 03 Mar 2015 23:03:58 +0100

Hi,

Am 03/03/15 um 15:10 schrieb Mitchell:
> Hi Chris,
>
> On Mon, 2 Mar 2015, Chris Emerson wrote:
>
>> On Mon, Mar 02, 2015 at 08:56:23AM -0500, Mitchell wrote:
>>> * If you're looking for a big project, here's one: Many text editors
>>> have their own package managers for extensions and modules.
>>> Textadept currently does not, but the LuaRocks project now supports
>>> local repositories in any configurable location. I did some work
>>> looking into this but didn't manage to come up with something (I
>>> don't remember why at the moment). If you manage to do this, you'd
>>> be a rock star :) I can send you the code from my previous attempt
>>> and my notes. This is a very open-ended project with nothing really
>>> clearly defined.
>>
>> I had an idea for this (which I haven't tried, so I'm probably missing some
>> crucial problems). If textadept had a command line option to behave like the
>> lua interpreter (ie load and execute a script instead of running the editor),
>> then installing LuaRocks and telling it that your Lua 5.2 (currently) binary
>> is, say, "textadept --lua-interpreter", that might just about work to install
>> existing rocks (which is useful in itself). Could Textadept extensions just
>> be put into the normal LuaRocks system?
>
> I was thinking of 'require'ing LuaRocks from Textadept's Lua state and
> doing stuff from there. I'm not sure how feasible a "Lua-interpreter mode"
> is. I wouldn't want Textadept extensions in LuaRocks' system, but in the
> standard `~/.textadept/modules` directory.
>

Since Luarocks is mostly Lua this might be possible and has been
discussed before on lua-l[1]. What works right now is just using
Luarocks to install modules into a place where Textadept can find it.

luarocks --tree=$HOME/.textadept/rocks install dkjson

In my init.lua I have to update the package path,

package.path = table.concat({
  package.path,
  -- taking LUAPATH from `luarocks --tree=$HOME/.textadept/rocks path` here,
  '[snip]'
}, ';');

And then I have a JSON module in Textadept:

keys.c1 = function()
  local json = require("dkjson")
  local tbl = {
  animals = { "dog", "cat", "aardvark" },
  instruments = { "violin", "trombone", "theremin" },
  bugs = json.null,
  trees = nil
  }

  local str = json.encode (tbl, { indent = true })
  ui.dialogs.msgbox{text=str}
end

It's also possible to specify the Lua version, e.g. `--lua-version=5.2`.
There might be problems with modules that need 5.1 compatibility since
Textadept has some compat flags disabled.

On OS X Luarocks packages are installed as x86_64 and textadept is i386
so compiled packages like Luasocket don't work but there might be a
workaround for this.

In general, as far as I understand, anyone can upload packages to
https://rocks.moonscript.org/ so this might be a possibility to
distribute Textadept packages.

Cheers,
Robert

[1] http://lua-users.org/lists/lua-l/2013-02/msg00339.html

-- 
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 03 Mar 2015 - 17:03:58 EST

This archive was generated by hypermail 2.2.0 : Wed 04 Mar 2015 - 06:46:24 EST