Re: [code] textadept indent to correct level

From: Joseph McDonald <joe.att.vpop.net>
Date: Sun, 08 Jun 2014 17:12:41 -0700

Thanks Robert!

With your help, I'm getting closer.
I put my init.lua here:
https://gist.github.com/anonymous/5f346676a88447bba8a6

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.

thanks,
-joe

On 06/08/2014 01:55 PM, Mitchell wrote:
> Hi Joseph,
>
> On Sun, 8 Jun 2014, Joseph McDonald wrote:
>
>> On 06/08/2014 01:28 AM, Robert Gieseke wrote:
>>
>>> Surely possible, but as far as I know nobody has written a functionality
>>> like this for Textadept yet and Emacs needs rules for indenting in major
>>> modes etc. I think
>>
>> OK, I will look into it. If anyone has any pointers, I'm all ears.
>
> I'll think of something later, but I have time to reply to your other
> questions now.
>
>>>> 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)
>
>> Now I'm trying to get a few more of my emacs keys in place, I have:
>>
>> keys['cx'] = {
>> u = buffer.undo,
>> cc = quit,
>> cf = io.open_file,
>> cs = buffer.save,
>> cw = buffer.save_as,
>> }
>>
>> ctrl-x u works fine as undo.
>> ctrl-x ctrl-c works fine.
>>
>> ctrl-x ctrl-f works just fine. although I would like to bind it to
>> textredux file picker. i have hijack mode on, not sure what else i need
>> to do.
>>
>> ctrl-x ctrl-s gives "invalid sequence" in the message area
>> ctrl-x ctrl-w gives "invalid sequence" in the message area
>>
>> any idea why?
>
> `buffer.save` and `buffer.save_as` do not exist. Use `io.save_file` and
> `io.save_file_as` instead. (*modules/textadept/keys.lua* contains pretty
> much all API functions assignable to keys.)
>
>> also, i'd like to have a key stroke "c " that will start selection mode,
>> so that all navigation changes the range of the selection (in emacs this
>> is called "set-mark"). Is such a thing possible in textadept?
>
> This feature exists in the terminal version of Textadept by default, but
> not the GUI version; you'll have to enable it yourself. Search in
> *modules/textadept/keys.lua* for 'c^' and 'c]'.
>
>> also , is it possible to use the "esc" key in a sequence?
>> for instance, hitting esc then hitting "w" to copy selection, or hit
>> esc, then hit "u" to uppercase the string under the cursor.
>
> Yes, redefine `keys.CLEAR`[1].
>
>> 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.
>
> Cheers,
> Mitchell
>
> [1]: http://foicica.com/textadept/api/keys.html#CLEAR

-- 
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 Sun 08 Jun 2014 - 20:12:41 EDT

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