Trailing whitepace deleted.
[emacs.git] / lisp / international / iso-transl.el
blobea5f9ff53aea73d7453b7301f707a04022070642
1 ;;; iso-transl.el --- keyboard input definitions for ISO 8859-1 -*- coding: iso-8859-1 -*-
3 ;; Copyright (C) 1987, 1993, 1994, 1995, 2001 Free Software Foundation, Inc.
5 ;; Author: Howard Gayle
6 ;; Maintainer: FSF
7 ;; Keywords: i18n
9 ;; This file is part of GNU Emacs.
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.
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.
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.
26 ;;; Commentary:
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).
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.
40 ;;; Code:
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)
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.")
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.
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.)")
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" . []))))
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)
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))))
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))))
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)
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)
293 (provide 'iso-transl)
295 ;;; iso-transl.el ends here