K
K
kablag2014-08-08 11:14:22
emacs
kablag, 2014-08-08 11:14:22

What is the correct way to use keyboard shortcuts in Russian layout in Emacs?

I am using GNU Emacs 24 on ubuntu 14.04.
Input sources in the system: English (USA) and Russian (typewriter).
To use hotkeys in Emacs when switching the system layout to Russian (typewriter), I use the following code:

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

(defadvice read-passwd (around my-read-passwd act)
  (let ((local-function-key-map nil))
    ad-do-it))

 (reverse-input-method 'russian-typewriter)

At the same time, when the system layout is English (USA), when pressing hot keys, some letters are mixed up. For example, instead of C-, C-6 is pressed.
How to fix it? Or do I need to use another method to use hotkeys in the Russian layout?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
thenno, 2014-08-11
@thenno

In fact, it's more correct to switch the layout in emacs itself via C-\ and not to fence crutches :)

M
Maxim Dunayevsky, 2021-02-18
@dunmaksim

(set-language-environment 'Russian)
Details here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question