Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I am using emacs 23.3 on KDE, I can not input ^, ´ and ~ from my German keyboard. If I press these keys, then emacs says that <dead-circumflex>, <dead-acute> and <dead-tilde> are undefined.

I can input ^, ´ and ~ on other applications (e.g. Konsole, Kwrite and firefox), and I can also paste these letters on emacs.

I have tried to type C-x ret C-\ latin-1-postfix, but there is no change.

Could anyone tell me how to solve this problem?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

I don't know what's causing this problem or how to fix this, but I can offer a workaround for most purposes.

Normally, dead keys are processed at a very low input layer, not even visible from Lisp. But you can do the processing in Lisp.

If you want the keys to act as dead keys:

There is already a limited mechanism for dead keys in Lisp, designed for 8-bit character sets on machines that don't have any way to input non-ASCII characters. If you type C-x 8 followed by an accent and a letter, the corresponding accented letter is inserted, thanks to the iso-transl library. We can copy this mechanism. Put this in your .emacs:

(define-key key-translation-map [dead-grave] (lookup-key key-translation-map "\C-x8`"))
(define-key key-translation-map [dead-acute] (lookup-key key-translation-map "\C-x8'"))
(define-key key-translation-map [dead-circumflex] (lookup-key key-translation-map "\C-x8^"))
(define-key key-translation-map [dead-diaeresis] (lookup-key key-translation-map "\C-x8\""))
(define-key key-translation-map [dead-tilde] (lookup-key key-translation-map "\C-x8~"))
(define-key isearch-mode-map [dead-grave] nil)
(define-key isearch-mode-map [dead-acute] nil)
(define-key isearch-mode-map [dead-circumflex] nil)
(define-key isearch-mode-map [dead-diaeresis] nil)
(define-key isearch-mode-map [dead-tilde] nil)

The map key-translation-map rewrites key sequences as they are entered, so this will make dead ` a equivalent to à for most purposes. Explicitly setting entries in isearch-mode-map to nil is necessary because otherwise pressing a dead key would exit isearch before the translation could kick in.

If you want the accent characters to be inserted immediately

(define-key key-translation-map [dead-grave] "`")
(define-key key-translation-map [dead-acute] "'")
(define-key key-translation-map [dead-circumflex] "^")
(define-key key-translation-map [dead-diaeresis] "\"")
(define-key key-translation-map [dead-tilde] "~")
share|improve this answer
    
Thank you very much for your suggestion. The above settings allow me to input all of ^, ´ and ~ on emacs by pressing "^ SPC", "´ SPC" and "~ SPC". Do you know if there is a way to input these letters by pressing only each key (i.e. without SPC)? I have tried to modify the above settings like "(define-key key-translation-map [dead-circumflex] (lookup-key key-translation-map "\C-x8^SPC"))", but this seems to be invalid. –  H. Shindoh Jan 3 '12 at 12:23
    
@moduli: If you want to press only one key for these characters everywhere (not just in Emacs), you can change the keyboard settings in KDE. Choose a keyboard with something like "German - no dead keys" ("ohne Akzenttasten"). –  elmicha Jan 4 '12 at 18:41
1  
@moduli Oh, I think I misunderstood your question. I thought you wanted ^, ` and ~ to be dead keys, and that wasn't working. If you want them to insert the actual character, then it's even easier: (define-key key-translation-map [dead-tilde] "~") and the like. But in that case it may be better to handle this at the system level (through KDE) as elmicha suggests. –  Gilles Jan 4 '12 at 20:07
1  
@elmicha Thank you for your comment. I can input the letters by one press for all applications expect firefox and emacs. For firefox, I can input ^ by two presses the same key and I do not think that is a problem. –  H. Shindoh Jan 4 '12 at 21:49
    
@Gilles Thank you for the setting. It works as I expected! –  H. Shindoh Jan 4 '12 at 22:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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