On Sun, Mar 13, 2011 at 5:16 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
> I got these exact keyboard-translate lines from Xah's blog. They don't work
> reliably on Windows. Sometimes after switching back to Emacs from another
> program, and my first input to Emacs is C-j, C-j still registers instead of
> C-x.
Sounds like a bug (even sounds like one that's already been reported but
that we're having trouble tracking down). But I can't find it in the
bug database, so maybe it's something different. So please M-x
report-emacs-bug an include as much info as possible to help us
reproduce the bug.
> How would I use key-translation-map to do the swap?
> (define-key key-translation-map [(control x)] [(control j)])
> (define-key key-translation-map [(control j)] [(control x)])
Yes.
> C-j seems regixter as C-x. But C-x acting like a prefix key, waiting for
> the next input.
I think that's because of function-key-map's remapping of C-x @ S <key>
to S-<key>. If you add (define-key function-key-map [?\C-x] nil), it
might work (it does for me).
These 3 lines seem to do the swapping I want.
(define-key key-translation-map [(control x)] [(control j)])
(define-key key-translation-map [(control j)] [(control x)])
(define-key function-key-map [(control x)] nil)
Hopefully this will work reliably.
Thanks!
Stefan