Emacs,Linux和国际键盘布局

sab*_*bof 18 linux keyboard emacs internationalization

当您使用非英语(俄语)键盘布局时,是否有一种简单的方法可以使用Emacs键绑定?

每当打开国际布局时,所有按键都按字面解释,M-ф代替Ma.结果我不能使用命令.

如果Linux可以根据国际布局解释非前缀和移位前缀键,同时保持其余的英语,这也是很好的.

bar*_*ddu 13

您可以通过键入来设置输入法(kudos转到kindahero)

M-x set-input-method RET cyrillic-yawerty RET
Run Code Online (Sandbox Code Playgroud)

要么

M-x set-input-method RET cyrillic-jcuken RET
Run Code Online (Sandbox Code Playgroud)

要永久存储,请添加

(setq default-input-method "cyrillic-yawerty")
Run Code Online (Sandbox Code Playgroud)

〜/ .emacs配置(并用于C-\在键盘布局之间切换).


sab*_*bof 5

以下是基于syndikat答案的使用OS语言的替代解决方案.

缺少一些关键翻译,但应该很容易添加它们.

;; 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))
Run Code Online (Sandbox Code Playgroud)