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
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/>.
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.
40 ;;; Provide some binding for startup:
41 ;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map)
42 ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap)
44 (defvar iso-transl-dead-key-alist
47 (?
\" . mute-diaeresis
)
48 (?^ . mute-asciicircum
)
49 (?\~ . mute-asciitilde
)
52 (?
\" . dead-diaeresis
)
53 (?^ . dead-asciicircum
)
54 (?\~ . dead-asciitilde
)
56 (?^ . dead-circumflex
)
58 ;; Someone reports that these keys don't work if shifted.
59 ;; This might fix it--no word yet.
62 (?
\" . S-dead-diaeresis
)
63 (?^ . S-dead-asciicircum
)
64 (?\~ . S-dead-asciitilde
)
66 (?^ . S-dead-circumflex
)
68 "Mapping of ASCII characters to their corresponding dead-key symbols.")
70 ;; The two-character mnemonics are intended to be available in all languages.
71 ;; The ones beginning with `*' have one-character synonyms, but a
72 ;; language-specific table might override the short form for its own use.
74 (defvar iso-transl-char-map
199 "Alist of character translations for entering ISO characters.
200 Each element has the form (STRING . VECTOR).
201 The sequence STRING of ASCII chars translates into the
202 sequence VECTOR. (VECTOR is normally one character long.)")
204 ;; Language-specific translation lists.
205 (defvar iso-transl-language-alist
239 (defvar iso-transl-ctl-x-8-map nil
240 "Keymap for C-x 8 prefix.")
241 (or iso-transl-ctl-x-8-map
242 (fset 'iso-transl-ctl-x-8-map
243 (setq iso-transl-ctl-x-8-map
(make-sparse-keymap))))
244 (or key-translation-map
245 (setq key-translation-map
(make-sparse-keymap)))
246 (define-key key-translation-map
"\C-x8" iso-transl-ctl-x-8-map
)
248 ;; For each entry in the alist, we'll make up to three ways to generate
249 ;; the character in question: the prefix `C-x 8'; the ALT modifier on
250 ;; the first key of the sequence; and (if applicable) replacing the first
251 ;; key of the sequence with the corresponding dead key. For example, a
252 ;; character associated with the string "~n" can be input with `C-x 8 ~ n'
253 ;; or `Alt-~ n' or `mute-asciitilde n'.
254 (defun iso-transl-define-keys (alist)
256 (let ((translated-vec (cdr (car alist
))))
257 (define-key iso-transl-ctl-x-8-map
(car (car alist
)) translated-vec
)
258 (let ((inchar (aref (car (car alist
)) 0))
259 (vec (vconcat (car (car alist
))))
260 (tail iso-transl-dead-key-alist
))
261 (aset vec
0 (logior (aref vec
0) ?\A-\^
@))
262 (define-key key-translation-map vec translated-vec
)
263 (define-key isearch-mode-map
(vector (aref vec
0)) nil
)
265 (if (eq (car (car tail
)) inchar
)
266 (let ((deadvec (copy-sequence vec
))
267 (deadkey (cdr (car tail
))))
268 (aset deadvec
0 deadkey
)
269 (define-key isearch-mode-map
(vector deadkey
) nil
)
270 (define-key key-translation-map deadvec translated-vec
)))
271 (setq tail
(cdr tail
)))))
272 (setq alist
(cdr alist
))))
274 (defun iso-transl-set-language (lang)
275 (interactive (list (let ((completion-ignore-case t
))
276 (completing-read "Set which language? "
277 iso-transl-language-alist nil t
))))
278 (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist
))))
281 ;; The standard mapping comes automatically. You can partially overlay it
282 ;; with a language-specific mapping by using `M-x iso-transl-set-language'.
283 (iso-transl-define-keys iso-transl-char-map
)
285 (provide 'iso-transl
)
287 ;;; iso-transl.el ends here