Ragnar Lodbrog
Ragnar Lodbrog

Reputation: 21

How to set a specific input method to emacs specific major-mode?

I use few languages and I need to set up specific input method to specific major-mode in Emacs.

I mean, configuration to "auto change" input method for specific major-mode.

Is there some way to do this? Thank you!

Upvotes: 1

Views: 556

Answers (1)

phils
phils

Reputation: 73246

You can use the MODE-hook for each MODE in question to either set the default-input-method (toggled with C-\) for buffers in that mode:

(add-hook 'emacs-lisp-mode-hook 'my-emacs-lisp-mode-hook)
(defun my-emacs-lisp-mode-hook ()
  "Custom behaviours for `emacs-lisp-mode'."
  (setq-local default-input-method "latin-1-prefix"))

or to go ahead and activate the input method automatically:

(add-hook 'emacs-lisp-mode-hook 'my-emacs-lisp-mode-hook)
(defun my-emacs-lisp-mode-hook ()
  "Custom behaviours for `emacs-lisp-mode'."
  (activate-input-method "latin-1-prefix"))

See also How to set a specific input method to a file.

Upvotes: 1

Related Questions