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