Skip to content

Instantly share code, notes, and snippets.

@ghost355
Last active May 22, 2022 02:22
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ghost355/a967417bb7e826e833d4 to your computer and use it in GitHub Desktop.
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)
;; 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")))
@ghost355
Copy link
Author

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

@yeonsh
Copy link

yeonsh commented May 22, 2022

I tried this and it works perfectly.

https://github.com/laishulu/emacs-smart-input-source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment