Re: [code] [textadept] Are you a keyboard junkie?

From: Mitchell <>
Date: Mon, 8 Apr 2013 10:08:00 -0400 (Eastern Daylight Time)

Hi Pete,

On Fri, 5 Apr 2013, Pete Kazmier wrote:

> Here is something for the keyboard junkies out there. I hacked this
> together over the last couple of days. In a nutshell, I've basically
> allowed one to bind functions that take arguments that require user
> input to key bindings. In addition, you can now specify numeric prefixes
> to commands and pass that as an argument to functions. Using my
> bindings, I can do "ctl-u 1 0 ctl-t k", where the "ctl-u 1 0" is how I
> collect the number 10 so it can be passed as an argument to the function
> I have mapped on "ctl-t k", which is buffer.line_delete. An astute
> reader will realize that buffer.line_delete does not take a numeric
> argument to specify how many lines to delete so I have provide a wrapper
> that can be used for that too. All this good stuff is commented below in
> my init.lua file. I would love to hear feedback and I'm hoping that
> others will come up with other special argument types in addition to the
> handful I wrote already (I.NUMBER, I.BUFFER, I.BUFFERN, I,PROMPT).
> Here is a link to the file, I've also embedded it below in this email
> for convenience:

This is a clever use of metatables for stringing together custom key
sequences. I use a simpler[1] version of this for wrapping strings within
the next typed character[2] (such as '*'), but this is much more advanced.
Well done!

> [snip]
> -- This next one does not work. I was hoping I'd be able to use the
> -- select buffer dialog box to kill other buffers, but I realized
> -- that you can't close a non-active buffer, so this does not work
> -- if you are tryng to kill any buffer other than the one you are
> -- currently in. Need to investigate what else could be done.
> x = function() I.wrap(buffer.close, I.BUFFER) end,
> }

You could create a new function that calls `view.goto_buffer()` and then
`buffer:close()` (while storing the previous buffer to go back to). Then
if you want to keep the `buffer.close` syntax, you can assign
`buffer.close_orig, buffer.close = buffer.close, your_buffer_close`. Don't
forget to make this assignment for each new buffer via a `BUFFER_NEW`



You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Mon 08 Apr 2013 - 10:08:00 EDT

This archive was generated by hypermail 2.2.0 : Tue 09 Apr 2013 - 06:49:31 EDT