[code] [textadept] Dynamic keychains

From: Chris Emerson <c-ta.att.mail.nosreme.org>
Date: Fri, 29 Nov 2013 12:37:41 +0000

Hi Mitchell,

I've been making use of keychains a lot for my vi bindings, rather than
keeping state on what keys have been pressed somewhere (with more risk of
it getting out of sync).

One awkward case is where I want to allow an arbitrary numeric prefix to
a command (eg "1 2 3 d w" to delete 123 words).

My current solution involves the bindings for digits returning a new proxy
table wrapping the main binding table which keeps track of the count, and
modifies the result. It works, but it's not for the faint of heart!

What would be nice is if the end key handler function had access to the
keychain (which is currently a local in core/keys). What do you think
about passing the key chain to plain functions in the bindings? It would
also be handy for related bindings (eg binding all letters to functions
which do something with that letter), rather than wrapping each in a closure.

Alternatively, using the table form you could define a special parameter
which is replaced by the key chain (just like run_command swaps in the
current buffer/view).

Regards,

Chris

-- 
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 Fri 29 Nov 2013 - 07:37:41 EST

This archive was generated by hypermail 2.2.0 : Sat 30 Nov 2013 - 06:44:47 EST