6

If for some reason I am stuck to a keyboard with English layout and I often have to enter text in German - can emacs translate ae to ä (or ue to ü) for me?

I do have a not-working solution like this:

(setq abbrev-file-name "~/.emacs.d/abbrev_defs"
  save-abbrevs t) ;; save abbrevs when file is saved and emacs quits

(if (file-exists-p abbrev-file-name)
(quietly-read-abbrev-file))

(add-hook 'post-self-insert-hook 'expand-abbrev)

where in my abbrev_defs I have

(define-abbrev-table 'global-abbrev-table
  '(
    ("ue" "ü" nil 0)
    ("ae" "ä" nil 0)
    ("sz" "ß" nil 0)))

However this only works at the beginning of a word.

Is there a solution for this available?

  • The layout of the keyboard is one thing though the input method is another. Emacs can also be started with other input methods. Of course, if you say you aren't able to change the input method on your system also, then the built-in input methods provided by the answer seem to be the only option. – xji Feb 2 '17 at 13:04
9

You should be able to press C-\ (toggle-input-method) and give it german-postfix as an argument if asked (or with prefix) and then be able to type as you described.

The minibuffer will show you hints how to enter the diacritics. As always you can ask Emacs to show the documentation for a key with C-h K.

  • You can show documentation for an input method with C-h I (that's capital letter i). – legoscia Jan 27 '17 at 15:00
  • There are other interesting input-metods, e.g. TeX. – politza Jan 27 '17 at 20:47
4

You could have a look at key-seq or key-chord. Both lets you bind keys pressed together to a command, so if you press "ae" at the same time, you can bind it to "ä".

4

Without switching input methods there is direct access to all the german extra characters via C-x 8 ". In particular

  • C-x 8 " a gives ä
  • C-x 8 " A gives Ä
  • etc. and
  • C-x 8 " s gives ß

Similarly C-x 8 ' a gives á, C-x 8 ` a gives à, C-x 8 ^ a gives â and C-x 8 , c gives ç and other accents may be obtained in a comparable way. C-h b shows all current key bindings, but it is a long list, so knowing to look under C-x 8 for european characters is useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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