]> code.delx.au - gnu-emacs/blob - lisp/international/iso-transl.el
Nuke arch-tags.
[gnu-emacs] / 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, 2009, 2010, 2011 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 of the License, or
15 ;; (at your option) 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. If not, see <http://www.gnu.org/licenses/>.
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 ;; C-x 8 is set up to autoload this package,
34 ;; but Alt keys and dead accent keys are only defined
35 ;; once you have loaded the package. It is nontrivial
36 ;; to make all of the Alt keys autoload, and it is not clear
37 ;; that the dead accent keys SHOULD autoload this package.
38
39 ;;; Code:
40
41 ;;; Provide some binding for startup:
42 ;;;###autoload (or key-translation-map (setq key-translation-map (make-sparse-keymap)))
43 ;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map)
44 ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap)
45
46 (defvar iso-transl-dead-key-alist
47 '((?\' . mute-acute)
48 (?\` . mute-grave)
49 (?\" . mute-diaeresis)
50 (?^ . mute-asciicircum)
51 (?\~ . mute-asciitilde)
52 (?\' . dead-acute)
53 (?\` . dead-grave)
54 (?\" . dead-diaeresis)
55 (?^ . dead-asciicircum)
56 (?\~ . dead-asciitilde)
57 (?^ . dead-circum)
58 (?^ . dead-circumflex)
59 (?\~ . dead-tilde)
60 ;; Someone reports that these keys don't work if shifted.
61 ;; This might fix it--no word yet.
62 (?\' . S-dead-acute)
63 (?\` . S-dead-grave)
64 (?\" . S-dead-diaeresis)
65 (?^ . S-dead-asciicircum)
66 (?\~ . S-dead-asciitilde)
67 (?^ . S-dead-circum)
68 (?^ . S-dead-circumflex)
69 (?\~ . S-dead-tilde))
70 "Mapping of ASCII characters to their corresponding dead-key symbols.")
71
72 ;; The two-character mnemonics are intended to be available in all languages.
73 ;; The ones beginning with `*' have one-character synonyms, but a
74 ;; language-specific table might override the short form for its own use.
75
76 (defvar iso-transl-char-map
77 '(("* " . [? ])
78 (" " . [? ])
79 ("*!" . [?¡])
80 ("!" . [?¡])
81 ("\"\"" . [?¨])
82 ("\"A" . [?Ä])
83 ("\"E" . [?Ë])
84 ("\"I" . [?Ï])
85 ("\"O" . [?Ö])
86 ("\"U" . [?Ü])
87 ("\"a" . [?ä])
88 ("\"e" . [?ë])
89 ("\"i" . [?ï])
90 ("\"o" . [?ö])
91 ("\"s" . [?ß])
92 ("\"u" . [?ü])
93 ("\"y" . [?ÿ])
94 ("''" . [?´])
95 ("'A" . [?Á])
96 ("'E" . [?É])
97 ("'I" . [?Í])
98 ("'O" . [?Ó])
99 ("'U" . [?Ú])
100 ("'Y" . [?Ý])
101 ("'a" . [?á])
102 ("'e" . [?é])
103 ("'i" . [?í])
104 ("'o" . [?ó])
105 ("'u" . [?ú])
106 ("'y" . [?ý])
107 ("*$" . [?¤])
108 ("$" . [?¤])
109 ("*+" . [?±])
110 ("+" . [?±])
111 (",," . [?¸])
112 (",C" . [?Ç])
113 (",c" . [?ç])
114 ("*-" . [?­])
115 ("-" . [?­])
116 ("*." . [?·])
117 ("." . [?·])
118 ("//" . [?÷])
119 ("/A" . [?Å])
120 ("/E" . [?Æ])
121 ("/O" . [?Ø])
122 ("/a" . [?å])
123 ("/e" . [?æ])
124 ("/o" . [?ø])
125 ("1/2" . [?½])
126 ("1/4" . [?¼])
127 ("3/4" . [?¾])
128 ("*<" . [?«])
129 ("<" . [?«])
130 ("*=" . [?¯])
131 ("=" . [?¯])
132 ("*>" . [?»])
133 (">" . [?»])
134 ("*?" . [?¿])
135 ("?" . [?¿])
136 ("*C" . [?©])
137 ("C" . [?©])
138 ("*L" . [?£])
139 ("L" . [?£])
140 ("*P" . [?¶])
141 ("P" . [?¶])
142 ("*R" . [?®])
143 ("R" . [?®])
144 ("*S" . [?§])
145 ("S" . [?§])
146 ("*Y" . [?¥])
147 ("Y" . [?¥])
148 ("^1" . [?¹])
149 ("^2" . [?²])
150 ("^3" . [?³])
151 ("^A" . [?Â])
152 ("^E" . [?Ê])
153 ("^I" . [?Î])
154 ("^O" . [?Ô])
155 ("^U" . [?Û])
156 ("^a" . [?â])
157 ("^e" . [?ê])
158 ("^i" . [?î])
159 ("^o" . [?ô])
160 ("^u" . [?û])
161 ("_a" . [?ª])
162 ("_o" . [?º])
163 ("`A" . [?À])
164 ("`E" . [?È])
165 ("`I" . [?Ì])
166 ("`O" . [?Ò])
167 ("`U" . [?Ù])
168 ("`a" . [?à])
169 ("`e" . [?è])
170 ("`i" . [?ì])
171 ("`o" . [?ò])
172 ("`u" . [?ù])
173 ("*c" . [?¢])
174 ("c" . [?¢])
175 ("*o" . [?°])
176 ("o" . [?°])
177 ("*u" . [?µ])
178 ("u" . [?µ])
179 ("*m" . [?µ])
180 ("m" . [?µ])
181 ("*x" . [?×])
182 ("x" . [?×])
183 ("*|" . [?¦])
184 ("|" . [?¦])
185 ("~A" . [?Ã])
186 ("~D" . [?Ð])
187 ("~N" . [?Ñ])
188 ("~O" . [?Õ])
189 ("~T" . [?Þ])
190 ("~a" . [?ã])
191 ("~d" . [?ð])
192 ("~n" . [?ñ])
193 ("~o" . [?õ])
194 ("~t" . [?þ])
195 ("~~" . [?¬])
196 ("' " . "'")
197 ("` " . "`")
198 ("\" " . "\"")
199 ("^ " . "^")
200 ("~ " . "~"))
201 "Alist of character translations for entering ISO characters.
202 Each element has the form (STRING . VECTOR).
203 The sequence STRING of ASCII chars translates into the
204 sequence VECTOR. (VECTOR is normally one character long.)")
205
206 ;; Language-specific translation lists.
207 (defvar iso-transl-language-alist
208 '(("Esperanto"
209 ("C" . [?Æ])
210 ("G" . [?Ø])
211 ("H" . [?¦])
212 ("J" . [?¬])
213 ("S" . [?Þ])
214 ("U" . [?Ý])
215 ("c" . [?æ])
216 ("g" . [?ø])
217 ("h" . [?¶])
218 ("j" . [?¼])
219 ("s" . [?þ])
220 ("u" . [?ý]))
221 ("French"
222 ("C" . [?Ç])
223 ("c" . [?ç]))
224 ("German"
225 ("A" . [?Ä])
226 ("O" . [?Ö])
227 ("U" . [?Ü])
228 ("a" . [?ä])
229 ("o" . [?ö])
230 ("s" . [?ß])
231 ("u" . [?ü]))
232 ("Portuguese"
233 ("C" . [?Ç])
234 ("c" . [?ç]))
235 ("Spanish"
236 ("!" . [?¡])
237 ("?" . [?¿])
238 ("N" . [?Ñ])
239 ("n" . [?ñ]))))
240
241 (defvar iso-transl-ctl-x-8-map nil
242 "Keymap for C-x 8 prefix.")
243 (or iso-transl-ctl-x-8-map
244 (fset 'iso-transl-ctl-x-8-map
245 (setq iso-transl-ctl-x-8-map (make-sparse-keymap))))
246 (or key-translation-map
247 (setq key-translation-map (make-sparse-keymap)))
248 (define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map)
249
250 ;; For each entry in the alist, we'll make up to three ways to generate
251 ;; the character in question: the prefix `C-x 8'; the ALT modifier on
252 ;; the first key of the sequence; and (if applicable) replacing the first
253 ;; key of the sequence with the corresponding dead key. For example, a
254 ;; character associated with the string "~n" can be input with `C-x 8 ~ n'
255 ;; or `Alt-~ n' or `mute-asciitilde n'.
256 (defun iso-transl-define-keys (alist)
257 (while alist
258 (let ((translated-vec (cdr (car alist))))
259 (define-key iso-transl-ctl-x-8-map (car (car alist)) translated-vec)
260 (let ((inchar (aref (car (car alist)) 0))
261 (vec (vconcat (car (car alist))))
262 (tail iso-transl-dead-key-alist))
263 (aset vec 0 (logior (aref vec 0) ?\A-\^@))
264 (define-key key-translation-map vec translated-vec)
265 (define-key isearch-mode-map (vector (aref vec 0)) nil)
266 (while tail
267 (if (eq (car (car tail)) inchar)
268 (let ((deadvec (copy-sequence vec))
269 (deadkey (cdr (car tail))))
270 (aset deadvec 0 deadkey)
271 (define-key isearch-mode-map (vector deadkey) nil)
272 (define-key key-translation-map deadvec translated-vec)))
273 (setq tail (cdr tail)))))
274 (setq alist (cdr alist))))
275
276 (defun iso-transl-set-language (lang)
277 (interactive (list (let ((completion-ignore-case t))
278 (completing-read "Set which language? "
279 iso-transl-language-alist nil t))))
280 (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist))))
281
282
283 ;; The standard mapping comes automatically. You can partially overlay it
284 ;; with a language-specific mapping by using `M-x iso-transl-set-language'.
285 (iso-transl-define-keys iso-transl-char-map)
286
287 (define-key isearch-mode-map "\C-x" nil)
288 (define-key isearch-mode-map [?\C-x t] 'isearch-other-control-char)
289 (define-key isearch-mode-map "\C-x8" nil)
290
291
292 (provide 'iso-transl)
293
294 ;;; iso-transl.el ends here