Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

different keyboard layout key bindings in emacs

Tags:

emacs

I'm using two keyboard layouts - one for my mother-tongue language, and the other is english. Problem is when I switch to my mother-tongue language keyboard layout, and try to perform keybinding commands.

Is there an easy way to tell emacs to treat all commands (C-key,M-key etc) using the default, English-layout bindings?

I've seen this question: Emacs determining keyboard layout in which one answer simulates all keys to their according English-layout keys, but it is mentioned it eats up loading time, and the code is long, unreadable and thus probably error prone to me.

Help would me appreciated.

like image 922
Devon Ville Avatar asked Oct 28 '12 18:10

Devon Ville


2 Answers

Many layout managers allow applications (or even windows) to keep their own layout. Use English layout for Emacs, to write in you mother tongue, switch the input method (C-\).

like image 128
choroba Avatar answered Nov 15 '22 10:11

choroba


If the two layouts use completely different characters, then you can simply let Emacs try "the other character". E.g. if one key is b in US layout but и in the other layout, you can use:

(define-key function-key-map [?и]       [?b])
(define-key function-key-map [?\C-и]    [?\C-b])
(define-key function-key-map [?\M-и]    [?\M-b])
(define-key function-key-map [?\M-\C-и] [?\M-\C-b])

OTOH if the two layout end up swapping some characters, Emacs would really need to know which layout is active in order to know whether or not to remap the key. I don't know enough about keyboard handling to know how to let Emacs tell you which layout is in use currently.

like image 29
Stefan Avatar answered Nov 15 '22 10:11

Stefan