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