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

From: Peter Kazmier <>
Date: Mon, 8 Apr 2013 20:07:50 -0500

Hi Mitchell,

On Apr 8, 2013, at 9:08 AM, Mitchell <> wrote:

> [snip]
>> 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!

Thanks! I feel like I actually understand metatables now after that hacking session!

>> [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` event.

Great! This worked out well. I wrote a helper like my ntimes() that can be used with I.wrap:

-- Takes a function to be applied to a buffer that is selected when
-- the returned function is called. This allows us to use this with
-- I.wrap.
function with_buffer(f)
  return function(b)
    local orig = buffer

keys['ct'] = {
  x = function() I.wrap(with_buffer(buffer.close), I.BUFFERN) end,

What I really like about I.wrap is that I don't need to rely on you to provide interactive versions of the many functions available. Instead, all the interactive functions can be created by wrapping them and then replacing the arguments with values that were selected interactively!

I'd really like to make an I.COMMAND_ENTRY argument that can be used with I.wrap so that I can prompt the user for input from the command entry line instead of the heavy weight gtdialog input box (my I.PROMPT). I need help with a simple function that returns whatever was input in the command entry box. I can't wrap my head around the current examples of where you use command entry as the flow of control leaves the function that invokes it. So in my case, I would need a function that I.wrap can execute (I.COMMAND_ENTRY[2]) and get a simple return with a value. But I can't seem to wrap my head around how to do this because the flow of control leaves the function that sends the user to the command entry. Do you have any ideas or suggestions?


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 - 21:07:50 EDT

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