]> code.delx.au - gnu-emacs/blob - lisp/international/iso-transl.el
Update copyright year to 2015
[gnu-emacs] / lisp / international / iso-transl.el
1 ;;; iso-transl.el --- keyboard input definitions for ISO 8859-1 -*- coding: utf-8 -*-
2
3 ;; Copyright (C) 1987, 1993-1999, 2001-2015 Free Software Foundation,
4 ;; Inc.
5
6 ;; Author: Howard Gayle
7 ;; Maintainer: emacs-devel@gnu.org
8 ;; Keywords: i18n
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
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
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
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).
32
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
39 ;;; Code:
40
41 ;;; Provide some binding for startup:
42 ;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map)
43 ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap)
44
45 (defvar iso-transl-dead-key-alist
46 '((?\' . mute-acute)
47 (?\` . mute-grave)
48 (?\" . mute-diaeresis)
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))
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.
74
75 (defvar iso-transl-char-map
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 ("~~" . [?¬])
195 ("' " . "'")
196 ("` " . "`")
197 ("\" " . "\"")
198 ("^ " . "^")
199 ("~ " . "~"))
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
205 ;; Language-specific translation lists.
206 (defvar iso-transl-language-alist
207 '(("Esperanto"
208 ("C" . [?Æ])
209 ("G" . [?Ø])
210 ("H" . [?¦])
211 ("J" . [?¬])
212 ("S" . [?Þ])
213 ("U" . [?Ý])
214 ("c" . [?æ])
215 ("g" . [?ø])
216 ("h" . [?¶])
217 ("j" . [?¼])
218 ("s" . [?þ])
219 ("u" . [?ý]))
220 ("French"
221 ("C" . [?Ç])
222 ("c" . [?ç]))
223 ("German"
224 ("A" . [?Ä])
225 ("O" . [?Ö])
226 ("U" . [?Ü])
227 ("a" . [?ä])
228 ("o" . [?ö])
229 ("s" . [?ß])
230 ("u" . [?ü]))
231 ("Portuguese"
232 ("C" . [?Ç])
233 ("c" . [?ç]))
234 ("Spanish"
235 ("!" . [?¡])
236 ("?" . [?¿])
237 ("N" . [?Ñ])
238 ("n" . [?ñ]))))
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
243 (fset 'iso-transl-ctl-x-8-map
244 (setq iso-transl-ctl-x-8-map (make-sparse-keymap))))
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'
254 ;; or `Alt-~ n' or `mute-asciitilde n'.
255 (defun iso-transl-define-keys (alist)
256 (while alist
257 (let ((translated-vec (cdr (car alist))))
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)))))
273 (setq alist (cdr alist))))
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
286 (provide 'iso-transl)
287
288 ;;; iso-transl.el ends here