Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to be able to use simultaneously key-chord and an input method such as rfc1345.

Presently I use

C-x RET C-M-\ rfc1234 RET

to activate the input method.

and

M-x key-chord-mode RET M-x key-chord-mode RET (yes, two times)

to re-activate key-chord.

This switch is rather cumbersome. Any idea about how to have them both ativated? Or maybe a way to switch more quickly?

share|improve this question

The following code worked for me (I didn't write it, just got from some other source - don't remember where)

I just did some adjustments for my needs...

(set-language-environment "UTF-8")
(setq default-input-method "portuguese-prefix")

(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
      (progn
        (set-input-method default-input-method)
        (activate-input-method default-input-method))
    (inactivate-input-method))
  (key-chord-mode t))

(add-hook 'after-change-major-mode-hook 'activate-default-input-method)
(add-hook 'org-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)
  (key-chord-mode t))

(add-hook 'c-mode-hook 'inactivate-default-input-method)

(activate-default-input-method)

In the last line, you can define the hooks that won't use the default input method, but key-chord-mode will also be set on.

share|improve this answer

Does this function do what you want:

(defun my-whatever ()
  (interactive)
  "Doc string goes here."
  (activate-input-method "rfc1234")
  (key-chord-mode nil)
  (key-chord-mode nil))

I'm not sure what you have C-M-\ bound to, but if it's bound to activate-input-method, I think this does the equivalent of your key presses.

Obviously, you would bind this function to a key sequence of your choosing.

share|improve this answer
    
I tried it but I get an error message : > activate-input-method: Can't activate input method rfc1234' <kbd>C-x RET C-M-\</kbd> is the default for set-input-method. Changing activate` to set raises the same error message. Also I would like to be able to toggle between both mehtods (if they cannot work together). I can define a similar command doing the reverse action but then I will have to use another key. – Alfred M. Jul 18 '12 at 12:27
up vote 0 down vote accepted

There is a built-in function toggle-input-method, bound to C-\ by default that conveniently allows to switch from the set input method and key-chord support.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .