Re: [code] textadept indent to correct level

From: Robert Gieseke <rob.g.att.web.de>
Date: Mon, 09 Jun 2014 11:30:23 +0200

Hi Joe,

> quick question, how do I bind a key to a number such as 1 or 2 or 3?
> i.e.:
>
> keys['cx'] = {
> r = buffer.reload,
> u = buffer.undo,
> s = buffer.save,
> h = view_splith, -- how to make this "2" in addition to 'h'?
> v = view_splitv, -- how to make this a "3" in addition to v?
> }
> i'd like: ctrl-x 1 to unsplit, ctrl-x 2 to split h, and ctrl-x 3 to
> split vertical.

keys['cx'] could be written as keys.cx, since it's a valid Lua
identifier, for numbers you need
   ['2'] = view_splith

> On 06/08/2014 01:55 PM, Mitchell wrote:
>> On Sun, 8 Jun 2014, Joseph McDonald wrote:
>>> On 06/08/2014 01:28 AM, Robert Gieseke wrote:
>>>>> also, how do I bind a key to "reset" to reload my init.lua and all
>>>>> modules?
>>>>
>>>> E.g. for 'F9', in your 'init.lua':
>>>>
>>>> keys.f9 = reset
>>>
>>> perfect! thanks! it would be neat if saving any file in the
>>> ~/.textadept directory invoked reset automagically.
>>
>> Something like the following should work:
>>
>> events.connect(events.FILE_AFTER_SAVE, function(filename)
>> if filename:find('[/\\]%.textadept[/\\]') then reset() end
>> end)

I have

-- Save and reset Lua state: `F9`
keys['f9'] = function()
   io.save_file()
   reset()
end

since I save quite often and probably in a 'broken' state.

>>> one last thing: how to alter the path that textadept looks to when
>>> "require" is called? It would be nice if it worked for things that were
>>> installed with luarocks system. So we could install a package with
>>> luarocks and it is then accessible from within textadept without any
>>> fiddling.
>>
>> Change Textadept's `package.path` and `package.cpath` as you normally
>> would for Lua scripts. Textadept's *init.lua* has an example.

Re your gist,
I'm not sure what exactly luarocks.loader does, but adding the path like
you did and then directly requiring modules installed via Luarocks works
for me

To assign special shortcuts to Textredux functions you can use something
like:

events.connect(events.INITIALIZED, function()
   local textredux = require 'textredux'
   keys.cr = textredux.buffer_list.show
   keys.ao = textredux.fs.open_file
end)

Have you seen textadept-emacs[1]? It's a year old so maybe out of date
in some ways but it might give you some pointers.

Cheers,
Robert

[1] https://github.com/pkazmier/textadept-emacs

-- 
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 Mon 09 Jun 2014 - 05:30:23 EDT

This archive was generated by hypermail 2.2.0 : Mon 09 Jun 2014 - 06:30:24 EDT