Setting default-input-method
In the Customize interface (M-x customize
or “Options” → “Customize Emacs” → “Top-level Cutomization Group”), navigate to “Environment” → “I18n” → “MULE”. Set the “Default Input Method”: choose “String” in the value menu, and set the string to polish-slash
. Use the “State” button to set the value for the current session or to save it.
You can also reach this Customize setting M-x customize-variable
or through the menu “Options” → “Customize Emacs” → “Specific Option”, then entering default-input-method
.
Alternatively, set the default-input-method
variable in your .emacs
:
(setq default-input-method "polish-slash")
Once this is done, polish-slash
will be the default input method. However, by default, no input method is active (which is different, internally, from some kind of “none” or “pass-through” input method). The default input method is the one that gets activated by typing C-\
(toggle-input-method
).
Activating the input method by default
If you want the input method to be turned on by default, you need an additional step. I can't find a high-level way to do it. One low-level way is to add the following lines to your init file:
(defvar use-default-input-method t)
(make-variable-buffer-local 'use-default-input-method)
(defun activate-default-input-method ()
(interactive)
(if use-default-input-method
(activate-input-method default-input-method)
(inactivate-input-method)))
(add-hook 'after-change-major-mode-hook 'activate-default-input-method)
(add-hook 'minibuffer-setup-hook 'activate-default-input-method)
(defun inactivate-default-input-method ()
(setq use-default-input-method nil))
(add-hook 'c-mode-hook 'inactivate-default-input-method)
The variable use-default-input-method
and the function inactivate-default-input-method
provide a way to turn off the input method (it may be annoying e.g. in programming modes). If you want to turn off the default method in some modes, you register the function inactivate-default-input-method
in that mode's startup hook, as in the example above for C mode and derived modes (C++, Java, etc.).
The code above systematically turns on the default input method in the minibuffer (comment out that line to have it off by default). Smarter code might use the same input method or lack thereof as the buffer that was previously active, or might choose an input method depending on what the minibuffer is prompted for (e.g. used for search strings but not for file names), but I declare this beyond the scope of this answer.
If you prefer to whitelist modes where the input method is automatically activated, add the function activate-default-input-method
below to these modes' startup hook, as in the example below for Text mode and derived modes.
(defun activate-default-input-method ()
(interactive)
(activate-input-method default-input-method))
(add-hook 'text-mode-hook 'activate-default-input-method)