Add 2008 to copyright years.
[bpt/emacs.git] / 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, 1996, 1997, 1998, 1999, 2001
4 ;; 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5
6 ;; Author: Howard Gayle
7 ;; Maintainer: FSF
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, or (at your option)
15 ;; 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; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
26
27 ;;; Commentary:
28
29 ;; Loading this package defines three ways of entering the non-ASCII
30 ;; printable characters with codes above 127: the prefix C-x 8, or the
31 ;; Alt key, or a dead accent key. For example, you can enter uppercase
32 ;; A-umlaut as `C-x 8 " A' or `Alt-" A' (if you have an Alt key) or
33 ;; `umlaut A' (if you have an umlaut/diaeresis key).
34
35 ;; C-x 8 is set up to autoload this package,
36 ;; but Alt keys and dead accent keys are only defined
37 ;; once you have loaded the package. It is nontrivial
38 ;; to make all of the Alt keys autoload, and it is not clear
39 ;; that the dead accent keys SHOULD autoload this package.
40
41 ;;; Code:
42
43 ;;; Provide some binding for startup:
44 ;;;###autoload (or key-translation-map (setq key-translation-map (make-sparse-keymap)))
45 ;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map)
46 ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap)
47
48 (defvar iso-transl-dead-key-alist
49 '((?\' . mute-acute)
50 (?\` . mute-grave)
51 (?\" . mute-diaeresis)
52 (?^ . mute-asciicircum)
53 (?\~ . mute-asciitilde)
54 (?\' . dead-acute)
55 (?\` . dead-grave)
56 (?\" . dead-diaeresis)
57 (?^ . dead-asciicircum)
58 (?\~ . dead-asciitilde)
59 (?^ . dead-circum)
60 (?^ . dead-circumflex)
61 (?\~ . dead-tilde)
62 ;; Someone reports that these keys don't work if shifted.
63 ;; This might fix it--no word yet.
64 (?\' . S-dead-acute)
65 (?\` . S-dead-grave)
66 (?\" . S-dead-diaeresis)
67 (?^ . S-dead-asciicircum)
68 (?\~ . S-dead-asciitilde)
69 (?^ . S-dead-circum)
70 (?^ . S-dead-circumflex)
71 (?\~ . S-dead-tilde))
72 "Mapping of ASCII characters to their corresponding dead-key symbols.")
73
74 ;; The two-character mnemonics are intended to be available in all languages.
75 ;; The ones beginning with `*' have one-character synonyms, but a
76 ;; language-specific table might override the short form for its own use.
77
78 (defvar iso-transl-char-map
79 '(("* " . [])
80 (" " . [])
81 ("*!" . [])
82 ("!" . [])
83 ("\"\"" . [])
84 ("\"A" . [])
85 ("\"E" . [])
86 ("\"I" . [])
87 ("\"O" . [])
88 ("\"U" . [])
89 ("\"a" . [])
90 ("\"e" . [])
91 ("\"i" . [])
92 ("\"o" . [])
93 ("\"s" . [])
94 ("\"u" . [])
95 ("\"y" . [?ÿ])
96 ("''" . [])
97 ("'A" . [])
98 ("'E" . [])
99 ("'I" . [])
100 ("'O" . [])
101 ("'U" . [])
102 ("'Y" . [])
103 ("'a" . [])
104 ("'e" . [])
105 ("'i" . [])
106 ("'o" . [])
107 ("'u" . [])
108 ("'y" . [])
109 ("*$" . [])
110 ("$" . [])
111 ("*+" . [])
112 ("+" . [])
113 (",," . [])
114 (",C" . [])
115 (",c" . [])
116 ("*-" . [])
117 ("-" . [])
118 ("*." . [])
119 ("." . [])
120 ("//" . [])
121 ("/A" . [])
122 ("/E" . [])
123 ("/O" . [])
124 ("/a" . [])
125 ("/e" . [])
126 ("/o" . [])
127 ("1/2" . [])
128 ("1/4" . [])
129 ("3/4" . [])
130 ("*<" . [])
131 ("<" . [])
132 ("*=" . [])
133 ("=" . [])
134 ("*>" . [])
135 (">" . [])
136 ("*?" . [?¿])
137 ("?" . [?¿])
138 ("*C" . [])
139 ("C" . [])
140 ("*L" . [])
141 ("L" . [])
142 ("*P" . [])
143 ("P" . [])
144 ("*R" . [])
145 ("R" . [])
146 ("*S" . [])
147 ("S" . [])
148 ("*Y" . [])
149 ("Y" . [])
150 ("^1" . [])
151 ("^2" . [])
152 ("^3" . [])
153 ("^A" . [])
154 ("^E" . [])
155 ("^I" . [])
156 ("^O" . [])
157 ("^U" . [])
158 ("^a" . [])
159 ("^e" . [])
160 ("^i" . [])
161 ("^o" . [])
162 ("^u" . [])
163 ("_a" . [])
164 ("_o" . [])
165 ("`A" . [])
166 ("`E" . [])
167 ("`I" . [])
168 ("`O" . [])
169 ("`U" . [])
170 ("`a" . [])
171 ("`e" . [])
172 ("`i" . [])
173 ("`o" . [])
174 ("`u" . [])
175 ("*c" . [])
176 ("c" . [])
177 ("*o" . [])
178 ("o" . [])
179 ("*u" . [])
180 ("u" . [])
181 ("*m" . [])
182 ("m" . [])
183 ("*x" . [])
184 ("x" . [])
185 ("*|" . [])
186 ("|" . [])
187 ("~A" . [])
188 ("~D" . [])
189 ("~N" . [])
190 ("~O" . [])
191 ("~T" . [])
192 ("~a" . [])
193 ("~d" . [])
194 ("~n" . [])
195 ("~o" . [])
196 ("~t" . [])
197 ("~~" . [])
198 ("' " . "'")
199 ("` " . "`")
200 ("\" " . "\"")
201 ("^ " . "^")
202 ("~ " . "~"))
203 "Alist of character translations for entering ISO characters.
204 Each element has the form (STRING . VECTOR).
205 The sequence STRING of ASCII chars translates into the
206 sequence VECTOR. (VECTOR is normally one character long.)")
207
208 ;; Language-specific translation lists.
209 (defvar iso-transl-language-alist
210 '(("Esperanto"
211 ("C" . [])
212 ("G" . [])
213 ("H" . [])
214 ("J" . [])
215 ("S" . [])
216 ("U" . [])
217 ("c" . [])
218 ("g" . [])
219 ("h" . [])
220 ("j" . [])
221 ("s" . [])
222 ("u" . []))
223 ("French"
224 ("C" . [])
225 ("c" . []))
226 ("German"
227 ("A" . [])
228 ("O" . [])
229 ("U" . [])
230 ("a" . [])
231 ("o" . [])
232 ("s" . [])
233 ("u" . []))
234 ("Portuguese"
235 ("C" . [])
236 ("c" . []))
237 ("Spanish"
238 ("!" . [])
239 ("?" . [?¿])
240 ("N" . [])
241 ("n" . []))))
242
243 (defvar iso-transl-ctl-x-8-map nil
244 "Keymap for C-x 8 prefix.")
245 (or iso-transl-ctl-x-8-map
246 (fset 'iso-transl-ctl-x-8-map
247 (setq iso-transl-ctl-x-8-map (make-sparse-keymap))))
248 (or key-translation-map
249 (setq key-translation-map (make-sparse-keymap)))
250 (define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map)
251
252 ;; For each entry in the alist, we'll make up to three ways to generate
253 ;; the character in question: the prefix `C-x 8'; the ALT modifier on
254 ;; the first key of the sequence; and (if applicable) replacing the first
255 ;; key of the sequence with the corresponding dead key. For example, a
256 ;; character associated with the string "~n" can be input with `C-x 8 ~ n'
257 ;; or `Alt-~ n' or `mute-asciitilde n'.
258 (defun iso-transl-define-keys (alist)
259 (while alist
260 (let ((translated-vec (cdr (car alist))))
261 (define-key iso-transl-ctl-x-8-map (car (car alist)) translated-vec)
262 (let ((inchar (aref (car (car alist)) 0))
263 (vec (vconcat (car (car alist))))
264 (tail iso-transl-dead-key-alist))
265 (aset vec 0 (logior (aref vec 0) ?\A-\^@))
266 (define-key key-translation-map vec translated-vec)
267 (define-key isearch-mode-map (vector (aref vec 0)) nil)
268 (while tail
269 (if (eq (car (car tail)) inchar)
270 (let ((deadvec (copy-sequence vec))
271 (deadkey (cdr (car tail))))
272 (aset deadvec 0 deadkey)
273 (define-key isearch-mode-map (vector deadkey) nil)
274 (define-key key-translation-map deadvec translated-vec)))
275 (setq tail (cdr tail)))))
276 (setq alist (cdr alist))))
277
278 (defun iso-transl-set-language (lang)
279 (interactive (list (let ((completion-ignore-case t))
280 (completing-read "Set which language? "
281 iso-transl-language-alist nil t))))
282 (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist))))
283
284
285 ;; The standard mapping comes automatically. You can partially overlay it
286 ;; with a language-specific mapping by using `M-x iso-transl-set-language'.
287 (iso-transl-define-keys iso-transl-char-map)
288
289 (define-key isearch-mode-map "\C-x" nil)
290 (define-key isearch-mode-map [?\C-x t] 'isearch-other-control-char)
291 (define-key isearch-mode-map "\C-x8" nil)
292
293
294 (provide 'iso-transl)
295
296 ;;; arch-tag: 034cfedf-7ebd-461d-bcd0-5c79e6dc0b61
297 ;;; iso-transl.el ends here