Commit | Line | Data |
---|---|---|
381194d0 | 1 | ;;; iso-transl.el --- keyboard input definitions for ISO 8859-1 |
5970f3d0 | 2 | |
a36db1ea | 3 | ;; Copyright (C) 1987, 1993, 1994, 1995 Free Software Foundation, Inc. |
5970f3d0 RS |
4 | |
5 | ;; Author: Howard Gayle | |
6 | ;; Maintainer: FSF | |
7 | ;; Keywords: i18n | |
8 | ||
9 | ;; This file is part of GNU Emacs. | |
10 | ||
11 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 | ;; it under the terms of the GNU General Public License as published by | |
13 | ;; the Free Software Foundation; either version 2, or (at your option) | |
14 | ;; any later version. | |
15 | ||
16 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;; GNU General Public License for more details. | |
20 | ||
21 | ;; You should have received a copy of the GNU General Public License | |
b578f267 EN |
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 | ;; Boston, MA 02111-1307, USA. | |
5970f3d0 | 25 | |
63202134 RS |
26 | ;;; Commentary: |
27 | ||
a36db1ea KH |
28 | ;; Loading this package defines three ways of entering the non-ASCII |
29 | ;; printable characters with codes above 127: the prefix C-x 8, or the | |
30 | ;; Alt key, or a dead accent key. For example, you can enter uppercase | |
31 | ;; A-umlaut as `C-x 8 " A' or `Alt-" A' (if you have an Alt key) or | |
32 | ;; `umlaut A' (if you have an umlaut/diaeresis key). | |
63202134 | 33 | |
b1fb5d1b KH |
34 | ;; C-x 8 is set up to autoload this package, |
35 | ;; but Alt keys and dead accent keys are only defined | |
36 | ;; once you have loaded the package. It is nontrivial | |
37 | ;; to make all of the Alt keys autoload, and it is not clear | |
38 | ;; that the dead accent keys SHOULD autoload this package. | |
39 | ||
5970f3d0 RS |
40 | ;;; Code: |
41 | ||
628eac44 KH |
42 | ;;; Provide some binding for startup: |
43 | ;;;###autoload (or key-translation-map (setq key-translation-map (make-sparse-keymap))) | |
79f86347 | 44 | ;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map) |
628eac44 KH |
45 | ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap) |
46 | ||
a36db1ea KH |
47 | (defvar iso-transl-dead-key-alist |
48 | '((?\' . mute-acute) | |
49 | (?\` . mute-grave) | |
50 | (?\" . mute-diaeresis) | |
97966523 RS |
51 | (?^ . mute-asciicircum) |
52 | (?\~ . mute-asciitilde) | |
53 | (?\' . dead-acute) | |
54 | (?\` . dead-grave) | |
55 | (?\" . dead-diaeresis) | |
56 | (?^ . dead-asciicircum) | |
57 | (?\~ . dead-asciitilde) | |
58 | (?^ . dead-circum) | |
59 | (?^ . dead-circumflex) | |
60 | (?\~ . dead-tilde) | |
61 | ;; Someone reports that these keys don't work if shifted. | |
62 | ;; This might fix it--no word yet. | |
63 | (?\' . S-dead-acute) | |
64 | (?\` . S-dead-grave) | |
65 | (?\" . S-dead-diaeresis) | |
66 | (?^ . S-dead-asciicircum) | |
67 | (?\~ . S-dead-asciitilde) | |
68 | (?^ . S-dead-circum) | |
69 | (?^ . S-dead-circumflex) | |
70 | (?\~ . S-dead-tilde)) | |
a36db1ea KH |
71 | "Mapping of ASCII characters to their corresponding dead-key symbols.") |
72 | ||
73 | ;; The two-character mnemonics are intended to be available in all languages. | |
74 | ;; The ones beginning with `*' have one-character synonyms, but a | |
75 | ;; language-specific table might override the short form for its own use. | |
ff031514 RS |
76 | |
77 | ;; When a translation is non-ASCII, we use a symbol name | |
78 | ;; whose "function definition" is a translation, rather than | |
79 | ;; writing the translation directly here. | |
80 | ;; That is for the sake of C-x 8 C-h. | |
63202134 | 81 | (defvar iso-transl-char-map |
ff031514 RS |
82 | '(("* " . iso-transl-no-break-space) |
83 | (" " . iso-transl-no-break-space) | |
84 | ("*!" . iso-transl-inverted-exclamation-mark) | |
85 | ("!" . iso-transl-inverted-exclamation-mark) | |
86 | ("\"\"" . iso-transl-diaeresis) | |
87 | ("\"A" . iso-transl-A-umlaut) | |
88 | ("\"E" . iso-transl-E-umlaut) | |
89 | ("\"I" . iso-transl-I-umlaut) | |
90 | ("\"O" . iso-transl-O-umlaut) | |
91 | ("\"U" . iso-transl-U-umlaut) | |
92 | ("\"a" . iso-transl-a-umlaut) | |
93 | ("\"e" . iso-transl-e-umlaut) | |
94 | ("\"i" . iso-transl-i-umlaut) | |
95 | ("\"o" . iso-transl-o-umlaut) | |
96 | ("\"s" . iso-transl-ss) | |
97 | ("\"u" . iso-transl-u-umlaut) | |
98 | ("\"y" . iso-transl-y-umlaut) | |
99 | ("''" . iso-transl-acute-accent) | |
100 | ("'A" . iso-transl-A-acute) | |
101 | ("'E" . iso-transl-E-acute) | |
102 | ("'I" . iso-transl-I-acute) | |
103 | ("'O" . iso-transl-O-acute) | |
104 | ("'U" . iso-transl-U-acute) | |
105 | ("'Y" . iso-transl-Y-acute) | |
106 | ("'a" . iso-transl-a-acute) | |
107 | ("'e" . iso-transl-e-acute) | |
108 | ("'i" . iso-transl-i-acute) | |
109 | ("'o" . iso-transl-o-acute) | |
110 | ("'u" . iso-transl-u-acute) | |
111 | ("'y" . iso-transl-y-acute) | |
112 | ("*$" . iso-transl-general-currency-sign) | |
113 | ("$" . iso-transl-general-currency-sign) | |
114 | ("*+" . iso-transl-plus-or-minus-sign) | |
115 | ("+" . iso-transl-plus-or-minus-sign) | |
116 | (",," . iso-transl-cedilla) | |
117 | (",C" . iso-transl-C-cedilla) | |
118 | (",c" . iso-transl-c-cedilla) | |
119 | ("*-" . iso-transl-soft-hyphen) | |
120 | ("-" . iso-transl-soft-hyphen) | |
121 | ("*." . iso-transl-middle-dot) | |
122 | ("." . iso-transl-middle-dot) | |
123 | ("//" . iso-transl-division-sign) | |
ebdf0c33 RS |
124 | ("/A" . iso-transl-A-ring) |
125 | ("/E" . iso-transl-AE) | |
ff031514 | 126 | ("/O" . iso-transl-O-slash) |
ebdf0c33 RS |
127 | ("/a" . iso-transl-a-ring) |
128 | ("/e" . iso-transl-ae) | |
ff031514 RS |
129 | ("/o" . iso-transl-o-slash) |
130 | ("1/2" . iso-transl-one-half) | |
131 | ("1/4" . iso-transl-one-quarter) | |
132 | ("3/4" . iso-transl-three-quarters) | |
133 | ("*<" . iso-transl-angle-left) | |
134 | ("<" . iso-transl-angle-left) | |
135 | ("*=" . iso-transl-macron) | |
136 | ("=" . iso-transl-macron) | |
137 | ("*>" . iso-transl-angle-right) | |
138 | (">" . iso-transl-angle-right) | |
139 | ("*?" . iso-transl-inverted-question-mark) | |
140 | ("?" . iso-transl-inverted-question-mark) | |
141 | ("*C" . iso-transl-copyright-sign) | |
142 | ("C" . iso-transl-copyright-sign) | |
143 | ("*L" . iso-transl-pound-sign) | |
144 | ("L" . iso-transl-pound-sign) | |
145 | ("*P" . iso-transl-pilcrow) | |
146 | ("P" . iso-transl-pilcrow) | |
147 | ("*R" . iso-transl-registered-sign) | |
148 | ("R" . iso-transl-registered-sign) | |
149 | ("*S" . iso-transl-section-sign) | |
150 | ("S" . iso-transl-section-sign) | |
151 | ("*Y" . iso-transl-yen-sign) | |
152 | ("Y" . iso-transl-yen-sign) | |
153 | ("^1" . iso-transl-superscript-1) | |
154 | ("^2" . iso-transl-superscript-2) | |
155 | ("^3" . iso-transl-superscript-3) | |
156 | ("^A" . iso-transl-A-caret) | |
157 | ("^E" . iso-transl-E-caret) | |
158 | ("^I" . iso-transl-I-caret) | |
159 | ("^O" . iso-transl-O-caret) | |
160 | ("^U" . iso-transl-U-caret) | |
161 | ("^a" . iso-transl-a-caret) | |
f7ad1899 DL |
162 | ("^e" . iso-transl-e-caret) |
163 | ("^i" . iso-transl-i-caret) | |
164 | ("^o" . iso-transl-o-caret) | |
165 | ("^u" . iso-transl-u-caret) | |
ff031514 RS |
166 | ("_a" . iso-transl-ordinal-indicator-feminine) |
167 | ("_o" . iso-transl-ordinal-indicator-masculine) | |
168 | ("`A" . iso-transl-A-grave) | |
169 | ("`E" . iso-transl-E-grave) | |
170 | ("`I" . iso-transl-I-grave) | |
171 | ("`O" . iso-transl-O-grave) | |
172 | ("`U" . iso-transl-U-grave) | |
173 | ("`a" . iso-transl-a-grave) | |
174 | ("`e" . iso-transl-e-grave) | |
175 | ("`i" . iso-transl-i-grave) | |
176 | ("`o" . iso-transl-o-grave) | |
177 | ("`u" . iso-transl-u-grave) | |
178 | ("*c" . iso-transl-cent-sign) | |
179 | ("c" . iso-transl-cent-sign) | |
180 | ("*o" . iso-transl-degree-sign) | |
181 | ("o" . iso-transl-degree-sign) | |
182 | ("*u" . iso-transl-micro-sign) | |
183 | ("u" . iso-transl-micro-sign) | |
184 | ("*m" . iso-transl-micro-sign) | |
185 | ("m" . iso-transl-micro-sign) | |
186 | ("*x" . iso-transl-multiplication-sign) | |
187 | ("x" . iso-transl-multiplication-sign) | |
188 | ("*|" . iso-transl-broken-vertical-line) | |
189 | ("|" . iso-transl-broken-vertical-line) | |
190 | ("~A" . iso-transl-A-tilde) | |
191 | ("~D" . iso-transl-D-stroke) | |
192 | ("~N" . iso-transl-N-tilde) | |
193 | ("~O" . iso-transl-O-tilde) | |
194 | ("~T" . iso-transl-THORN) | |
195 | ("~a" . iso-transl-a-tilde) | |
196 | ("~d" . iso-transl-d-stroke) | |
197 | ("~n" . iso-transl-n-tilde) | |
198 | ("~o" . iso-transl-o-tilde) | |
199 | ("~t" . iso-transl-thorn) | |
200 | ("~~" . iso-transl-not-sign) | |
378df08c RS |
201 | ("' " . "'") |
202 | ("` " . "`") | |
203 | ("\" " . "\"") | |
204 | ("^ " . "^") | |
205 | ("~ " . "~")) | |
63202134 RS |
206 | "Alist of character translations for entering ISO characters. |
207 | Each element has the form (STRING . VECTOR). | |
208 | The sequence STRING of ASCII chars translates into the | |
209 | sequence VECTOR. (VECTOR is normally one character long.)") | |
210 | ||
ff031514 RS |
211 | (defalias 'iso-transl-no-break-space [160]) |
212 | (defalias 'iso-transl-inverted-exclamation-mark [161]) | |
213 | (defalias 'iso-transl-cent-sign [162]) | |
214 | (defalias 'iso-transl-pound-sign [163]) | |
215 | (defalias 'iso-transl-general-currency-sign [164]) | |
216 | (defalias 'iso-transl-yen-sign [165]) | |
217 | (defalias 'iso-transl-broken-vertical-line [166]) | |
218 | (defalias 'iso-transl-section-sign [167]) | |
219 | (defalias 'iso-transl-diaeresis [168]) | |
220 | (defalias 'iso-transl-copyright-sign [169]) | |
221 | (defalias 'iso-transl-ordinal-indicator-feminine [170]) | |
222 | (defalias 'iso-transl-angle-left [171]) | |
223 | (defalias 'iso-transl-not-sign [172]) | |
224 | (defalias 'iso-transl-soft-hyphen [173]) | |
225 | (defalias 'iso-transl-registered-sign [174]) | |
226 | (defalias 'iso-transl-macron [175]) | |
227 | (defalias 'iso-transl-degree-sign [176]) | |
228 | (defalias 'iso-transl-plus-or-minus-sign [177]) | |
229 | (defalias 'iso-transl-superscript-2 [178]) | |
230 | (defalias 'iso-transl-superscript-3 [179]) | |
231 | (defalias 'iso-transl-acute-accent [180]) | |
232 | (defalias 'iso-transl-micro-sign [181]) | |
233 | (defalias 'iso-transl-pilcrow [182]) | |
234 | (defalias 'iso-transl-middle-dot [183]) | |
235 | (defalias 'iso-transl-cedilla [184]) | |
236 | (defalias 'iso-transl-superscript-1 [185]) | |
237 | (defalias 'iso-transl-ordinal-indicator-masculine [186]) | |
238 | (defalias 'iso-transl-angle-right [187]) | |
239 | (defalias 'iso-transl-one-quarter [188]) | |
240 | (defalias 'iso-transl-one-half [189]) | |
241 | (defalias 'iso-transl-three-quarters [190]) | |
242 | (defalias 'iso-transl-inverted-question-mark [191]) | |
243 | (defalias 'iso-transl-A-grave [192]) | |
244 | (defalias 'iso-transl-A-acute [193]) | |
245 | (defalias 'iso-transl-A-caret [194]) | |
246 | (defalias 'iso-transl-A-tilde [195]) | |
247 | (defalias 'iso-transl-A-umlaut [196]) | |
ebdf0c33 RS |
248 | (defalias 'iso-transl-A-ring [197]) |
249 | (defalias 'iso-transl-AE [198]) | |
ff031514 RS |
250 | (defalias 'iso-transl-C-cedilla [199]) |
251 | (defalias 'iso-transl-E-grave [200]) | |
252 | (defalias 'iso-transl-E-acute [201]) | |
253 | (defalias 'iso-transl-E-caret [202]) | |
254 | (defalias 'iso-transl-E-umlaut [203]) | |
255 | (defalias 'iso-transl-I-grave [204]) | |
256 | (defalias 'iso-transl-I-acute [205]) | |
257 | (defalias 'iso-transl-I-caret [206]) | |
258 | (defalias 'iso-transl-I-umlaut [207]) | |
259 | (defalias 'iso-transl-D-stroke [208]) | |
260 | (defalias 'iso-transl-N-tilde [209]) | |
261 | (defalias 'iso-transl-O-grave [210]) | |
262 | (defalias 'iso-transl-O-acute [211]) | |
263 | (defalias 'iso-transl-O-caret [212]) | |
264 | (defalias 'iso-transl-O-tilde [213]) | |
265 | (defalias 'iso-transl-O-umlaut [214]) | |
266 | (defalias 'iso-transl-multiplication-sign [215]) | |
267 | (defalias 'iso-transl-O-slash [216]) | |
268 | (defalias 'iso-transl-U-grave [217]) | |
269 | (defalias 'iso-transl-U-acute [218]) | |
270 | (defalias 'iso-transl-U-caret [219]) | |
271 | (defalias 'iso-transl-U-umlaut [220]) | |
272 | (defalias 'iso-transl-Y-acute [221]) | |
273 | (defalias 'iso-transl-THORN [222]) | |
274 | (defalias 'iso-transl-ss [223]) | |
275 | (defalias 'iso-transl-a-grave [224]) | |
276 | (defalias 'iso-transl-a-acute [225]) | |
277 | (defalias 'iso-transl-a-caret [226]) | |
278 | (defalias 'iso-transl-a-tilde [227]) | |
279 | (defalias 'iso-transl-a-umlaut [228]) | |
ebdf0c33 RS |
280 | (defalias 'iso-transl-a-ring [229]) |
281 | (defalias 'iso-transl-ae [230]) | |
ff031514 RS |
282 | (defalias 'iso-transl-c-cedilla [231]) |
283 | (defalias 'iso-transl-e-grave [232]) | |
284 | (defalias 'iso-transl-e-acute [233]) | |
285 | (defalias 'iso-transl-E-caret [234]) | |
286 | (defalias 'iso-transl-e-umlaut [235]) | |
287 | (defalias 'iso-transl-i-grave [236]) | |
288 | (defalias 'iso-transl-i-acute [237]) | |
289 | (defalias 'iso-transl-I-caret [238]) | |
290 | (defalias 'iso-transl-i-umlaut [239]) | |
291 | (defalias 'iso-transl-d-stroke [240]) | |
292 | (defalias 'iso-transl-n-tilde [241]) | |
293 | (defalias 'iso-transl-o-grave [242]) | |
294 | (defalias 'iso-transl-o-acute [243]) | |
295 | (defalias 'iso-transl-O-caret [244]) | |
296 | (defalias 'iso-transl-o-tilde [245]) | |
297 | (defalias 'iso-transl-o-umlaut [246]) | |
298 | (defalias 'iso-transl-division-sign [247]) | |
299 | (defalias 'iso-transl-o-slash [248]) | |
300 | (defalias 'iso-transl-u-grave [249]) | |
301 | (defalias 'iso-transl-u-acute [250]) | |
302 | (defalias 'iso-transl-U-caret [251]) | |
303 | (defalias 'iso-transl-u-umlaut [252]) | |
304 | (defalias 'iso-transl-y-acute [253]) | |
305 | (defalias 'iso-transl-thorn [254]) | |
306 | (defalias 'iso-transl-y-umlaut [255]) | |
307 | ||
a36db1ea KH |
308 | ;; Language-specific translation lists. |
309 | (defvar iso-transl-language-alist | |
997d1bf0 | 310 | '(("Esperanto" |
a36db1ea KH |
311 | ("C" . [198]) |
312 | ("G" . [216]) | |
313 | ("H" . [166]) | |
314 | ("J" . [172]) | |
315 | ("S" . [222]) | |
316 | ("U" . [221]) | |
317 | ("c" . [230]) | |
318 | ("g" . [248]) | |
319 | ("h" . [182]) | |
320 | ("j" . [188]) | |
321 | ("s" . [254]) | |
997d1bf0 KH |
322 | ("u" . [253])) |
323 | ("French" | |
324 | ("C" . [199]) | |
325 | ("c" . [231])) | |
326 | ("German" | |
327 | ("A" . [196]) | |
328 | ("O" . [214]) | |
329 | ("U" . [220]) | |
330 | ("a" . [228]) | |
331 | ("o" . [246]) | |
332 | ("s" . [223]) | |
333 | ("u" . [252])) | |
334 | ("Portuguese" | |
335 | ("C" . [199]) | |
336 | ("c" . [231])) | |
337 | ("Spanish" | |
338 | ("!" . [161]) | |
339 | ("?" . [191]) | |
005f7830 KH |
340 | ("N" . [209]) |
341 | ("n" . [241])))) | |
a36db1ea KH |
342 | |
343 | (defvar iso-transl-ctl-x-8-map nil | |
344 | "Keymap for C-x 8 prefix.") | |
345 | (or iso-transl-ctl-x-8-map | |
79f86347 KH |
346 | (fset 'iso-transl-ctl-x-8-map |
347 | (setq iso-transl-ctl-x-8-map (make-sparse-keymap)))) | |
a36db1ea KH |
348 | (or key-translation-map |
349 | (setq key-translation-map (make-sparse-keymap))) | |
350 | (define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map) | |
351 | ||
352 | ;; For each entry in the alist, we'll make up to three ways to generate | |
353 | ;; the character in question: the prefix `C-x 8'; the ALT modifier on | |
354 | ;; the first key of the sequence; and (if applicable) replacing the first | |
355 | ;; key of the sequence with the corresponding dead key. For example, a | |
356 | ;; character associated with the string "~n" can be input with `C-x 8 ~ n' | |
997d1bf0 | 357 | ;; or `Alt-~ n' or `mute-asciitilde n'. |
a36db1ea | 358 | (defun iso-transl-define-keys (alist) |
97966523 | 359 | (while alist |
1dcbe239 | 360 | (let ((translated-vec (cdr (car alist)))) |
2d4ef3c0 RS |
361 | (define-key iso-transl-ctl-x-8-map (car (car alist)) translated-vec) |
362 | (let ((inchar (aref (car (car alist)) 0)) | |
363 | (vec (vconcat (car (car alist)))) | |
364 | (tail iso-transl-dead-key-alist)) | |
365 | (aset vec 0 (logior (aref vec 0) ?\A-\^@)) | |
366 | (define-key key-translation-map vec translated-vec) | |
367 | (define-key isearch-mode-map (vector (aref vec 0)) nil) | |
368 | (while tail | |
369 | (if (eq (car (car tail)) inchar) | |
370 | (let ((deadvec (copy-sequence vec)) | |
371 | (deadkey (cdr (car tail)))) | |
372 | (aset deadvec 0 deadkey) | |
373 | (define-key isearch-mode-map (vector deadkey) nil) | |
374 | (define-key key-translation-map deadvec translated-vec))) | |
375 | (setq tail (cdr tail))))) | |
e54d89f4 | 376 | (setq alist (cdr alist)))) |
a36db1ea KH |
377 | |
378 | (defun iso-transl-set-language (lang) | |
379 | (interactive (list (let ((completion-ignore-case t)) | |
380 | (completing-read "Set which language? " | |
381 | iso-transl-language-alist nil t)))) | |
382 | (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist)))) | |
383 | ||
384 | ||
385 | ;; The standard mapping comes automatically. You can partially overlay it | |
386 | ;; with a language-specific mapping by using `M-x iso-transl-set-language'. | |
387 | (iso-transl-define-keys iso-transl-char-map) | |
388 | ||
389 | (define-key isearch-mode-map "\C-x" nil) | |
390 | (define-key isearch-mode-map [?\C-x t] 'isearch-other-control-char) | |
391 | (define-key isearch-mode-map "\C-x8" nil) | |
63202134 | 392 | |
4579dd42 RS |
393 | |
394 | (provide 'iso-transl) | |
395 | ||
396 | ;;; iso-transl.el ends here |