Skip to content

Instantly share code, notes, and snippets.

@tsuu32
Last active November 3, 2023 07:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsuu32/2a5cadd5e72debabad684e72bb424856 to your computer and use it in GitHub Desktop.
Save tsuu32/2a5cadd5e72debabad684e72bb424856 to your computer and use it in GitHub Desktop.
;;; w32-ime-mode.el --- Yes another initializer for W32-IME
;;; Commentary:
;; Add following code to your init file instead of (w32-ime-initialize):
;;
;; (require 'w32-ime-mode)
;; (w32-ime-mode)
;;; Code:
(require 'w32-ime)
(define-minor-mode w32-ime-mode
"Use Win32 System IME."
:global t
(if (and (or (eq system-type 'windows-nt) (eq system-type 'cygwin))
(eq window-system 'w32)
(fboundp 'ime-get-mode))
(cond
(w32-ime-mode
(setq default-input-method "W32-IME")
(setq w32-ime-input-method-title "W32") ; override W32-IME input method title
(add-hook 'select-window-functions
#'w32-ime-select-window-hook)
(add-hook 'set-selected-window-buffer-functions
#'w32-ime-set-selected-window-buffer-hook))
(t
(setq default-input-method nil)
(setq w32-ime-input-method-title nil)
(remove-hook 'select-window-functions
#'w32-ime-select-window-hook)
(remove-hook 'set-selected-window-buffer-functions
#'w32-ime-set-selected-window-buffer-hook)))
(when (called-interactively-p 'any)
(message "`w32-ime-mode' only works in Windows GUI"))
(setq w32-ime-mode nil)))
(provide 'w32-ime-mode)
;;; w32-ime.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment