1

I am typing with a German ISO keyboard that I've set to US English in X:

setxkbmap -layout us -model pc102

For entering German characters in Emacs, I do:

(set-input-method 'german)

Some special characters are in unusual locations, but that's fine. All characters for writing texts are in the correct location, except for one, the single quote. If I type S-# on a German ISO keyboard, then instead I get ^, the caret.

How do I fix that?

PS: I know that I could change keyboard layouts using setxkbmap and even toggle between several layouts. However, switching layout in Emacs seems at least interesting. I could of course define keyboard shortcuts to call setxkbmap from within Emacs, and perhaps I'll do just that.

  • 1
    This is not really a solution, but as a quick workaround you can probably do `C-\` to toggle your input method, type your single quote, and then toggle again (the German input method doesn't have an entry for single quote, possibly because it's based on the Sun German layout, not the ISO one) – rpluim Jan 29 at 15:59
  • @rpluim Toggling input method is fine if I need to type special characters, but ' is just a standard character that I need when writing text for humans. Thanks for the bit of history! – feklee Jan 29 at 16:11
  • 1
    In that case, you could copy the definitions for the German input method from lisp/leim/quail/latin-post.el to your init file, and adjust it as needed, eg by adding ("||" ?') to it, such that repeating S-# results in ^ – rpluim Jan 29 at 16:18
  • @rpluim I could just create my own iso-german package, no? (or maybe so. has already done that) – feklee Jan 29 at 16:33
  • 1
    Absolutely you could (and fix any other things you dislike about it in the process) – rpluim Jan 29 at 16:48
2

Created my own layout, german-t1, simply by adding to ~/.emacs:

;; T1 German keyboard layout without AltGR and without <> (see
;; <https://emacs.stackexchange.com/a/47487/5327>):
(quail-define-package
 "german-t1" "German" "DE1" t
 "German (Deutsch) input method simulating the T1 layout"
 nil t t t t nil nil nil nil nil t)

;; ^°  1!  2"  3§  4$  5%  6&  7/  8(  9)  0=  ß?  ´`
;;      qQ  wW  eE  rR  tT  zZ  uU  iI  oO  pP  üÜ  +*
;;       aA  sS  dD  fF  gG  hH  jJ  kK  lL  öÖ  äÄ  #'
;;        yY  xX  cC  vV  bB  nN  mM  ,;  .:  -_

(quail-define-rules
 (">" ?:)
 ("<" ?\;)
 ("`" ?^)
 ("~" ?°)
 ("-" ?ß)
 ("=" ?\´)
 ("`" ?\])
 ("y" ?z)
 ("[" ?ü)
 ("]" ?+)
 (";" ?ö)
 ("'" ?ä)
 ("\\" ?#)
 ("z" ?y)
 ("/" ?-)
 ("@" ?\")
 ("#" ?§)
 ("^" ?&)
 ("&" ?/)
 ("*" ?\()
 ("Y" ?Z)
 ("(" ?\))
 (")" ?=)
 ("_" ??)
 ("+" ?`)
 ("~" ?})
 ("{" ?Ü)
 ("}" ?*)
 (":" ?Ö)
 ("\"" ?Ä)
 ("|" ?\')
 ("Z" ?Y)
 ("?" ?_)
 )

Credit goes to @rpluim for pointing me in the right direction!

0

This is far from the ideal solution, but it should let you type the single quote (though it will prevent you from typing ^).

(define-key key-translation-map (kbd "^") (kbd "'"))
  • It's good to know about key-translation-map. A drawback is that this simple solution will also affect all other keyboard layouts, not just the German one. – feklee Jan 29 at 17:00
  • Good point. This page mentions rebinding keys in an input method using quail-translation-map, but my attempt at detecting the new input method in quail-activate-hook failed, so I'm not sure how you could define keys in a specific, non-current input method (and this page describes the basic input mappings, if you want to know more). – jirassimok Jan 29 at 17:49

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.