diff options
| author | Karl Heuer | 1995-01-24 04:20:37 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-01-24 04:20:37 +0000 |
| commit | a36db1ea6b42da06ad0c9fa194f954cf9f623cc1 (patch) | |
| tree | 47f395c909dbf3c5a61d61349471ba6bd1154221 | |
| parent | 9566dc15477da94e7570d84806a917533273c499 (diff) | |
| download | emacs-a36db1ea6b42da06ad0c9fa194f954cf9f623cc1.tar.gz emacs-a36db1ea6b42da06ad0c9fa194f954cf9f623cc1.zip | |
(iso-transl-dead-key-alist): New var.
(iso-transl-char-map): Give each singleton a doubleton synonym.
(iso-transl-language-alist, iso-transl-ctl-x-8-map): New vars.
(iso-transl-define-keys): New function; sets up keymap.
(iso-transl-set-language): New function; sets language-specific part.
| -rw-r--r-- | lisp/international/iso-transl.el | 215 |
1 files changed, 120 insertions, 95 deletions
diff --git a/lisp/international/iso-transl.el b/lisp/international/iso-transl.el index f76111e6326..1c2e108bc1c 100644 --- a/lisp/international/iso-transl.el +++ b/lisp/international/iso-transl.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; iso-transl.el --- keyboard input definitions for ISO 8859/1. | 1 | ;;; iso-transl.el --- keyboard input definitions for ISO 8859/1. |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1987, 1993, 1994 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1987, 1993, 1994, 1995 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Howard Gayle | 5 | ;; Author: Howard Gayle |
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -24,20 +24,28 @@ | |||
| 24 | 24 | ||
| 25 | ;;; Commentary: | 25 | ;;; Commentary: |
| 26 | 26 | ||
| 27 | ;; Loading this package defines two ways of entering the ISO Latin 1 characters | 27 | ;; Loading this package defines three ways of entering the non-ASCII |
| 28 | ;; with codes above 127. | 28 | ;; printable characters with codes above 127: the prefix C-x 8, or the |
| 29 | 29 | ;; Alt key, or a dead accent key. For example, you can enter uppercase | |
| 30 | ;; One way is to type C-x 8 followed by a special chaacter sequence. | 30 | ;; A-umlaut as `C-x 8 " A' or `Alt-" A' (if you have an Alt key) or |
| 31 | ;; For example, C-x 8 " A enters an upper-case A-umlaut. | 31 | ;; `umlaut A' (if you have an umlaut/diaeresis key). |
| 32 | |||
| 33 | ;; The other way is to type the same special sequence | ||
| 34 | ;; but hold down Alt for the first character in it. | ||
| 35 | 32 | ||
| 36 | ;;; Code: | 33 | ;;; Code: |
| 37 | 34 | ||
| 35 | (defvar iso-transl-dead-key-alist | ||
| 36 | '((?\' . mute-acute) | ||
| 37 | (?\` . mute-grave) | ||
| 38 | (?\" . mute-diaeresis) | ||
| 39 | (?\^ . mute-asciicircum) | ||
| 40 | (?\~ . mute-asciitilde)) | ||
| 41 | "Mapping of ASCII characters to their corresponding dead-key symbols.") | ||
| 42 | |||
| 43 | ;; The two-character mnemonics are intended to be available in all languages. | ||
| 44 | ;; The ones beginning with `*' have one-character synonyms, but a | ||
| 45 | ;; language-specific table might override the short form for its own use. | ||
| 38 | (defvar iso-transl-char-map | 46 | (defvar iso-transl-char-map |
| 39 | '((" " . [160]) | 47 | '(("* " . [160])(" " . [160]) |
| 40 | ("!" . [161]) | 48 | ("*!" . [161])("!" . [161]) |
| 41 | ("\"\"" . [168]) | 49 | ("\"\"" . [168]) |
| 42 | ("\"A" . [196]) | 50 | ("\"A" . [196]) |
| 43 | ("\"E" . [203]) | 51 | ("\"E" . [203]) |
| @@ -63,33 +71,33 @@ | |||
| 63 | ("'o" . [243]) | 71 | ("'o" . [243]) |
| 64 | ("'u" . [250]) | 72 | ("'u" . [250]) |
| 65 | ("'y" . [253]) | 73 | ("'y" . [253]) |
| 66 | ("$" . [164]) | 74 | ("*$" . [164])("$" . [164]) |
| 67 | ("+" . [177]) | 75 | ("*+" . [177])("+" . [177]) |
| 68 | (",," . [184]) | 76 | (",," . [184]) |
| 69 | (",C" . [199]) | 77 | (",C" . [199]) |
| 70 | (",c" . [231]) | 78 | (",c" . [231]) |
| 71 | ("-" . [173]) | 79 | ("*-" . [173])("-" . [173]) |
| 72 | ("." . [183]) | 80 | ("*." . [183])("." . [183]) |
| 73 | ("//" . [247]) | 81 | ("//" . [247]) |
| 74 | ("/O" . [216]) | 82 | ("/O" . [216]) |
| 75 | ("/o" . [248]) | 83 | ("/o" . [248]) |
| 76 | ("1/2" . [189]) | 84 | ("1/2" . [189]) |
| 77 | ("1/4" . [188]) | 85 | ("1/4" . [188]) |
| 78 | ("3/4" . [190]) | 86 | ("3/4" . [190]) |
| 79 | ("<" . [171]) | 87 | ("*<" . [171])("<" . [171]) |
| 80 | ("=" . [175]) | 88 | ("*=" . [175])("=" . [175]) |
| 81 | (">" . [187]) | 89 | ("*>" . [187])(">" . [187]) |
| 82 | ("?" . [191]) | 90 | ("*?" . [191])("?" . [191]) |
| 83 | ("A" . [197]) | 91 | ("*A" . [197])("A" . [197]) |
| 84 | ("E" . [198]) | 92 | ("*E" . [198])("E" . [198]) |
| 85 | ("C" . [169]) | 93 | ("*C" . [169])("C" . [169]) |
| 86 | ("D" . [208]) | 94 | ("*D" . [208])("D" . [208]) |
| 87 | ("L" . [163]) | 95 | ("*L" . [163])("L" . [163]) |
| 88 | ("P" . [182]) | 96 | ("*P" . [182])("P" . [182]) |
| 89 | ("R" . [174]) | 97 | ("*R" . [174])("R" . [174]) |
| 90 | ("S" . [167]) | 98 | ("*S" . [167])("S" . [167]) |
| 91 | ("T" . [222]) | 99 | ("*T" . [222])("T" . [222]) |
| 92 | ("Y" . [165]) | 100 | ("*Y" . [165])("Y" . [165]) |
| 93 | ("^1" . [185]) | 101 | ("^1" . [185]) |
| 94 | ("^2" . [178]) | 102 | ("^2" . [178]) |
| 95 | ("^3" . [179]) | 103 | ("^3" . [179]) |
| @@ -115,16 +123,16 @@ | |||
| 115 | ("`i" . [236]) | 123 | ("`i" . [236]) |
| 116 | ("`o" . [242]) | 124 | ("`o" . [242]) |
| 117 | ("`u" . [249]) | 125 | ("`u" . [249]) |
| 118 | ("a" . [229]) | 126 | ("*a" . [229])("a" . [229]) |
| 119 | ("e" . [230]) | 127 | ("*e" . [230])("e" . [230]) |
| 120 | ("c" . [162]) | 128 | ("*c" . [162])("c" . [162]) |
| 121 | ("d" . [240]) | 129 | ("*d" . [240])("d" . [240]) |
| 122 | ("o" . [176]) | 130 | ("*o" . [176])("o" . [176]) |
| 123 | ("s" . [223]) | 131 | ("*s" . [223])("s" . [223]) |
| 124 | ("t" . [254]) | 132 | ("*t" . [254])("t" . [254]) |
| 125 | ("u" . [181]) | 133 | ("*u" . [181])("u" . [181]) |
| 126 | ("x" . [215]) | 134 | ("*x" . [215])("x" . [215]) |
| 127 | ("|" . [166]) | 135 | ("*|" . [166])("|" . [166]) |
| 128 | ("~A" . [195]) | 136 | ("~A" . [195]) |
| 129 | ("~N" . [209]) | 137 | ("~N" . [209]) |
| 130 | ("~O" . [213]) | 138 | ("~O" . [213]) |
| @@ -137,63 +145,80 @@ Each element has the form (STRING . VECTOR). | |||
| 137 | The sequence STRING of ASCII chars translates into the | 145 | The sequence STRING of ASCII chars translates into the |
| 138 | sequence VECTOR. (VECTOR is normally one character long.)") | 146 | sequence VECTOR. (VECTOR is normally one character long.)") |
| 139 | 147 | ||
| 148 | ;; Language-specific translation lists. | ||
| 149 | (defvar iso-transl-language-alist | ||
| 150 | '(("German" | ||
| 151 | ("A" . [196]) | ||
| 152 | ("O" . [214]) | ||
| 153 | ("U" . [220]) | ||
| 154 | ("a" . [228]) | ||
| 155 | ("o" . [246]) | ||
| 156 | ("s" . [223]) | ||
| 157 | ("u" . [252])) | ||
| 158 | ("Spanish" | ||
| 159 | ("!" . [161]) | ||
| 160 | ("?" . [191]) | ||
| 161 | ("N" . [241]) | ||
| 162 | ("n" . [209])) | ||
| 163 | ("Esperanto" | ||
| 164 | ("C" . [198]) | ||
| 165 | ("G" . [216]) | ||
| 166 | ("H" . [166]) | ||
| 167 | ("J" . [172]) | ||
| 168 | ("S" . [222]) | ||
| 169 | ("U" . [221]) | ||
| 170 | ("c" . [230]) | ||
| 171 | ("g" . [248]) | ||
| 172 | ("h" . [182]) | ||
| 173 | ("j" . [188]) | ||
| 174 | ("s" . [254]) | ||
| 175 | ("u" . [253])))) | ||
| 176 | |||
| 177 | (defvar iso-transl-ctl-x-8-map nil | ||
| 178 | "Keymap for C-x 8 prefix.") | ||
| 179 | (or iso-transl-ctl-x-8-map | ||
| 180 | (setq iso-transl-ctl-x-8-map (make-sparse-keymap))) | ||
| 181 | (or key-translation-map | ||
| 182 | (setq key-translation-map (make-sparse-keymap))) | ||
| 183 | (define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map) | ||
| 184 | |||
| 185 | ;; For each entry in the alist, we'll make up to three ways to generate | ||
| 186 | ;; the character in question: the prefix `C-x 8'; the ALT modifier on | ||
| 187 | ;; the first key of the sequence; and (if applicable) replacing the first | ||
| 188 | ;; key of the sequence with the corresponding dead key. For example, a | ||
| 189 | ;; character associated with the string "~n" can be input with `C-x 8 ~ n' | ||
| 190 | ;; or `Alt-~ c' or `mute-asciitilde c'. | ||
| 191 | (defun iso-transl-define-keys (alist) | ||
| 192 | (while alist | ||
| 193 | (define-key iso-transl-ctl-x-8-map (car (car alist)) (cdr (car alist))) | ||
| 194 | (let ((vec (vconcat (car (car alist)))) | ||
| 195 | (deadpair (assq (aref (car (car alist)) 0) | ||
| 196 | iso-transl-dead-key-alist))) | ||
| 197 | (aset vec 0 (logior (aref vec 0) ?\A-\^@)) | ||
| 198 | (define-key key-translation-map vec (cdr (car alist))) | ||
| 199 | (define-key isearch-mode-map (vector (aref vec 0)) nil) | ||
| 200 | (if deadpair | ||
| 201 | (let ((deadvec (copy-sequence vec))) | ||
| 202 | (aset deadvec 0 (cdr deadpair)) | ||
| 203 | (define-key isearch-mode-map (vector (aref deadvec 0)) nil) | ||
| 204 | (define-key key-translation-map deadvec (cdr (car alist)))))) | ||
| 205 | (setq alist (cdr alist)))) | ||
| 206 | |||
| 207 | (defun iso-transl-set-language (lang) | ||
| 208 | (interactive (list (let ((completion-ignore-case t)) | ||
| 209 | (completing-read "Set which language? " | ||
| 210 | iso-transl-language-alist nil t)))) | ||
| 211 | (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist)))) | ||
| 212 | |||
| 213 | |||
| 214 | ;; The standard mapping comes automatically. You can partially overlay it | ||
| 215 | ;; with a language-specific mapping by using `M-x iso-transl-set-language'. | ||
| 216 | (iso-transl-define-keys iso-transl-char-map) | ||
| 217 | |||
| 218 | (define-key isearch-mode-map "\C-x" nil) | ||
| 219 | (define-key isearch-mode-map [?\C-x t] 'isearch-other-control-char) | ||
| 220 | (define-key isearch-mode-map "\C-x8" nil) | ||
| 140 | 221 | ||
| 141 | (let ((map (make-sparse-keymap)) | ||
| 142 | table) | ||
| 143 | (setq table iso-transl-char-map) | ||
| 144 | ;;; ;; Create all the prefixes we need. | ||
| 145 | ;;; (define-key map "\"" (make-sparse-keymap)) | ||
| 146 | ;;; (define-key map "'" (make-sparse-keymap)) | ||
| 147 | ;;; (define-key map "," (make-sparse-keymap)) | ||
| 148 | ;;; (define-key map "/" (make-sparse-keymap)) | ||
| 149 | ;;; (define-key map "1" (make-sparse-keymap)) | ||
| 150 | ;;; (define-key map "1/" (make-sparse-keymap)) | ||
| 151 | ;;; (define-key map "3" (make-sparse-keymap)) | ||
| 152 | ;;; (define-key map "3/" (make-sparse-keymap)) | ||
| 153 | ;;; (define-key map "A" (make-sparse-keymap)) | ||
| 154 | ;;; (define-key map "^" (make-sparse-keymap)) | ||
| 155 | ;;; (define-key map "_" (make-sparse-keymap)) | ||
| 156 | ;;; (define-key map "`" (make-sparse-keymap)) | ||
| 157 | ;;; (define-key map "a" (make-sparse-keymap)) | ||
| 158 | ;;; (define-key map "~" (make-sparse-keymap)) | ||
| 159 | |||
| 160 | ;; Enter the individual sequences. | ||
| 161 | (setq table iso-transl-char-map) | ||
| 162 | (while table | ||
| 163 | (define-key map (car (car table)) (cdr (car table))) | ||
| 164 | (setq table (cdr table))) | ||
| 165 | |||
| 166 | (or key-translation-map | ||
| 167 | (setq key-translation-map (make-sparse-keymap))) | ||
| 168 | (define-key key-translation-map "\C-x8" map) | ||
| 169 | |||
| 170 | ;; Enter the individual sequences, this time with Alt as a modifier | ||
| 171 | ;; on the first character, instead of with C-x 8 as a prefix. | ||
| 172 | (setq table iso-transl-char-map) | ||
| 173 | (while table | ||
| 174 | (let ((string (vconcat (car (car table))))) | ||
| 175 | (aset string 0 (+ (aref string 0) 262144)) | ||
| 176 | (define-key key-translation-map string (cdr (car table)))) | ||
| 177 | (setq table (cdr table))) | ||
| 178 | |||
| 179 | ;; Enter the individual sequences, this time with | ||
| 180 | ;; certain special function keys replacing the punctuation characters. | ||
| 181 | (setq table iso-transl-char-map) | ||
| 182 | (while table | ||
| 183 | (let ((mapping | ||
| 184 | (assq (aref (car (car table)) 0) '((?\' . mute-acute) | ||
| 185 | (?\` . mute-grave) | ||
| 186 | (?\" . mute-diaeresis) | ||
| 187 | (?\^ . mute-asciicircum) | ||
| 188 | (?\~ . mute-asciitilde))))) | ||
| 189 | (if mapping | ||
| 190 | (let ((string (vector (cdr mapping) (aref (car (car table)) 1)))) | ||
| 191 | (define-key key-translation-map string (cdr (car table)))))) | ||
| 192 | (setq table (cdr table))) | ||
| 193 | |||
| 194 | (define-key isearch-mode-map "\C-x" nil) | ||
| 195 | (define-key isearch-mode-map [?\C-x t] 'isearch-other-control-char) | ||
| 196 | (define-key isearch-mode-map "\C-x8" nil)) | ||
| 197 | 222 | ||
| 198 | (provide 'iso-transl) | 223 | (provide 'iso-transl) |
| 199 | 224 | ||