Merge branch 'master' into comment-cache
[emacs.git] / lisp / international / iso-transl.el
bloba665a39b63c37fd77db785142c614f7376666978
1 ;;; iso-transl.el --- keyboard input for ISO 10646 chars -*- coding: utf-8 -*-
3 ;; Copyright (C) 1987, 1993-1999, 2001-2017 Free Software Foundation,
4 ;; Inc.
6 ;; Author: Howard Gayle
7 ;; Maintainer: emacs-devel@gnu.org
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 ;; 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.
43 ;;; Code:
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)
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.")
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.
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.)")
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" . []))))
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)
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))))
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))))
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)
315 (provide 'iso-transl)
317 ;;; iso-transl.el ends here