7

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?

Matthias
  • 745
  • 3
  • 14
  • 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 02 '17 at 13:04

3 Answers3

13

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.

p_wiersig
  • 1,051
  • 9
  • 15
9

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.

Andrew Swann
  • 3,436
  • 2
  • 15
  • 43
3

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 "ä".

Erik Sjöstrand
  • 826
  • 4
  • 14