help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: elisp question:keyboard-translate with hyper fail?


From: Le Wang
Subject: Re: elisp question:keyboard-translate with hyper fail?
Date: Sat, 12 Mar 2011 12:51:56 +0800

On Sat, Mar 12, 2011 at 10:54 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> ;; Swap “Ctrl+x” and “Ctrl+t”, so it's easier to type on Dvorak layout
> (keyboard-translate ?\C-t ?\C-x)
> (keyboard-translate ?\C-x ?\C-t)

There are 32 Ctrl+letter combinations which are characters, and the
above two are among them.  These are exceptional special cases due
to history.  My general recommendation is to not use keyboard-translate
but key-translation-map or function-key-map, which work on arbitrary
key sequences rather only on single-char events.

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.

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)])

C-j seems regixter as C-x.  But C-x acting like a prefix key, waiting for the next input.
 

       Stefan




--
Le

reply via email to

[Prev in Thread] Current Thread [Next in Thread]