Evil-mode defining ex commands & redefining whole line commands (eg. dd)

Frank Fischer frank-fischer at shadow-soft.de
Sun Sep 14 10:25:08 CEST 2014


Am 14.09.2014 um 00:17 schrieb Russell Dunphy:
> Hi, new to Emacs (Evil-mode persuading me that it’s worth attempting the switch). Have a few questions.
> 
> I’m trying to get adhoc key mappings working as they would in vim.. So for example if I open a new Clojure file I might want to quickly set up a mapping to run it. In vim this would be something like:
> 
> :map ,t :!lein exec %<CR>
> 
> Is there a way to implement the `map` ex command in evil-mode to make creating arbitrary, temporary mappings like this possible and easy?

Then the desired command is more or less the same as in Vim:

(define-key evil-normal-state-local-map ",t" ":!ls\C-j")

You can also enter this command at the ex command line.

However, the ex command line in Evil does not interpret the '%'. But, of
course, you can define your own 'map' command (which you might want to
do anyway to save some typing ;))

> Second question relates to trying to get evil-mode to play nicely with paredit. I’m using `evil-paredit-mode` which makes most things work, but whole line commands such as `dd` don’t seem to work, and I can’t work out how to rebind them. I’ve tried the following:
> 
> (evil-define-key 'normal evil-paredit-mode-map (kbd “dd”)
>   (lambda () (move-beginning-of-line)
>              (evil-paredit-delete-line))
> 
> But I get the error “key sequence dd starts with non-prefix key d”.

In Emacs it is generally *not* possible to have, e.g., both "ab" and
"abc" bound to some command: as soon as some key sequence is complete
the corresponding command is executed. The error is raised because "d"
is bound to the command `evil-delete`. There is not easy work around,
sorry (maybe you can redefine `evil-delete`, but it will require some work).

Frank




More information about the implementations-list mailing list