Q: how do I switch between input methods for different languages when using a non-standard keyboard layout?

I have to edit text in two different languages. I would like to be able to use my keybindings across the two languages, except, of course, when inserting text into the buffer. It looks like I should be able to toggle-input-method (C-\) and select the alternate language.

So far, almost so good.

Here's the rub: I use the English Dvorak layout, which I set at the OS level (ie, with setxkbmap). When I toggle-input-method, the text I insert would be correct if I had a QWERTY layout (the standard in the US), but comes out as gibberish because I'm on Dvorak. (FWIW, when I switch my layout to standard US, it works fine.)

So: how do I inform Emacs that I'm using Dvorak so that toggle-input-method and friends translate my keypresses to the correct characters in the other language?

  • swedish-postfix and other compositional input methods work for me, which methods are you having trouble with?
    – shapr
    Nov 14, 2014 at 20:54
  • @shapr: I'm switching between English and Arabic. The problem seems to be that I'm using a Dvorak layout at the OS level, as the toggling works fine when I use the standard US layout at the OS level.
    – Dan
    Nov 14, 2014 at 21:01

2 Answers 2


There is a method to change the physical layout definition for input method by setting quail-keyboard-layout-type. But it looks Dvorak is not among the possible candidates in quail-keyboard-layout-alist in my Emacs 24.4.

You can either define a new physical keyboard layout by looking at definition of quail-keyboard-layout-alist in quail.el or create a new input method by defining corresponding Arabic keys for Dvorak layout.

I'm not experienced in the first, but I can testify the second approach is easier than you think. (I had to create an Ottoman Turkish input method on top of Farsi.) Copy arabic.el (which resides in my Debian system at /usr/share/emacs/24.4/lisp/leim/quail/arabic.el.gz) to your home site-lisp and change the keys per your preferences. Also, don't forget to change the input method names etc. You just created a new Dvorak-Arabic input method.

I can update the answer with more details if anything seems complex.

  • Thank you! That set me on the correct path. I'll post an additional answer that lays out how I got there on the ...-alist version.
    – Dan
    Nov 15, 2014 at 12:29
  • You're welcome. You may think to submit your update to the quail-. *-alist to Emacs development. I'm sure there are other Dvorak users that will benefit from it.
    – Emre Sahin
    Nov 16, 2014 at 11:02

@EmreSahin put me on the right path to answer this question, so I'm laying out a little bit of the detail in case anyone else ever has to deal with a problem like this themselves.

As Emre points out, we need to add a Dvorak layout to quail-keyboard-layout-alist. It turns out that the quail library is not well-documented in the manual, in which two related functions are mentioned in passing on one node.

However, after consulting this help thread and, especially, the EmacsWiki page on Russian with Dvorak (from which this answer cribs), I've think I've got it figured out.

The docstring for the variable quail-keyboard-layout describes what we need to put in quail-keyboard-layout-alist. It's a long string corresponding to 6 rows of 15 keys each. Each row corresponds to the unshifted and shifted values of each key, for a total of 30 characters per row. I'm less sure about the following point, but it appears that, for what I'll call "semi-standard" keyboards with 4 rows of keys, the first and sixth rows should each be 30 blank spaces.

The big reveal:

(require 'quail)

(add-to-list 'quail-keyboard-layout-alist
             `("dvorak" . ,(concat "                              "
                                   "  1!2@3#4$5%6^7&8*9(0)[{]}`~  "
                                   "  '\",<.>pPyYfFgGcCrRlL/?=+    "
                                   "  aAoOeEuUiIdDhHtTnNsS-_\\|    "
                                   "  ;:qQjJkKxXbBmMwWvVzZ        "
                                   "                              ")))

(quail-set-keyboard-layout "dvorak")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.