Emacs 25.1 の IME パッチ

私は普段 Windows 7 の MSYS2 環境で作業しています。

エディターは Emacs を使っていますが、IME を使うためにパッチを当ててい ます。Emacs 25.1 がリリースされたので、そのパッチを https://github.com/K-Arakawa/emacs-ime-patch に置いてみました。

.emacs

(cond ((string= (window-system) "w32")
       (setq default-input-method "W32-IME")
       (setq-default w32-ime-mode-line-state-indicator "[--]")
       (setq w32-ime-mode-line-state-indicator-list '("[--]" "[あ]" "[--]"))
       (w32-ime-initialize)
       (require 'smart-ime)
       ;; Register 指定時に IME を OFF にする
       (with-eval-after-load "register"
         (fset 'saved-read-key (symbol-function 'read-key))
         (defun read-key-with-ime-off (&optional prompt)
           (let ((im current-input-method)
                 (key))
             (deactivate-input-method)
             (setq key (saved-read-key prompt))
             (activate-input-method im)
             key))
         (fset 'saved-register-read-with-preview (symbol-function 'register-read-with-preview))
         (defun register-read-with-preview (prompt)
           "Read and return a register name, possibly showing existing registers.
Prompt with the string PROMPT.  If `register-alist' and
`register-preview-delay' are both non-nil, display a window
listing existing registers after `register-preview-delay' seconds.
If `help-char' (or a member of `help-event-list') is pressed,
display such a window regardless."
           (cl-letf (((symbol-function 'read-key)
                      (symbol-function 'read-key-with-ime-off)))
             (saved-register-read-with-preview prompt))))))

と書いておけば OK です。