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