[implementations-list] I want to contribute!
Marius Andersen
rezonatix3 at yahoo.no
Thu Mar 26 23:53:02 CET 2009
Where to start?
Someone at EmacsWiki mentioned Vim's "text objects", such as `diw' (delete inner word), `vip' (select inner paragraph) and `ciB' (change inner block). E.g., one can place the cursor inside a pair of parentheses,
if(VAR == FALSE) { ...
and type `cib' to delete their contents:
if() { ...
As a rough attempt to get similar behavior in Emacs, I recorded a keyboard macro and bound it to `di(':
(define-key viper-vi-global-user-map "di(" "%v%ldi")
Unfortunately, this overwrites all other `d' bindings! C-h k reveals that the first letter, `d', is bound to `viper-command-argument' in `viper-vi-basic-map'. That is a generic function, bound to `c' and `y' as well, which calls the 100-lines function `viper-prefix-arg-com' to read the next keystrokes manually (with C routine `read-char') and take appropriate action.
So to define new `d' commands, it seems we are stuck with modifying (perhaps even redefining :) this very long function. Indeed, to quote from viper.el (line 284):
Some of the code that is inherited from VIP-3.5 is rather
convoluted. Instead of viper-command-argument, keymaps should bind
the actual commands. E.g., "dw" should be bound to a generic
command viper-delete that will delete things based on the value of
last-command-char. This would greatly simplify the logic and the
code.
Currently, I've added an entry to the cond form beginning at line 1300 in viper-cmd.el (where `viper-prefix-arg-com' is defined), to associate some simple behavior to `di' (whose cons cell would be '(?i . ?d)). There should be a better way, or perhaps a a larger rewrite is necessary to do things more elegantly. Any thoughts?
By the way, there's a small discussion page for vimpulse at http://www.emacswiki.org/emacs/vimpulse. It lists a few bugs/requests which should be addressed. (viper.el also contains a buglist.)
_________________________________________________________
Alt i ett. Få Yahoo! Mail med adressekartotek, kalender og
notisblokk. http://no.mail.yahoo.com
More information about the implementations-list
mailing list