DRY way of remapping a key in all relevant modes

Barry OReilly gundaetiapo at gmail.com
Mon Sep 24 16:59:09 CEST 2012


> I want "i" mapped to evil-forward-char in
normal, visual, visual block, dired, etc. modes. I want to avoid this:

If you want the key binding in normal and visual, you can add it to the
evil-motion-state-map, which is active in both of those two.  In terms of
how to integrate it with Dired's own key bindings, I wrote up a guide on
that kind of thing a few weeks ago:

http://emacswiki.org/emacs/Evil#toc7



On Sat, Sep 22, 2012 at 4:22 AM, Patrick Brinich-Langlois <
pbrinichlanglois at gmail.com> wrote:

> Hi,
>
> I've been using Vim with extensive remappings designed for the Colemak
> keyboard
> layout (http://colemak.com/pub/vim/colemak.vim). I'm trying to recreate
> the Vim
> mappings in Emacs with Evil. What's a good way of remapping a key in all
> relevant contexts? For example, I want "i" mapped to evil-forward-char in
> normal, visual, visual block, dired, etc. modes. I want to avoid this:
>
> (define-key evil-normal-state-map "i" 'evil-forward-char)
> (define-key
> evil-visual-state-map "i" 'evil-forward-char)
> (define-key
> whatever-corresponds-to-dired-map "i" 'evil-forward-char)
>
> I tried to write some Elisp to do this, but it doesn't work (Wrong type
> argument):
>
> (defun remap-all (char action states)
> (if states (progn (define-key (car states) char action)
> (remap-all char action (cdr states)))))
> (setq states '(evil-normal-state-map evil-visual-state-map))
> (remap-all "i" 'evil-forward-char states)
>
> Thanks, Patrick
>
>
> _______________________________________________
> implementations-list mailing list
> implementations-list at lists.ourproject.org
> https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ourproject.org/pipermail/implementations-list/attachments/20120924/6881f198/attachment.htm 


More information about the implementations-list mailing list