1 ;;; iso-transl.el --- keyboard input definitions for ISO 8859-1 -*- coding: iso-8859-1 -*-
3 ;; Copyright (C) 1987, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001
4 ;; 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: Howard Gayle
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, or (at your option)
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; 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.
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).
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.
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)
48 (defvar iso-transl-dead-key-alist
51 (?
\" . mute-diaeresis
)
52 (?^ . mute-asciicircum
)
53 (?\~ . mute-asciitilde
)
56 (?
\" . dead-diaeresis
)
57 (?^ . dead-asciicircum
)
58 (?\~ . dead-asciitilde
)
60 (?^ . dead-circumflex
)
62 ;; Someone reports that these keys don't work if shifted.
63 ;; This might fix it--no word yet.
66 (?
\" . S-dead-diaeresis
)
67 (?^ . S-dead-asciicircum
)
68 (?\~ . S-dead-asciitilde
)
70 (?^ . S-dead-circumflex
)
72 "Mapping of ASCII characters to their corresponding dead-key symbols.")
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.
78 (defvar iso-transl-char-map
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.)")
208 ;; Language-specific translation lists.
209 (defvar iso-transl-language-alist
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
)
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)
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
)
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
))))
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
))))
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
)
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
)
294 (provide 'iso-transl
)
296 ;;; arch-tag: 034cfedf-7ebd-461d-bcd0-5c79e6dc0b61
297 ;;; iso-transl.el ends here