Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Emacs ignore system keyboard layout

Tags:

emacs

keyboard

When typing in Emacs I use its internal keyboard layout switch.

Sometimes I switch system keyboard layout, when I work with other applications.

If both Emacs' internal and system layouts are not English they interfere and it is impossible to work. For example, I have two ways to type some letter but no way to type comma character.

I want to make Emacs ignore system keyboard layout. Is it possible?

EDIT:
My OS is Linux Mint 10 (64bit)
I use Emacs 24

like image 706
Maksim Zholudev Avatar asked Feb 28 '12 11:02

Maksim Zholudev


1 Answers

Can you tell what keyboard layouts you use in your OS and what input methods you use in Emacs? Currently there's not enough information in your post. My problem was, for example, that i used Colemak and Russian-typewriter as OS layouts and Russian-typewriter as a secondary Emacs input method. Combination Colemak(OS)-Russian(Emacs) messed up my input, because Emacs' input method is the mapping of English character, received from OS, to some Russian character, and all input methods in Emacs are based on mapping from QWERTY. For example, what should have been "йцукен" was printed as "йцазпо". I solved it by running the following code:

(require 'quail)

(quail-define-package
 "colemak-russian" "Russian" "ru" nil
 "Russian-typewriter keyboard layout assuming that your default
keyboard layout is Colemak"
 nil t t t t nil nil nil nil nil t)

(quail-define-rules
 ("1" ?№) ("2" ?-) ("3" ?/) ("4" ?\") ("5" ?:) ("6" ?,) ("7" ?.) ("8" ?_) ("9" ??) 
 ("0" ?%) ("-" ?!) ("=" ?\;) ("q" ?й) ("w" ?ц) ("f" ?у) ("p" ?к) ("g" ?е) ("j" ?н)("l" ?г) 
 ("u" ?ш) ("y" ?щ) (";" ?з) ("[" ?х) ("]" ?ъ) ("\\" ?\)) ("a" ?ф) ("r" ?ы) ("s" ?в) 
 ("t" ?а) ("d" ?п) ("h" ?р) ("n" ?о) ("e" ?л) ("i" ?д) ("o" ?ж) ("'" ?э) ("z" ?я) ("x" ?ч) 
 ("c" ?с) ("v" ?м) ("b" ?и) ("k" ?т) ("m" ?ь) ("," ?б) ("." ?ю) ("/" ?ё) ("~" ?+) ("!" ?1) 
 ("@" ?2) ("#" ?3) ("$" ?4) ("%" ?5) ("^" ?6) ("&" ?7) ("*" ?8) ("\(" ?9) ("\)" ?0) ("_" ?=) 
 ("+" ?\\) ("Q" ?Й) ("W" ?Ц) ("F" ?У) ("P" ?К) ("G" ?Е) ("J" ?Н) ("L" ?Г) ("U" ?Ш) ("Y" ?Щ) 
 (":" ?З) ("{" ?Х) ("}" ?Ъ) ("|"?\() ("A" ?Ф) ("R" ?Ы) ("S" ?В) ("T" ?А) ("D" ?П) ("H" ?Р) 
 ("N" ?О) ("E" ?Л) ("I" ?Д) ("O" ?Ж) ("\"" ?Э) ("Z" ?Я) ("V" ?Ч) ("X" ?С) ("C" ?М) ("B" ?И) 
 ("K" ?Т) ("M"?Ь) ("<" ?Б) (">" ?Ю) ("?" ?Ё))

and then used colemak-russian instead of russian-typewriter. You can change associated pairs with the corresponding to your layouts.

EDIT: Of course, this is not the most correct solution. As Maksim noted, characters common to both languages are translated even when shouldn't. For example, i set system layout to Colemak and Emacs input method to "colemak-russian" - then i can't use commas, which become "б".

To make Emacs ignore system layout, you can integrate it with third-party software like xxkb, SCIM or IBus. As you speak Russian, you may try this tutorial.

I personally use a hacky workaround to translate Russian characters inside key combos and ignore Emacs input methods altogether.

like image 78
Mirzhan Irkegulov Avatar answered Sep 20 '22 19:09

Mirzhan Irkegulov