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