1 ;;; iso-transl.el --- keyboard input for ISO 10646 chars -*- coding: utf-8 -*-
3 ;; Copyright (C) 1987, 1993-1999, 2001-2016 Free Software Foundation,
6 ;; Author: Howard Gayle
7 ;; Maintainer: emacs-devel@gnu.org
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 of the License, or
15 ;; (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>.
27 ;; Loading this package defines three ways of entering the non-ASCII
28 ;; printable characters with codes above 127: the prefix C-x 8, or the
29 ;; Alt key, or a dead accent key. For example, you can enter uppercase
30 ;; A-umlaut as `C-x 8 " A' or `Alt-" A' (if you have an Alt key) or
31 ;; `umlaut A' (if you have an umlaut/diaeresis key).
33 ;; C-x 8 is set up to autoload this package,
34 ;; but Alt keys and dead accent keys are only defined
35 ;; once you have loaded the package. It is nontrivial
36 ;; to make all of the Alt keys autoload, and it is not clear
37 ;; that the dead accent keys SHOULD autoload this package.
39 ;; This package supports all characters defined by ISO 8859-1, along
40 ;; with a few other ISO 10646 characters commonly used in English and
45 ;;; Provide some binding for startup:
46 ;;;###autoload (define-key key-translation-map "\C-x8" 'iso-transl-ctl-x-8-map)
47 ;;;###autoload (autoload 'iso-transl-ctl-x-8-map "iso-transl" "Keymap for C-x 8 prefix." t 'keymap)
49 (defvar iso-transl-dead-key-alist
52 (?
\" . mute-diaeresis
)
53 (?^ . mute-asciicircum
)
54 (?\~ . mute-asciitilde
)
57 (?
\" . dead-diaeresis
)
58 (?^ . dead-asciicircum
)
59 (?\~ . dead-asciitilde
)
61 (?^ . dead-circumflex
)
63 ;; Someone reports that these keys don't work if shifted.
64 ;; This might fix it--no word yet.
67 (?
\" . S-dead-diaeresis
)
68 (?^ . S-dead-asciicircum
)
69 (?\~ . S-dead-asciitilde
)
71 (?^ . S-dead-circumflex
)
73 "Mapping of ASCII characters to their corresponding dead-key symbols.")
75 ;; The two-character mnemonics are intended to be available in all languages.
76 ;; The ones beginning with `*' have one-character synonyms, but a
77 ;; language-specific table might override the short form for its own use.
79 (defvar iso-transl-char-map
229 "Alist of character translations for entering ISO characters.
230 Each element has the form (STRING . VECTOR).
231 The sequence STRING of ASCII chars translates into the
232 sequence VECTOR. (VECTOR is normally one character long.)")
234 ;; Language-specific translation lists.
235 (defvar iso-transl-language-alist
269 (defvar iso-transl-ctl-x-8-map nil
270 "Keymap for C-x 8 prefix.")
271 (or iso-transl-ctl-x-8-map
272 (fset 'iso-transl-ctl-x-8-map
273 (setq iso-transl-ctl-x-8-map
(make-sparse-keymap))))
274 (or key-translation-map
275 (setq key-translation-map
(make-sparse-keymap)))
276 (define-key key-translation-map
"\C-x8" iso-transl-ctl-x-8-map
)
278 ;; For each entry in the alist, we'll make up to three ways to generate
279 ;; the character in question: the prefix `C-x 8'; the ALT modifier on
280 ;; the first key of the sequence; and (if applicable) replacing the first
281 ;; key of the sequence with the corresponding dead key. For example, a
282 ;; character associated with the string "~n" can be input with `C-x 8 ~ n'
283 ;; or `Alt-~ n' or `mute-asciitilde n'.
284 (defun iso-transl-define-keys (alist)
286 (let ((translated-vec (cdr (car alist
))))
287 (define-key iso-transl-ctl-x-8-map
(car (car alist
)) translated-vec
)
288 (let ((inchar (aref (car (car alist
)) 0))
289 (vec (vconcat (car (car alist
))))
290 (tail iso-transl-dead-key-alist
))
291 (aset vec
0 (logior (aref vec
0) ?\A-\^
@))
292 (define-key key-translation-map vec translated-vec
)
293 (define-key isearch-mode-map
(vector (aref vec
0)) nil
)
295 (if (eq (car (car tail
)) inchar
)
296 (let ((deadvec (copy-sequence vec
))
297 (deadkey (cdr (car tail
))))
298 (aset deadvec
0 deadkey
)
299 (define-key isearch-mode-map
(vector deadkey
) nil
)
300 (define-key key-translation-map deadvec translated-vec
)))
301 (setq tail
(cdr tail
)))))
302 (setq alist
(cdr alist
))))
304 (defun iso-transl-set-language (lang)
305 (interactive (list (let ((completion-ignore-case t
))
306 (completing-read "Set which language? "
307 iso-transl-language-alist nil t
))))
308 (iso-transl-define-keys (cdr (assoc lang iso-transl-language-alist
))))
311 ;; The standard mapping comes automatically. You can partially overlay it
312 ;; with a language-specific mapping by using `M-x iso-transl-set-language'.
313 (iso-transl-define-keys iso-transl-char-map
)
315 (provide 'iso-transl
)
317 ;;; iso-transl.el ends here