Emacs, Linux and international keyboard layouts
You can set input method (kudos go to kindahero) by typing
M-x set-input-method RET cyrillic-yawerty RET
or
M-x set-input-method RET cyrillic-jcuken RET
To store it permanently, add
(setq default-input-method "cyrillic-yawerty")
to ~/.emacs config (and use C-\ to switch between keyboard layouts).
different keyboard layout key bindings in emacs
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.
How to make emacs default keys works in non english keyboard layout
When working with Emacs, always use the English layout on the system level, but switch to any Emacs' input-method you like. That way, all the keyboard shortcuts still work, but when typing, you insert characters of a different layout.
Make Emacs ignore system keyboard layout
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.
Arch Linux installation keyboard layout de-latin1 in /etc/vconsole.conf
You can list all available layouts via localectl list-keymaps
. If you wish to have a standard QWERTY layout, you might want to use KEYMAP=us
Have a look at this Wiki page for more information.
Related Topics
Grep String Inside Double Quotes
How to Calculate the Total Size of Certain Files Only, Recursive, in Linux
Grep -Q' Not Exiting with 'Tail -F'
Null Modem Emulator (Com0Com) for Linux
Interrupting Epoll_Wait with a Non-Io Event, No Signals
Sched_Fifo Process with Priority of 99 Gets Preempted
How to Identify Multiple Usb-Serial Adapters Under Ubuntu 10.1
How to Know Whether a Copy-On-Write Page Is an Actual Copy
Are There Some Program Like Com0Com in Linux
Unable to Start Rstudio in Centos Getting Error "Unable to Connect to Service"
How to Open a File in Assembler and Modify It
Writing Memory of the Traced Process
Nasm Linux Assembly Printing Integers
Packet Sniffing Using Raw Sockets in Linux in C
Bash Print Stderr Only, Not Stdout