]> code.delx.au - gnu-emacs/blob - lisp/international/iso-transl.el
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-72
[gnu-emacs] / lisp / international / iso-transl.el
1 ;;; iso-transl.el --- keyboard input definitions for ISO 8859-1 -*- coding: iso-8859-1 -*-
2
3 ;; Copyright (C) 1987, 1993, 1994, 1995, 2001 Free Software Foundation, Inc.
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
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.
25
26 ;;; Commentary:
27
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).
33
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
40 ;;; Code:
41
42 ;;; Provide some binding for startup:
43 ;;;###autoload (or key-translation-map (setq key-translation-map (make-sparse-keymap)))
44 ;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map)
45 ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap)
46
47 (defvar iso-transl-dead-key-alist
48 '((?\' . mute-acute)
49 (?\` . mute-grave)
50 (?\" . mute-diaeresis)
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))
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.
76
77 (defvar iso-transl-char-map
78 '(("* " . [? ])
79 (" " . [? ])
80 ("*!" . [?¡])
81 ("!" . [?¡])
82 ("\"\"" . [?¨])
83 ("\"A" . [?Ä])
84 ("\"E" . [?Ë])
85 ("\"I" . [?Ï])
86 ("\"O" . [?Ö])
87 ("\"U" . [?Ü])
88 ("\"a" . [?ä])
89 ("\"e" . [?ë])
90 ("\"i" . [?ï])
91 ("\"o" . [?ö])
92 ("\"s" . [?ß])
93 ("\"u" . [?ü])
94 ("\"y" . [?ÿ])
95 ("''" . [?´])
96 ("'A" . [?Á])
97 ("'E" . [?É])
98 ("'I" . [?Í])
99 ("'O" . [?Ó])
100 ("'U" . [?Ú])
101 ("'Y" . [?Ý])
102 ("'a" . [?á])
103 ("'e" . [?é])
104 ("'i" . [?í])
105 ("'o" . [?ó])
106 ("'u" . [?ú])
107 ("'y" . [?ý])
108 ("*$" . [?¤])
109 ("$" . [?¤])
110 ("*+" . [?±])
111 ("+" . [?±])
112 (",," . [?¸])
113 (",C" . [?Ç])
114 (",c" . [?ç])
115 ("*-" . [?­])
116 ("-" . [?­])
117 ("*." . [?·])
118 ("." . [?·])
119 ("//" . [?÷])
120 ("/A" . [?Å])
121 ("/E" . [?Æ])
122 ("/O" . [?Ø])
123 ("/a" . [?å])
124 ("/e" . [?æ])
125 ("/o" . [?ø])
126 ("1/2" . [?½])
127 ("1/4" . [?¼])
128 ("3/4" . [?¾])
129 ("*<" . [?«])
130 ("<" . [?«])
131 ("*=" . [?¯])
132 ("=" . [?¯])
133 ("*>" . [?»])
134 (">" . [?»])
135 ("*?" . [?¿])
136 ("?" . [?¿])
137 ("*C" . [?©])
138 ("C" . [?©])
139 ("*L" . [?£])
140 ("L" . [?£])
141 ("*P" . [?¶])
142 ("P" . [?¶])
143 ("*R" . [?®])
144 ("R" . [?®])
145 ("*S" . [?§])
146 ("S" . [?§])
147 ("*Y" . [?¥])
148 ("Y" . [?¥])
149 ("^1" . [?¹])
150 ("^2" . [?²])
151 ("^3" . [?³])
152 ("^A" . [?Â])
153 ("^E" . [?Ê])
154 ("^I" . [?Î])
155 ("^O" . [?Ô])
156 ("^U" . [?Û])
157 ("^a" . [?â])
158 ("^e" . [?ê])
159 ("^i" . [?î])
160 ("^o" . [?ô])
161 ("^u" . [?û])
162 ("_a" . [?ª])
163 ("_o" . [?º])
164 ("`A" . [?À])
165 ("`E" . [?È])
166 ("`I" . [?Ì])
167 ("`O" . [?Ò])
168 ("`U" . [?Ù])
169 ("`a" . [?à])
170 ("`e" . [?è])
171 ("`i" . [?ì])
172 ("`o" . [?ò])
173 ("`u" . [?ù])
174 ("*c" . [?¢])
175 ("c" . [?¢])
176 ("*o" . [?°])
177 ("o" . [?°])
178 ("*u" . [?µ])
179 ("u" . [?µ])
180 ("*m" . [?µ])
181 ("m" . [?µ])
182 ("*x" . [?×])
183 ("x" . [?×])
184 ("*|" . [?¦])
185 ("|" . [?¦])
186 ("~A" . [?Ã])
187 ("~D" . [?Ð])
188 ("~N" . [?Ñ])
189 ("~O" . [?Õ])
190 ("~T" . [?Þ])
191 ("~a" . [?ã])
192 ("~d" . [?ð])
193 ("~n" . [?ñ])
194 ("~o" . [?õ])
195 ("~t" . [?þ])
196 ("~~" . [?¬])
197 ("' " . "'")
198 ("` " . "`")
199 ("\" " . "\"")
200 ("^ " . "^")
201 ("~ " . "~"))
202 "Alist of character translations for entering ISO characters.
203 Each element has the form (STRING . VECTOR).
204 The sequence STRING of ASCII chars translates into the
205 sequence VECTOR. (VECTOR is normally one character long.)")
206
207 ;; Language-specific translation lists.
208 (defvar iso-transl-language-alist
209 '(("Esperanto"
210 ("C" . [?Æ])
211 ("G" . [?Ø])
212 ("H" . [?¦])
213 ("J" . [?¬])
214 ("S" . [?Þ])
215 ("U" . [?Ý])
216 ("c" . [?æ])
217 ("g" . [?ø])
218 ("h" . [?¶])
219 ("j" . [?¼])
220 ("s" . [?þ])
221 ("u" . [?ý]))
222 ("French"
223 ("C" . [?Ç])
224 ("c" . [?ç]))
225 ("German"
226 ("A" . [?Ä])
227 ("O" . [?Ö])
228 ("U" . [?Ü])
229 ("a" . [?ä])
230 ("o" . [?ö])
231 ("s" . [?ß])
232 ("u" . [?ü]))
233 ("Portuguese"
234 ("C" . [?Ç])
235 ("c" . [?ç]))
236 ("Spanish"
237 ("!" . [?¡])
238 ("?" . [?¿])
239 ("N" . [?Ñ])
240 ("n" . [?ñ]))))
241
242 (defvar iso-transl-ctl-x-8-map nil
243 "Keymap for C-x 8 prefix.")
244 (or iso-transl-ctl-x-8-map
245 (fset 'iso-transl-ctl-x-8-map
246 (setq iso-transl-ctl-x-8-map (make-sparse-keymap))))
247 (or key-translation-map
248 (setq key-translation-map (make-sparse-keymap)))
249 (define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map)
250
251 ;; For each entry in the alist, we'll make up to three ways to generate
252 ;; the character in question: the prefix `C-x 8'; the ALT modifier on
253 ;; the first key of the sequence; and (if applicable) replacing the first
254 ;; key of the sequence with the corresponding dead key. For example, a
255 ;; character associated with the string "~n" can be input with `C-x 8 ~ n'
256 ;; or `Alt-~ n' or `mute-asciitilde n'.
257 (defun iso-transl-define-keys (alist)
258 (while alist
259 (let ((translated-vec (cdr (car alist))))
260 (define-key iso-transl-ctl-x-8-map (car (car alist)) translated-vec)
261 (let ((inchar (aref (car (car alist)) 0))
262 (vec (vconcat (car (car alist))))
263 (tail iso-transl-dead-key-alist))
264 (aset vec 0 (logior (aref vec 0) ?\A-\^@))
265 (define-key key-translation-map vec translated-vec)
266 (define-key isearch-mode-map (vector (aref vec 0)) nil)
267 (while tail
268 (if (eq (car (car tail)) inchar)
269 (let ((deadvec (copy-sequence vec))
270 (deadkey (cdr (car tail))))
271 (aset deadvec 0 deadkey)
272 (define-key isearch-mode-map (vector deadkey) nil)
273 (define-key key-translation-map deadvec translated-vec)))
274 (setq tail (cdr tail)))))
275 (setq alist (cdr alist))))
276
277 (defun iso-transl-set-language (lang)
278 (interactive (list (let ((completion-ignore-case t))
279 (completing-read "Set which language? "
280 iso-transl-language-alist nil t))))
281 (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist))))
282
283
284 ;; The standard mapping comes automatically. You can partially overlay it
285 ;; with a language-specific mapping by using `M-x iso-transl-set-language'.
286 (iso-transl-define-keys iso-transl-char-map)
287
288 (define-key isearch-mode-map "\C-x" nil)
289 (define-key isearch-mode-map [?\C-x t] 'isearch-other-control-char)
290 (define-key isearch-mode-map "\C-x8" nil)
291
292
293 (provide 'iso-transl)
294
295 ;;; arch-tag: 034cfedf-7ebd-461d-bcd0-5c79e6dc0b61
296 ;;; iso-transl.el ends here