;; el-accents.el -- electric accent keys ;; ;; SCCS Status : @(#)@ el-accents.el 1.3 ;; Author : Johan Vromans ;; Created On : Tue Feb 5 09:58:05 1991 ;; Last Modified By: Johan Vromans ;; Last Modified On: Tue Oct 15 18:39:07 1991 ;; Update Count : 4 ;; Status : OK ;; ;; Use pseudo-accents to allow "dead keys" like a typewriter. ;; ;; Pseudo-accents are: ;; ;; ' (minute) -> grave accent ;; ` (backtick) -> acute accent ;; " (second) -> diaeresis ;; ^ (caret) -> circonflexe ;; ;; In general: ;; ;; pseudo-accent appropriate letter -> accented letter ;; pseudo-accent space -> pseudo-accent ;; pseudo-accent pseudo-accent -> accent (if available) ;; pseudo-accent other -> pseudo-accent other ;; ;; Function "electric-accents" can be used to enable the dead keys, or ;; disable them if called with a non-null argument. ;; ;; The inserted codes are conformant to the ISO Latin-1 alphabeth. ;; ;; Thanks to: Dale ;; (defvar electric-accent-list '(((?' ?A) ?\301) ((?' ?C) ?\307) ((?' ?E) ?\311) ((?' ?I) ?\315) ((?' ?O) ?\323) ((?' ?U) ?\332) ((?' ?a) ?\341) ((?' ?c) ?\347) ((?' ?e) ?\351) ((?' ?i) ?\355) ((?' ?o) ?\363) ((?' ?u) ?\372) ((?' ?') ?') ; \264 ? ; ((?' ? ) ?') ((?` ?A) ?\300) ((?` ?E) ?\310) ((?` ?I) ?\314) ((?` ?O) ?\322) ((?` ?U) ?\331) ((?` ?a) ?\340) ((?` ?e) ?\350) ((?` ?i) ?\354) ((?` ?o) ?\362) ((?` ?u) ?\371) ((?` ?`) ?`) ; ((?` ? ) ?`) ((?^ ?A) ?\302) ((?^ ?E) ?\312) ((?^ ?I) ?\316) ((?^ ?O) ?\324) ((?^ ?U) ?\333) ((?^ ?a) ?\342) ((?^ ?e) ?\352) ((?^ ?i) ?\356) ((?^ ?o) ?\364) ((?^ ?u) ?\373) ; ((?^ ? ) ?^) ((?^ ?^) ?^) ; no special code? ((?\" ?A) ?\304) ((?\" ?E) ?\313) ((?\" ?I) ?\317) ((?\" ?O) ?\326) ((?\" ?U) ?\334) ((?\" ?a) ?\344) ((?\" ?e) ?\353) ((?\" ?i) ?\357) ((?\" ?o) ?\366) ((?\" ?u) ?\374) ; ((?\" ? ) ?\") ((?\" ?\") ?\") ;\250 ? ((?~ ?A) ?\303) ((?~ ?N) ?\321) ((?~ ?O) ?\325) ((?~ ?a) ?\343) ((?~ ?n) ?\361) ((?~ ?o) ?\365) ((?~ ?~) ?~) )) (defun dead-key () "Emulate typewriter dead keys." (interactive) ;; Pick up the dead-key (let ((first-char last-command-char)) ;; Display it and backup (insert first-char) (backward-char 1) ;; Wait for the second key and look up the combination in the list (let* ((second-char (read-char)) (entry (assoc (list first-char second-char) electric-accent-list))) (if entry ;; If it's OK, delete the first character and insert the combination (progn (delete-char 1) (insert (car (cdr entry)))) ;; Otherwise, advance and execute the second key (forward-char 1) (setq unread-command-char second-char))))) (defun electric-accents (&optional arg) "Have the pseudo-accent keys behave like dead typewriter keys. With ARG, make them normal again." (interactive "P") (if arg (progn (local-unset-key "'") (local-unset-key "`") (local-unset-key "~") (local-unset-key "\"") (local-unset-key "^")) (local-set-key "'" 'dead-key) (local-set-key "`" 'dead-key) (local-set-key "^" 'dead-key) (local-set-key "\"" 'dead-key) (local-set-key "~" 'dead-key) ))