genovese/emacs-utils — Issue #5: win-switch-custom-set-keys can override bindings
Author: markhepburn
Created: 2011-12-09 03:52:52+00:00
State: open

win-switch-custom-set-keys is very order-sensitive in the way it removes old bindings for a command. For example, starting with the default ijkl setup, say you did the following:

```lisp
(win-switch-set-keys '("k") 'up)
(win-switch-set-keys '("j") 'down)
```

The first statement will look up the previous binding for 'up, find that it's "i", and (effectively) removes it before binding "k" to 'up.

The second then looks up the assumed previous binding for 'down, finds "k", and rebinds it to 'win-switch-exit-and-redo, which clobbers the just-set binding of 'up.

I think a safer approach is to use 'substitute-key-definition against the function itself, not the key. I have a patch for this, but since I can't see how to attach it here I'll have to attach it in a follow-up I think, sorry.. (I just imported the main file into my repository rather than cloning, so I can't send a pull-request unless you'd prefer it that way)