Last active
May 22, 2022 02:22
-
-
Save ghost355/a967417bb7e826e833d4 to your computer and use it in GitHub Desktop.
How to smart switch Russian /English keyboard layout mode when use Emacs and Evil mode (or Spacemacs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Mac OS Edition | |
;; This code helps us to work with Spacemacs (Emacs + Evil mode) in multilanguage mode | |
;; You need to install https://github.com/vovkasm/input-source-switcher | |
;; It's a console utilite to switch input language. | |
;; Pavel Pavlov (c) 2015 | |
;; In other OS you'll have to change name of langages layers and name of Switcher like issw | |
;; In thу Terminal # issw show you namу of the current layout | |
(setq shell-file-name "/bin/bash") | |
(setq lang_source "com.apple.keylayout.US") ;set default var lang_source for issw arg | |
(add-hook 'evil-insert-state-entry-hook ;what we do when enter insert mode | |
(lambda () | |
(shell-command (concat "issw " lang_source)))) ; | |
; | |
(add-hook 'evil-insert-state-exit-hook ;what we do when enter normal mode | |
(lambda () | |
(setq lang_source (shell-command-to-string "issw")) | |
(shell-command "issw com.apple.keylayout.US"))) | |
(setq lang_source "com.apple.keylayout.US") ;set default var lang_source for issw arg | |
(add-hook 'evil-replace-state-entry-hook ;what we do when enter insert mode | |
(lambda () | |
(shell-command (concat "issw " lang_source)))) ; | |
; | |
(add-hook 'evil-replace-state-exit-hook ;what we do when enter normal mode | |
(lambda () | |
(setq lang_source (shell-command-to-string "issw")) | |
(shell-command "issw com.apple.keylayout.US"))) | |
I tried this and it works perfectly.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a problem too - my script didn't work properly. Just try to use another version of Emacs
https://emacsformacosx.com
27-1-1 is working