Mon Nov 6 18:01:01 1995 Dave Love <d.love@dl.ac.uk>
[bpt/emacs.git] / lisp / international / iso-transl.el
1 ;;; iso-transl.el --- keyboard input definitions for ISO 8859/1.
2
3 ;; Copyright (C) 1987, 1993, 1994, 1995 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
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
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 ;;; Code:
34
35 (defvar iso-transl-dead-key-alist
36 '((?\' . mute-acute)
37 (?\` . mute-grave)
38 (?\" . mute-diaeresis)
39 (?\^ . mute-asciicircum)
40 (?\~ . mute-asciitilde))
41 "Mapping of ASCII characters to their corresponding dead-key symbols.")
42
43 ;; Some X servers use these alternate names.
44 (or key-translation-map
45 (setq key-translation-map (make-sparse-keymap)))
46 (define-key key-translation-map [dead-acute] [mute-acute])
47 (define-key key-translation-map [dead-grave] [mute-grave])
48 (define-key key-translation-map [dead-diaeresis] [mute-diaeresis])
49 (define-key key-translation-map [dead-asciicircum] [mute-asciicircum])
50 (define-key key-translation-map [dead-asciitilde] [mute-asciitilde])
51 ;; Someone reports that these keys don't work if shifted.
52 ;; This might fix it--no word yet.
53 (define-key key-translation-map [S-dead-acute] [mute-acute])
54 (define-key key-translation-map [S-dead-grave] [mute-grave])
55 (define-key key-translation-map [S-dead-diaeresis] [mute-diaeresis])
56 (define-key key-translation-map [S-dead-asciicircum] [mute-asciicircum])
57 (define-key key-translation-map [S-dead-asciitilde] [mute-asciitilde])
58
59 ;; The two-character mnemonics are intended to be available in all languages.
60 ;; The ones beginning with `*' have one-character synonyms, but a
61 ;; language-specific table might override the short form for its own use.
62 (defvar iso-transl-char-map
63 '(("* " . [160])(" " . [160])
64 ("*!" . [161])("!" . [161])
65 ("\"\"" . [168])
66 ("\"A" . [196])
67 ("\"E" . [203])
68 ("\"I" . [207])
69 ("\"O" . [214])
70 ("\"U" . [220])
71 ("\"a" . [228])
72 ("\"e" . [235])
73 ("\"i" . [239])
74 ("\"o" . [246])
75 ("\"s" . [223])
76 ("\"u" . [252])
77 ("\"y" . [255])
78 ("''" . [180])
79 ("'A" . [193])
80 ("'E" . [201])
81 ("'I" . [205])
82 ("'O" . [211])
83 ("'U" . [218])
84 ("'Y" . [221])
85 ("'a" . [225])
86 ("'e" . [233])
87 ("'i" . [237])
88 ("'o" . [243])
89 ("'u" . [250])
90 ("'y" . [253])
91 ("*$" . [164])("$" . [164])
92 ("*+" . [177])("+" . [177])
93 (",," . [184])
94 (",C" . [199])
95 (",c" . [231])
96 ("*-" . [173])("-" . [173])
97 ("*." . [183])("." . [183])
98 ("//" . [247])
99 ("/A" . [197])
100 ("/E" . [198])
101 ("/O" . [216])
102 ("/a" . [229])
103 ("/e" . [230])
104 ("/o" . [248])
105 ("1/2" . [189])
106 ("1/4" . [188])
107 ("3/4" . [190])
108 ("*<" . [171])("<" . [171])
109 ("*=" . [175])("=" . [175])
110 ("*>" . [187])(">" . [187])
111 ("*?" . [191])("?" . [191])
112 ("*C" . [169])("C" . [169])
113 ("*L" . [163])("L" . [163])
114 ("*P" . [182])("P" . [182])
115 ("*R" . [174])("R" . [174])
116 ("*S" . [167])("S" . [167])
117 ("*Y" . [165])("Y" . [165])
118 ("^1" . [185])
119 ("^2" . [178])
120 ("^3" . [179])
121 ("^A" . [194])
122 ("^E" . [202])
123 ("^I" . [206])
124 ("^O" . [212])
125 ("^U" . [219])
126 ("^a" . [226])
127 ("^e" . [234])
128 ("^i" . [238])
129 ("^o" . [244])
130 ("^u" . [251])
131 ("_a" . [170])
132 ("_o" . [186])
133 ("`A" . [192])
134 ("`E" . [200])
135 ("`I" . [204])
136 ("`O" . [210])
137 ("`U" . [217])
138 ("`a" . [224])
139 ("`e" . [232])
140 ("`i" . [236])
141 ("`o" . [242])
142 ("`u" . [249])
143 ("*c" . [162])("c" . [162])
144 ("*o" . [176])("o" . [176])
145 ("*u" . [181])("u" . [181])
146 ("*m" . [181])("m" . [181])
147 ("*x" . [215])("x" . [215])
148 ("*|" . [166])("|" . [166])
149 ("~A" . [195])
150 ("~D" . [208])
151 ("~N" . [209])
152 ("~O" . [213])
153 ("~T" . [222])
154 ("~a" . [227])
155 ("~d" . [240])
156 ("~n" . [241])
157 ("~o" . [245])
158 ("~t" . [254])
159 ("~~" . [172]))
160 "Alist of character translations for entering ISO characters.
161 Each element has the form (STRING . VECTOR).
162 The sequence STRING of ASCII chars translates into the
163 sequence VECTOR. (VECTOR is normally one character long.)")
164
165 ;; Language-specific translation lists.
166 (defvar iso-transl-language-alist
167 '(("Esperanto"
168 ("C" . [198])
169 ("G" . [216])
170 ("H" . [166])
171 ("J" . [172])
172 ("S" . [222])
173 ("U" . [221])
174 ("c" . [230])
175 ("g" . [248])
176 ("h" . [182])
177 ("j" . [188])
178 ("s" . [254])
179 ("u" . [253]))
180 ("French"
181 ("C" . [199])
182 ("c" . [231]))
183 ("German"
184 ("A" . [196])
185 ("O" . [214])
186 ("U" . [220])
187 ("a" . [228])
188 ("o" . [246])
189 ("s" . [223])
190 ("u" . [252]))
191 ("Portuguese"
192 ("C" . [199])
193 ("c" . [231]))
194 ("Spanish"
195 ("!" . [161])
196 ("?" . [191])
197 ("N" . [241])
198 ("n" . [209]))))
199
200 (defvar iso-transl-ctl-x-8-map nil
201 "Keymap for C-x 8 prefix.")
202 (or iso-transl-ctl-x-8-map
203 (setq iso-transl-ctl-x-8-map (make-sparse-keymap)))
204 (or key-translation-map
205 (setq key-translation-map (make-sparse-keymap)))
206 (define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map)
207
208 ;; For each entry in the alist, we'll make up to three ways to generate
209 ;; the character in question: the prefix `C-x 8'; the ALT modifier on
210 ;; the first key of the sequence; and (if applicable) replacing the first
211 ;; key of the sequence with the corresponding dead key. For example, a
212 ;; character associated with the string "~n" can be input with `C-x 8 ~ n'
213 ;; or `Alt-~ n' or `mute-asciitilde n'.
214 (defun iso-transl-define-keys (alist)
215 (while alist
216 (define-key iso-transl-ctl-x-8-map (car (car alist)) (cdr (car alist)))
217 (let ((vec (vconcat (car (car alist))))
218 (deadpair (assq (aref (car (car alist)) 0)
219 iso-transl-dead-key-alist)))
220 (aset vec 0 (logior (aref vec 0) ?\A-\^@))
221 (define-key key-translation-map vec (cdr (car alist)))
222 (define-key isearch-mode-map (vector (aref vec 0)) nil)
223 (if deadpair
224 (let ((deadvec (copy-sequence vec)))
225 (aset deadvec 0 (cdr deadpair))
226 (define-key isearch-mode-map (vector (aref deadvec 0)) nil)
227 (define-key key-translation-map deadvec (cdr (car alist))))))
228 (setq alist (cdr alist))))
229
230 (defun iso-transl-set-language (lang)
231 (interactive (list (let ((completion-ignore-case t))
232 (completing-read "Set which language? "
233 iso-transl-language-alist nil t))))
234 (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist))))
235
236
237 ;; The standard mapping comes automatically. You can partially overlay it
238 ;; with a language-specific mapping by using `M-x iso-transl-set-language'.
239 (iso-transl-define-keys iso-transl-char-map)
240
241 (define-key isearch-mode-map "\C-x" nil)
242 (define-key isearch-mode-map [?\C-x t] 'isearch-other-control-char)
243 (define-key isearch-mode-map "\C-x8" nil)
244
245
246 (provide 'iso-transl)
247
248 ;;; iso-transl.el ends here