Emacs, Linux and international keyboard layouts

Is there an easy way to use Emacs key-bindings when you are using a not-English (Russian) keyboard layout?

Whenever an international layout is on, all keystrokes are interpreted literally, M-ф instead of M-a. As a result I can't use commands.

It would also be nice if Linux could interpret non-prefixed and shift-prefixed keys according according to an international layout, while keeping the rest English.

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

Emacs and international keyboard layouts : emacs, Emacs is not able to handle default key bindings for international keyboard layouts. Russian C-ф (Russian ф is the same key as a in English qwerty layout ) is not bound to beginning-of-line . New tool for faster emacs startup (on linux). Vim has a very simple system to join two lines. all you have to do is press the J (uppercase) key inside the line above. In Emacs, instead, you must use the C-^ binding in the lower line. But the Emacs solution may seem a bit more laborious if you use a keyboard with US International Dead Keys layout in MS Windows or GNU/Linux.

Here is an alternative solution that uses the OS language, based on syndikat's answer.

Some key translations are missing, but it should be easy to add them.

;; USAGE:
;; Put in your .emacs:
;; 
;; (translate-keystrokes-ru->en)
;; (add-hook 'text-mode-hook
;;           (lambda () (literal-insert-mode 1)))
;; 
;; Only buffers with literal-insert-mode active will be sensitive to the
;; environment language. Prefixed keybindings will still be usable.

