[implementations-list] vimpulse-modal.el --- modal key bindings
The :map, :imap and :vmap commands of Vim let one make two key mappings starting with the same sequence of characters without one overwriting the other. For example: :imap aa foo :imap aaa bar When Vim has read "aa" in Insert mode, it will wait for another character to decide whether to insert "foo" or "bar". If the user types "a", "bar" is inserted; if another letter, "foo" plus that letter. Compare with the analogous use of Emacs' `global-set-key' function: (global-set-key "aa" 'foo) (global-set-key "aaa" 'bar) Here, the first binding is simply overwritten by the more specific second. The end result is that "aaa" is bound to `bar', while any other sequence starting with "aa" is not bound to anything. The attached code provides a set of Vim-like or "modal" functions for making new keybindings "on top of" previous bindings. They are `vimpulse-map', `vimpulse-imap' and `vimpulse-vmap', which mimic Vim's commands, and `vimpulse-define-key', a generic function for specifying the keymap. To load it, issue (require 'vimpulse-modal) Then, for example, the key sequences "cae" and "dae" may be bound in vi (command) mode using `vimpulse-map': (vimpulse-map "cae" 'vimpulse-change-a-sexp) (vimpulse-map "dae" 'vimpulse-delete-a-sexp) This will execute `vimpulse-change-a-sexp' when typing "cae" in vi mode, while retaining keys like "cw" for "change word" or "cas" for "change a sentence". Just for demonstration purposes, `vimpulse-change-a-sexp' and `vimpulse-delete-a-sexp' are indeed real text object commands, defined and bound as shown at the end of the file. They act on Lisp S-expressions. I am not suggesting they be made part of vimpulse.el, just making a point about extensibility. Try it! And please comment. :) Vegard Øye _________________________________________________________________ Windows Live™ Mail. Flere kontoer på ett sted. http://download.live.com/wlmail
Seems the attachment didn't make it through. I've uploaded the code here: http://hekta.org/~vegardoy/vimpulse-modal.el _________________________________________________________________ Få nye Windows Live™ Messenger. http://download.live.com/messenger
On Sun, Dec 6, 2009 at 2:53 PM, Vegard Øye <[email protected]> wrote:
Seems the attachment didn't make it through. I've uploaded the code here:
Thank you very much. Please test on XEmacs, and also on Emacs 22 if possible. Then please submit this patch as a new issue in the bug tracker with [PATCH] in the summary line. Reply and tell us you have done so. Then wait and see what Alessandro decides to do about it. Do you agree that later on, if and when Vimpulse gets merged into Emacs, you will sign and send in the FSF copyright assignment form? Cheers, -Jason -- Jason Spiro: software/web developer, packager, trainer, IT consultant. I support Linux, UNIX, Windows, and more. Contact me to discuss your needs. +1 (416) 992-3445 / www.jspiro.com
From: [email protected] Date: Tue, 8 Dec 2009 00:54:27 -0500
On Sun, Dec 6, 2009 at 2:53 PM, Vegard Øye <[email protected]> wrote:
Thank you very much. Please test on XEmacs, and also on Emacs 22 if possible.
vimpulse-modal.el works fine with GNU Emacs 22.3. It does not work with XEmacs, as XEmacs lacks default key bindings (the ability to interpret the Lisp symbol `t' in a key sequence as a wildcard).
Then please submit this patch as a new issue in the bug tracker with [PATCH] in the summary line.
Done: http://my-trac.assembla.com/vimpulse/ticket/14
Do you agree that later on, if and when Vimpulse gets merged into Emacs, you will sign and send in the FSF copyright assignment form?
I'd be happy to. What do I do? Vegard Øye _________________________________________________________________ Få nye Windows Live™ Messenger. http://download.live.com/messenger
On Tue, Dec 8, 2009 at 12:35 PM, Vegard Øye <[email protected]> wrote:
Do you agree that later on, if and when Vimpulse gets merged into Emacs, you will sign and send in the FSF copyright assignment form?
I'd be happy to. What do I do?
You don't have to do anything until merge time; but it would be appreciated if you would send your phone number and home snail mail address to me and Alessandro by private mail. We won't use it until we need to (probably at merge time).
participants (2)
-
Jason Spiro -
Vegard Øye