Fix permissions handling (CVE-2010-0825).
[emacs.git] / lisp / international / iso-transl.el
blobb11a7a2930db8b13512ceeaddb09400e59074e76
1 ;;; iso-transl.el --- keyboard input definitions for ISO 8859-1 -*- coding: iso-8859-1 -*-
3 ;; Copyright (C) 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001
4 ;; 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Howard Gayle
7 ;; Maintainer: FSF
8 ;; Keywords: i18n
10 ;; This file is part of GNU Emacs.
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.
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.
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/>.
25 ;;; Commentary:
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).
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.
39 ;;; Code:
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)
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.")
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.
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.)")
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" . []))))
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)
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))))
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))))
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)
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)
292 (provide 'iso-transl)
294 ;; arch-tag: 034cfedf-7ebd-461d-bcd0-5c79e6dc0b61
295 ;;; iso-transl.el ends here