1 ;;; iso-transl.el --- keyboard input definitions for ISO 8859-1 -*- coding: iso-8859-1 -*-
3 ;; Copyright (C) 1987, 1993-1999, 2001-2011 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 (or key-translation-map (setq key-translation-map (make-sparse-keymap)))
42 ;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map)
43 ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap)
45 (defvar iso-transl-dead-key-alist
48 (?\" . mute-diaeresis)
49 (?^ . mute-asciicircum)
50 (?\~ . mute-asciitilde)
53 (?\" . dead-diaeresis)
54 (?^ . dead-asciicircum)
55 (?\~ . dead-asciitilde)
57 (?^ . dead-circumflex)
59 ;; Someone reports that these keys don't work if shifted.
60 ;; This might fix it--no word yet.
63 (?\" . S-dead-diaeresis)
64 (?^ . S-dead-asciicircum)
65 (?\~ . S-dead-asciitilde)
67 (?^ . S-dead-circumflex)
69 "Mapping of ASCII characters to their corresponding dead-key symbols.")
71 ;; The two-character mnemonics are intended to be available in all languages.
72 ;; The ones beginning with `*' have one-character synonyms, but a
73 ;; language-specific table might override the short form for its own use.
75 (defvar iso-transl-char-map
200 "Alist of character translations for entering ISO characters.
201 Each element has the form (STRING . VECTOR).
202 The sequence STRING of ASCII chars translates into the
203 sequence VECTOR. (VECTOR is normally one character long.)")
205 ;; Language-specific translation lists.
206 (defvar iso-transl-language-alist
240 (defvar iso-transl-ctl-x-8-map nil
241 "Keymap for C-x 8 prefix.")
242 (or iso-transl-ctl-x-8-map
243 (fset 'iso-transl-ctl-x-8-map
244 (setq iso-transl-ctl-x-8-map (make-sparse-keymap))))
245 (or key-translation-map
246 (setq key-translation-map (make-sparse-keymap)))
247 (define-key key-translation-map "\C-x8" iso-transl-ctl-x-8-map)
249 ;; For each entry in the alist, we'll make up to three ways to generate
250 ;; the character in question: the prefix `C-x 8'; the ALT modifier on
251 ;; the first key of the sequence; and (if applicable) replacing the first
252 ;; key of the sequence with the corresponding dead key. For example, a
253 ;; character associated with the string "~n" can be input with `C-x 8 ~ n'
254 ;; or `Alt-~ n' or `mute-asciitilde n'.
255 (defun iso-transl-define-keys (alist)
257 (let ((translated-vec (cdr (car alist))))
258 (define-key iso-transl-ctl-x-8-map (car (car alist)) translated-vec)
259 (let ((inchar (aref (car (car alist)) 0))
260 (vec (vconcat (car (car alist))))
261 (tail iso-transl-dead-key-alist))
262 (aset vec 0 (logior (aref vec 0) ?\A-\^@))
263 (define-key key-translation-map vec translated-vec)
264 (define-key isearch-mode-map (vector (aref vec 0)) nil)
266 (if (eq (car (car tail)) inchar)
267 (let ((deadvec (copy-sequence vec))
268 (deadkey (cdr (car tail))))
269 (aset deadvec 0 deadkey)
270 (define-key isearch-mode-map (vector deadkey) nil)
271 (define-key key-translation-map deadvec translated-vec)))
272 (setq tail (cdr tail)))))
273 (setq alist (cdr alist))))
275 (defun iso-transl-set-language (lang)
276 (interactive (list (let ((completion-ignore-case t))
277 (completing-read "Set which language? "
278 iso-transl-language-alist nil t))))
279 (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist))))
282 ;; The standard mapping comes automatically. You can partially overlay it
283 ;; with a language-specific mapping by using `M-x iso-transl-set-language'.
284 (iso-transl-define-keys iso-transl-char-map)
286 (define-key isearch-mode-map "\C-x" nil)
287 (define-key isearch-mode-map [?\C-x t] 'isearch-other-control-char)
288 (define-key isearch-mode-map "\C-x8" nil)
291 (provide 'iso-transl)
293 ;;; iso-transl.el ends here