(defun translate-keystrokes-ru->en ()
  "Make emacs output english characters, regardless whether
the OS keyboard is english or russian"
  (flet ((make-key-stroke (prefix char)
           (eval `(kbd ,(if (and (string-match "^C-" prefix)
                                 (string-match "[A-Z]" (string char)))
                            (concat "S-" prefix (string (downcase char)))
                            (concat prefix (string char)))))))
    (let ((case-fold-search nil)
          (keys-pairs (mapcar* 'cons
                               "йцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖ\ЭЯЧСМИТЬБЮ№"
                               "qwertyuiop[]asdfghjkl;'zxcvbnm,.QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>#"))
          (prefixes '(""    "s-"    "M-"    "M-s-"
                      "C-"  "C-s-"  "C-M-"  "C-M-s-")))
      (mapc (lambda (prefix)
              (mapc (lambda (pair)
                      (define-key key-translation-map
                          (make-key-stroke prefix (car pair))
                        (make-key-stroke prefix (cdr pair))))
                    keys-pairs))
            prefixes))))

(defun literal-insert ()
  (interactive)
  (insert-char last-input-event 1))

(define-minor-mode literal-insert-mode
    "Make emacs output characters corresponging to the OS keyboard,
 ignoring the key-translation-map"
  :keymap (let ((new-map (make-sparse-keymap))
                (english-chars "qwertyuiop[]asdfghjkl;'zxcvbnm,.QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>#"))
            (mapc (lambda (char)
                    (define-key new-map (string char)
                      'literal-insert))
                  english-chars)
            new-map))

Emacs, Linux and international keyboard layouts, Is there an easy way to use Emacs key-bindings when you are using a not- English (Russian) keyboard layout? In this article, we will see how we can install emacs in a Linux system and use it for basic text editing. Emacs is also available for graphical window managers for Linux like GNOME; however, we will only cover the 'text based' version here.

Not sure, where did sabof got 150 billion. I ran this code (thanks to Yuri Khan, taken from EmacsWiki):

(loop
 for from across "йцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖ\ЭЯЧСМИТЬБЮ№"
 for to   across "qwertyuiop[]asdfghjkl;'zxcvbnm,.QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>#"
 do
 (eval `(define-key key-translation-map (kbd ,(concat "C-" (string from))) (kbd ,(concat     "C-" (string to)))))
 (eval `(define-key key-translation-map (kbd ,(concat "M-" (string from))) (kbd ,(concat     "M-" (string to))))))

It's only 128 combinations. Unfortunately, combinations with single letters like C-x b don't work. I'm still trying to find a better solution.

Emacs, Linux and international keyboard layouts, Is there an easy way to use Emacs key-bindings when you are using a not- English (Russian) keyboard layout? Whenever an international� Given the huge number of keyboard layouts Ubuntu Linux offers for multiple languages, is there a US international keyboard layout exactly like the windows version? For instance, a layout where I get Ç when I input ' + C.

I use following snippet for Cyrillic keyboard and it works fine for me:

(defun reverse-input-method (input-method)
  "Build the reverse mapping of single letters from INPUT-METHOD."
  (interactive
   (list (read-input-method-name "Use input method (default current): ")))
  (if (and input-method (symbolp input-method))
      (setq input-method (symbol-name input-method)))
  (let ((current current-input-method)
        (modifiers '(nil (control) (meta) (control meta))))
    (when input-method
      (activate-input-method input-method))
    (when (and current-input-method quail-keyboard-layout)
      (dolist (map (cdr (quail-map)))
        (let* ((to (car map))
               (from (quail-get-translation
                      (cadr map) (char-to-string to) 1)))
          (when (and (characterp from) (characterp to))
            (dolist (mod modifiers)
              (define-key local-function-key-map
                (vector (append mod (list from)))
                (vector (append mod (list to)))))))))
    (when input-method
      (activate-input-method current))))

(reverse-input-method 'russian-computer)

Except:

The only issue I know is that recalculation of OrgTable formulas isn't working in Russian layout because it is mapped to C-c-* and * change its location.

source

Keybindings with AltGr, The reason I ask is the following: I use the “US international” keyboard layout (on Linux), which remaps the right Alt key to AltGr (aka Level3 shift), so that I can type � export DISPLAY=:0 export LIBGL_ALWAYS_INDIRECT=1 # OPTIONAL Set the keyboard layout to US setxkbmap -layout us setsid emacs exit This will open Emacs in a new window. By using setsid this is done in a new session and therefore the WSL can be closed after with exit.

If you want to keep using the Russian layout in Emacs (rather than use Emacs's own input methods), the only way I know of for now is to add bindings of the form:

(define-key function-key-map [?\M-ф] [?\M-a])

This will tell Emacs that in case M-ф is not bound, it should try to lookup M-a instead. Sadly, you'll need a lot of these bindings. If someone writes up a patch/package that can automatically provide all these bindings, I'd be happy to include it in Emacs.

Select Input Method - GNU Emacs Manual, How to do this remapping properly depends on your actual keyboard layout. To specify which layout your keyboard has, use the command M-x quail-set- keyboard-� Meanwhile, I only order my personal notebooks with US-international keyboard layouts. In case I have to use a business computer that was ordered with a German QWERTZ keyboard, I usually apply keyboard stickers to turn it into a US-international keyboard layout. Comments. Here is a German email comment from Peter who is mentioning the Neo-layout:

Keyboard Layout (GNU Guix Reference Manual), Keyboard Layout (GNU Guix Reference Manual) The operating system kernel, Linux, will need that so that the console is properly The "US international" layout, which is the US layout plus ;; dead keys to enter accented characters. This is� This might make many emacs . Stack Overflow. Products Emacs, Linux and international keyboard layouts. 1. How to enter C-M-b in Emacs under a windows keyboard? 6.

Join lines in Emacs using US International Dead Keys layout, How to get the Emacs' join-lines function if you use a keyboard with US US International Dead Keys layout in MS Windows or GNU/Linux. Dvorak layout is invented in 1936. Colemak is invented around 2005. Colemak proponents like you to believe that Colemak is the modern better more efficient layout. [see Dvorak Keyboard Layout] [see Ergonomic Keyboard Layouts] Rolling Finger vs Alternating Hands. Dvorak focus on alternating hands. For example, all vowels A O E U I are on the

Dvorak Latin-1 extended keyboard for Linux-Emacs, Both the X keyboard extension (XKB) and Emacs itself get involved in the XKB already has the layouts us(dvorak-intl) "English (Dvorak, international with dead� I decided to use the Emacs 23.1 Cocoa build that by default uses the Mac keyboard’s alt/option key as the meta key. But because I am German and I’m using a German keyboard, of course, it get’s quite tricky to enter parantheses that are needed for programming extensively: { } [ ]

Comments
  • One way is to use English layout while you are on Emacs.. if you want write Russian in emacs change emacs input method by pressing C-\
  • You mean M-x set-input-method, and then C-\ to switch between Russian and English? At least that's what worked for me
  • This means you didn't understand my comment. I've added an improved version as an answer, in case someone needs it
  • It seems you can make <kbd>C-x b</kbd> combinations with something like (loop for from across "йцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖ\ЭЯЧСМИТЬБЮ№" for to across "qwertyuiop[]asdfghjkl;'zxcvbnm,.QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>#" do (global-set-key (kbd (concat "C-x " (string from))) (key-binding (kbd (concat "C-x " (string to))) t)) ) `
  • I did a rough calculation and end up with 150 billion combinations, assuming 4 modifier keys, a 4-long chord, and 40 keys. A on-the-fly translator function might be nicer
  • I've written a snippet that takes care of the bindings. It's half-cooked - it could take maps from mule to provide bindings for all keyboards. It also conflicts with modes that override the self-insert command, such as cua-rectangle.
  • @sabof: whilte the number of combinations needed to cover all cases is large, it's not quite as large as you think because this remapping is applied within key sequences. So the single example I showed will already cover C-x M-ф or M-ф M-ф for example. But yes, 40-keys combined with 4 modifiers gives you 480 bindings and clearly doing it programmatically on-the-fly would be much better.