Commit | Line | Data |
---|---|---|
c38e0c97 | 1 | ;;; iso-transl.el --- keyboard input definitions for ISO 8859-1 -*- coding: utf-8 -*- |
5970f3d0 | 2 | |
ba318903 | 3 | ;; Copyright (C) 1987, 1993-1999, 2001-2014 Free Software Foundation, |
ab422c4d | 4 | ;; Inc. |
5970f3d0 RS |
5 | |
6 | ;; Author: Howard Gayle | |
34dc21db | 7 | ;; Maintainer: emacs-devel@gnu.org |
5970f3d0 RS |
8 | ;; Keywords: i18n |
9 | ||
10 | ;; This file is part of GNU Emacs. | |
11 | ||
4936186e | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
5970f3d0 | 13 | ;; it under the terms of the GNU General Public License as published by |
4936186e GM |
14 | ;; the Free Software Foundation, either version 3 of the License, or |
15 | ;; (at your option) any later version. | |
5970f3d0 RS |
16 | |
17 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | ;; GNU General Public License for more details. | |
21 | ||
22 | ;; You should have received a copy of the GNU General Public License | |
4936186e | 23 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
5970f3d0 | 24 | |
63202134 RS |
25 | ;;; Commentary: |
26 | ||
a36db1ea KH |
27 | ;; Loading this package defines three ways of entering the non-ASCII |
28 | ;; printable characters with codes above 127: the prefix C-x 8, or the | |
29 | ;; Alt key, or a dead accent key. For example, you can enter uppercase | |
30 | ;; A-umlaut as `C-x 8 " A' or `Alt-" A' (if you have an Alt key) or | |
31 | ;; `umlaut A' (if you have an umlaut/diaeresis key). | |
63202134 | 32 | |
b1fb5d1b KH |
33 | ;; C-x 8 is set up to autoload this package, |
34 | ;; but Alt keys and dead accent keys are only defined | |
35 | ;; once you have loaded the package. It is nontrivial | |
36 | ;; to make all of the Alt keys autoload, and it is not clear | |
37 | ;; that the dead accent keys SHOULD autoload this package. | |
38 | ||
5970f3d0 RS |
39 | ;;; Code: |
40 | ||
628eac44 | 41 | ;;; Provide some binding for startup: |
79f86347 | 42 | ;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map) |
628eac44 | 43 | ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap) |
a1506d29 | 44 | |
a36db1ea KH |
45 | (defvar iso-transl-dead-key-alist |
46 | '((?\' . mute-acute) | |
47 | (?\` . mute-grave) | |
48 | (?\" . mute-diaeresis) | |
97966523 RS |
49 | (?^ . mute-asciicircum) |
50 | (?\~ . mute-asciitilde) | |
51 | (?\' . dead-acute) | |
52 | (?\` . dead-grave) | |
53 | (?\" . dead-diaeresis) | |
54 | (?^ . dead-asciicircum) | |
55 | (?\~ . dead-asciitilde) | |
56 | (?^ . dead-circum) | |
57 | (?^ . dead-circumflex) | |
58 | (?\~ . dead-tilde) | |
59 | ;; Someone reports that these keys don't work if shifted. | |
60 | ;; This might fix it--no word yet. | |
61 | (?\' . S-dead-acute) | |
62 | (?\` . S-dead-grave) | |
63 | (?\" . S-dead-diaeresis) | |
64 | (?^ . S-dead-asciicircum) | |
65 | (?\~ . S-dead-asciitilde) | |
66 | (?^ . S-dead-circum) | |
67 | (?^ . S-dead-circumflex) | |
68 | (?\~ . S-dead-tilde)) | |
a36db1ea KH |
69 | "Mapping of ASCII characters to their corresponding dead-key symbols.") |
70 | ||
71 | ;; The two-character mnemonics are intended to be available in all languages. | |
72 | ;; The ones beginning with `*' have one-character synonyms, but a | |
73 | ;; language-specific table might override the short form for its own use. | |
ff031514 | 74 | |
63202134 | 75 | (defvar iso-transl-char-map |
c38e0c97 PE |
76 | '(("* " . [? ]) |
77 | (" " . [? ]) | |
78 | ("*!" . [?¡]) | |
79 | ("!" . [?¡]) | |
80 | ("\"\"" . [?¨]) | |
81 | ("\"A" . [?Ä]) | |
82 | ("\"E" . [?Ë]) | |
83 | ("\"I" . [?Ï]) | |
84 | ("\"O" . [?Ö]) | |
85 | ("\"U" . [?Ü]) | |
86 | ("\"a" . [?ä]) | |
87 | ("\"e" . [?ë]) | |
88 | ("\"i" . [?ï]) | |
89 | ("\"o" . [?ö]) | |
90 | ("\"s" . [?ß]) | |
91 | ("\"u" . [?ü]) | |
92 | ("\"y" . [?ÿ]) | |
93 | ("''" . [?´]) | |
94 | ("'A" . [?Á]) | |
95 | ("'E" . [?É]) | |
96 | ("'I" . [?Í]) | |
97 | ("'O" . [?Ó]) | |
98 | ("'U" . [?Ú]) | |
99 | ("'Y" . [?Ý]) | |
100 | ("'a" . [?á]) | |
101 | ("'e" . [?é]) | |
102 | ("'i" . [?í]) | |
103 | ("'o" . [?ó]) | |
104 | ("'u" . [?ú]) | |
105 | ("'y" . [?ý]) | |
106 | ("*$" . [?¤]) | |
107 | ("$" . [?¤]) | |
108 | ("*+" . [?±]) | |
109 | ("+" . [?±]) | |
110 | (",," . [?¸]) | |
111 | (",C" . [?Ç]) | |
112 | (",c" . [?ç]) | |
113 | ("*-" . [?]) | |
114 | ("-" . [?]) | |
115 | ("*." . [?·]) | |
116 | ("." . [?·]) | |
117 | ("//" . [?÷]) | |
118 | ("/A" . [?Å]) | |
119 | ("/E" . [?Æ]) | |
120 | ("/O" . [?Ø]) | |
121 | ("/a" . [?å]) | |
122 | ("/e" . [?æ]) | |
123 | ("/o" . [?ø]) | |
124 | ("1/2" . [?½]) | |
125 | ("1/4" . [?¼]) | |
126 | ("3/4" . [?¾]) | |
127 | ("*<" . [?«]) | |
128 | ("<" . [?«]) | |
129 | ("*=" . [?¯]) | |
130 | ("=" . [?¯]) | |
131 | ("*>" . [?»]) | |
132 | (">" . [?»]) | |
133 | ("*?" . [?¿]) | |
134 | ("?" . [?¿]) | |
135 | ("*C" . [?©]) | |
136 | ("C" . [?©]) | |
137 | ("*L" . [?£]) | |
138 | ("L" . [?£]) | |
139 | ("*P" . [?¶]) | |
140 | ("P" . [?¶]) | |
141 | ("*R" . [?®]) | |
142 | ("R" . [?®]) | |
143 | ("*S" . [?§]) | |
144 | ("S" . [?§]) | |
145 | ("*Y" . [?¥]) | |
146 | ("Y" . [?¥]) | |
147 | ("^1" . [?¹]) | |
148 | ("^2" . [?²]) | |
149 | ("^3" . [?³]) | |
150 | ("^A" . [?Â]) | |
151 | ("^E" . [?Ê]) | |
152 | ("^I" . [?Î]) | |
153 | ("^O" . [?Ô]) | |
154 | ("^U" . [?Û]) | |
155 | ("^a" . [?â]) | |
156 | ("^e" . [?ê]) | |
157 | ("^i" . [?î]) | |
158 | ("^o" . [?ô]) | |
159 | ("^u" . [?û]) | |
160 | ("_a" . [?ª]) | |
161 | ("_o" . [?º]) | |
162 | ("`A" . [?À]) | |
163 | ("`E" . [?È]) | |
164 | ("`I" . [?Ì]) | |
165 | ("`O" . [?Ò]) | |
166 | ("`U" . [?Ù]) | |
167 | ("`a" . [?à]) | |
168 | ("`e" . [?è]) | |
169 | ("`i" . [?ì]) | |
170 | ("`o" . [?ò]) | |
171 | ("`u" . [?ù]) | |
172 | ("*c" . [?¢]) | |
173 | ("c" . [?¢]) | |
174 | ("*o" . [?°]) | |
175 | ("o" . [?°]) | |
176 | ("*u" . [?µ]) | |
177 | ("u" . [?µ]) | |
178 | ("*m" . [?µ]) | |
179 | ("m" . [?µ]) | |
180 | ("*x" . [?×]) | |
181 | ("x" . [?×]) | |
182 | ("*|" . [?¦]) | |
183 | ("|" . [?¦]) | |
184 | ("~A" . [?Ã]) | |
185 | ("~D" . [?Ð]) | |
186 | ("~N" . [?Ñ]) | |
187 | ("~O" . [?Õ]) | |
188 | ("~T" . [?Þ]) | |
189 | ("~a" . [?ã]) | |
190 | ("~d" . [?ð]) | |
191 | ("~n" . [?ñ]) | |
192 | ("~o" . [?õ]) | |
193 | ("~t" . [?þ]) | |
194 | ("~~" . [?¬]) | |
378df08c RS |
195 | ("' " . "'") |
196 | ("` " . "`") | |
197 | ("\" " . "\"") | |
198 | ("^ " . "^") | |
199 | ("~ " . "~")) | |
63202134 RS |
200 | "Alist of character translations for entering ISO characters. |
201 | Each element has the form (STRING . VECTOR). | |
202 | The sequence STRING of ASCII chars translates into the | |
203 | sequence VECTOR. (VECTOR is normally one character long.)") | |
204 | ||
a36db1ea KH |
205 | ;; Language-specific translation lists. |
206 | (defvar iso-transl-language-alist | |
997d1bf0 | 207 | '(("Esperanto" |
c38e0c97 PE |
208 | ("C" . [?Æ]) |
209 | ("G" . [?Ø]) | |
210 | ("H" . [?¦]) | |
211 | ("J" . [?¬]) | |
212 | ("S" . [?Þ]) | |
213 | ("U" . [?Ý]) | |
214 | ("c" . [?æ]) | |
215 | ("g" . [?ø]) | |
216 | ("h" . [?¶]) | |
217 | ("j" . [?¼]) | |
218 | ("s" . [?þ]) | |
219 | ("u" . [?ý])) | |
997d1bf0 | 220 | ("French" |
c38e0c97 PE |
221 | ("C" . [?Ç]) |
222 | ("c" . [?ç])) | |
997d1bf0 | 223 | ("German" |
c38e0c97 PE |
224 | ("A" . [?Ä]) |
225 | ("O" . [?Ö]) | |
226 | ("U" . [?Ü]) | |
227 | ("a" . [?ä]) | |
228 | ("o" . [?ö]) | |
229 | ("s" . [?ß]) | |
230 | ("u" . [?ü])) | |
997d1bf0 | 231 | ("Portuguese" |
c38e0c97 PE |
232 | ("C" . [?Ç]) |
233 | ("c" . [?ç])) | |
997d1bf0 | 234 | ("Spanish" |
c38e0c97 PE |
235 | ("!" . [?¡]) |
236 | ("?" . [?¿]) | |
237 | ("N" . [?Ñ]) | |
238 | ("n" . [?ñ])))) | |
a36db1ea KH |
239 | |
240 | (defvar iso-transl-ctl-x-8-map nil | |
241 | "Keymap for C-x 8 prefix.") | |
242 | (or iso-transl-ctl-x-8-map | |
79f86347 KH |
243 | (fset 'iso-transl-ctl-x-8-map |
244 | (setq iso-transl-ctl-x-8-map (make-sparse-keymap)))) | |
a36db1ea KH |
245 | (or key-translation-map |
246 | (setq key-translation-map (make-sparse-keymap))) | |
247 | (define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map) | |
248 | ||
249 | ;; For each entry in the alist, we'll make up to three ways to generate | |
250 | ;; the character in question: the prefix `C-x 8'; the ALT modifier on | |
251 | ;; the first key of the sequence; and (if applicable) replacing the first | |
252 | ;; key of the sequence with the corresponding dead key. For example, a | |
253 | ;; character associated with the string "~n" can be input with `C-x 8 ~ n' | |
997d1bf0 | 254 | ;; or `Alt-~ n' or `mute-asciitilde n'. |
a36db1ea | 255 | (defun iso-transl-define-keys (alist) |
97966523 | 256 | (while alist |
1dcbe239 | 257 | (let ((translated-vec (cdr (car alist)))) |
2d4ef3c0 RS |
258 | (define-key iso-transl-ctl-x-8-map (car (car alist)) translated-vec) |
259 | (let ((inchar (aref (car (car alist)) 0)) | |
260 | (vec (vconcat (car (car alist)))) | |
261 | (tail iso-transl-dead-key-alist)) | |
262 | (aset vec 0 (logior (aref vec 0) ?\A-\^@)) | |
263 | (define-key key-translation-map vec translated-vec) | |
264 | (define-key isearch-mode-map (vector (aref vec 0)) nil) | |
265 | (while tail | |
266 | (if (eq (car (car tail)) inchar) | |
267 | (let ((deadvec (copy-sequence vec)) | |
268 | (deadkey (cdr (car tail)))) | |
269 | (aset deadvec 0 deadkey) | |
270 | (define-key isearch-mode-map (vector deadkey) nil) | |
271 | (define-key key-translation-map deadvec translated-vec))) | |
272 | (setq tail (cdr tail))))) | |
e54d89f4 | 273 | (setq alist (cdr alist)))) |
a36db1ea KH |
274 | |
275 | (defun iso-transl-set-language (lang) | |
276 | (interactive (list (let ((completion-ignore-case t)) | |
277 | (completing-read "Set which language? " | |
278 | iso-transl-language-alist nil t)))) | |
279 | (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist)))) | |
280 | ||
281 | ||
282 | ;; The standard mapping comes automatically. You can partially overlay it | |
283 | ;; with a language-specific mapping by using `M-x iso-transl-set-language'. | |
284 | (iso-transl-define-keys iso-transl-char-map) | |
285 | ||
4579dd42 RS |
286 | (provide 'iso-transl) |
287 | ||
288 | ;;; iso-transl.el ends here |