(defun compose-disable-all-followups (mode-map key-to-revert-l) (dolist (key-to-revert key-to-revert-l) (let ((key (car key-to-revert)) (revert (nth 2 key-to-revert))) (define-key mode-map key revert) ))) (defun compose-followup-key (mode-map key-to-revert-l) (dolist (key-to-revert key-to-revert-l) (let ((key (car key-to-revert)) (to (nth 1 key-to-revert)) (revert (nth 2 key-to-revert))) (define-key (symbol-value mode-map) key `(lambda () (interactive) (insert ,to) (compose-disable-all-followups ,mode-map ',key-to-revert-l )))))) (defun activate-semi-colon-compose-key () (interactive) (compose-followup-key 'text-mode-map '(("A" "Ä" self-insert-command) ("a" "ä" self-insert-command) ("O" "Ö" self-insert-command) ("o" "ö" self-insert-command) (":" "Å" self-insert-command) (";" "å" activate-semi-colon-compose-key) ))) (define-key text-mode-map ";" 'activate-semi-colon-compose-key)