On Sat, Sep 22 2012 (10:22), Patrick Brinich-Langlois <[email protected]> wrote: [14 lines snipped]
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)
The problem is that you pass a list of symbols (e.g. (list 'evil-normal-state-map ...)) instead of a list of keymaps. Use (list evil-normal-state-map ...) to build such a list. Here's another approach, as recursion is not a fine choice for elisp: (defun set-in-all-evil-states (key def &optional maps) (unless maps (setq maps (list evil-normal-state-map evil-visual-state-map evil-insert-state-map evil-emacs-state-map))) (while maps (define-key (pop maps) key def))) ;; usage (set-in-all-evil-states "i" 'evil-forward-char) ;; or (set-in-all-evil-states "i" 'evil-forward-char (list evil-normal-state-map evil-visual-state-map)) HTH, Michael