27 Mar 2009 01:20
I want to contribute!
Marius Andersen <rezonatix3 <at> yahoo.no>
2009-03-27 00:20:44 GMT
2009-03-27 00:20:44 GMT
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.
(Continue reading)
RSS Feed