1 ;;; iso-transl.el --- keyboard input definitions for ISO 8859-1 -*- coding: iso-8859-1 -*-
3 ;; Copyright (C) 1987, 1993, 1994, 1995, 2001 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 2, or (at your option)
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; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; Loading this package defines three ways of entering the non-ASCII
29 ;; printable characters with codes above 127: the prefix C-x 8, or the
30 ;; Alt key, or a dead accent key. For example, you can enter uppercase
31 ;; A-umlaut as `C-x 8 " A' or `Alt-" A' (if you have an Alt key) or
32 ;; `umlaut A' (if you have an umlaut/diaeresis key).
34 ;; C-x 8 is set up to autoload this package,
35 ;; but Alt keys and dead accent keys are only defined
36 ;; once you have loaded the package. It is nontrivial
37 ;; to make all of the Alt keys autoload, and it is not clear
38 ;; that the dead accent keys SHOULD autoload this package.
42 ;;; Provide some binding for startup:
43 ;;;###autoload (or key-translation-map (setq key-translation-map (make-sparse-keymap)))
44 ;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map)
45 ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap)
47 (defvar iso-transl-dead-key-alist
50 (?
\" . mute-diaeresis
)
51 (?^ . mute-asciicircum
)
52 (?\~ . mute-asciitilde
)
55 (?
\" . dead-diaeresis
)
56 (?^ . dead-asciicircum
)
57 (?\~ . dead-asciitilde
)
59 (?^ . dead-circumflex
)
61 ;; Someone reports that these keys don't work if shifted.
62 ;; This might fix it--no word yet.
65 (?
\" . S-dead-diaeresis
)
66 (?^ . S-dead-asciicircum
)
67 (?\~ . S-dead-asciitilde
)
69 (?^ . S-dead-circumflex
)
71 "Mapping of ASCII characters to their corresponding dead-key symbols.")
73 ;; The two-character mnemonics are intended to be available in all languages.
74 ;; The ones beginning with `*' have one-character synonyms, but a
75 ;; language-specific table might override the short form for its own use.
77 (defvar iso-transl-char-map
202 "Alist of character translations for entering ISO characters.
203 Each element has the form (STRING . VECTOR).
204 The sequence STRING of ASCII chars translates into the
205 sequence VECTOR. (VECTOR is normally one character long.)")
207 ;; Language-specific translation lists.
208 (defvar iso-transl-language-alist
242 (defvar iso-transl-ctl-x-8-map nil
243 "Keymap for C-x 8 prefix.")
244 (or iso-transl-ctl-x-8-map
245 (fset 'iso-transl-ctl-x-8-map
246 (setq iso-transl-ctl-x-8-map
(make-sparse-keymap))))
247 (or key-translation-map
248 (setq key-translation-map
(make-sparse-keymap)))
249 (define-key key-translation-map
"\C-x8" iso-transl-ctl-x-8-map
)
251 ;; For each entry in the alist, we'll make up to three ways to generate
252 ;; the character in question: the prefix `C-x 8'; the ALT modifier on
253 ;; the first key of the sequence; and (if applicable) replacing the first
254 ;; key of the sequence with the corresponding dead key. For example, a
255 ;; character associated with the string "~n" can be input with `C-x 8 ~ n'
256 ;; or `Alt-~ n' or `mute-asciitilde n'.
257 (defun iso-transl-define-keys (alist)
259 (let ((translated-vec (cdr (car alist
))))
260 (define-key iso-transl-ctl-x-8-map
(car (car alist
)) translated-vec
)
261 (let ((inchar (aref (car (car alist
)) 0))
262 (vec (vconcat (car (car alist
))))
263 (tail iso-transl-dead-key-alist
))
264 (aset vec
0 (logior (aref vec
0) ?\A-\^
@))
265 (define-key key-translation-map vec translated-vec
)
266 (define-key isearch-mode-map
(vector (aref vec
0)) nil
)
268 (if (eq (car (car tail
)) inchar
)
269 (let ((deadvec (copy-sequence vec
))
270 (deadkey (cdr (car tail
))))
271 (aset deadvec
0 deadkey
)
272 (define-key isearch-mode-map
(vector deadkey
) nil
)
273 (define-key key-translation-map deadvec translated-vec
)))
274 (setq tail
(cdr tail
)))))
275 (setq alist
(cdr alist
))))
277 (defun iso-transl-set-language (lang)
278 (interactive (list (let ((completion-ignore-case t
))
279 (completing-read "Set which language? "
280 iso-transl-language-alist nil t
))))
281 (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist
))))
284 ;; The standard mapping comes automatically. You can partially overlay it
285 ;; with a language-specific mapping by using `M-x iso-transl-set-language'.
286 (iso-transl-define-keys iso-transl-char-map
)
288 (define-key isearch-mode-map
"\C-x" nil
)
289 (define-key isearch-mode-map
[?\C-x t
] 'isearch-other-control-char
)
290 (define-key isearch-mode-map
"\C-x8" nil
)
293 (provide 'iso-transl
)
295 ;;; iso-transl.el ends here