root/trunk/lisp/international/iso-transl.el

Revision 4220, 8.4 kB (checked in by miyoshi, 9 months ago)

Sync up with Emacs22.2.

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