annotate lisp/international/encoded-kb.el @ 50313:59ddec11881f

Initial revision
author Simon Josefsson <jas@extundo.com>
date Wed, 26 Mar 2003 11:48:32 +0000
parents 0d8b17d428b5
children 695cf19ef79e d7ddb3e565de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37238
diff changeset
1 ;;; encoded-kb.el --- handler to input multibyte characters encoded somehow
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
18377
8b4a66c66dd6 Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents: 17985
diff changeset
4 ;; Licensed to the Free Software Foundation.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; any later version.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
21 ;; Boston, MA 02111-1307, USA.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37238
diff changeset
23 ;;; Commentary:
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37238
diff changeset
24
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37238
diff changeset
25 ;;; Code:
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37238
diff changeset
26
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
27 (defconst encoded-kbd-mode-map (make-sparse-keymap)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 "Keymap for Encoded-kbd minor mode.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;; Subsidiary keymaps for handling ISO2022 escape sequences.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 (defvar encoded-kbd-iso2022-esc-map
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 (let ((map (make-sparse-keymap)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 (define-key map "$" 'encoded-kbd-iso2022-esc-dollar-prefix)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35 (define-key map "(" 'encoded-kbd-iso2022-designation-prefix)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 (define-key map ")" 'encoded-kbd-iso2022-designation-prefix)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 (define-key map "," 'encoded-kbd-iso2022-designation-prefix)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 (define-key map "-" 'encoded-kbd-iso2022-designation-prefix)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 "Keymap for handling ESC code in Encoded-kbd mode.")
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
41 (fset 'encoded-kbd-iso2022-esc-prefix encoded-kbd-iso2022-esc-map)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 (defvar encoded-kbd-iso2022-esc-dollar-map
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 (let ((map (make-sparse-keymap)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 (define-key map "(" 'encoded-kbd-iso2022-designation-prefix)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 (define-key map ")" 'encoded-kbd-iso2022-designation-prefix)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 (define-key map "," 'encoded-kbd-iso2022-designation-prefix)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 (define-key map "-" 'encoded-kbd-iso2022-designation-prefix)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 (define-key map "@" 'encoded-kbd-iso2022-designation)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 (define-key map "A" 'encoded-kbd-iso2022-designation)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 (define-key map "B" 'encoded-kbd-iso2022-designation)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 map)
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
53 "Keymap for handling ESC $ sequence in Encoded-kbd mode.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 (fset 'encoded-kbd-iso2022-esc-dollar-prefix
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 encoded-kbd-iso2022-esc-dollar-map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 (defvar encoded-kbd-iso2022-designation-map
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 (let ((map (make-sparse-keymap))
29267
00ff62c583fe (encoded-kbd-iso2022-designation-map): Pay attention to that
Kenichi Handa <handa@m17n.org>
parents: 27816
diff changeset
59 (l charset-list)
00ff62c583fe (encoded-kbd-iso2022-designation-map): Pay attention to that
Kenichi Handa <handa@m17n.org>
parents: 27816
diff changeset
60 final-char)
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
61 (while l
29267
00ff62c583fe (encoded-kbd-iso2022-designation-map): Pay attention to that
Kenichi Handa <handa@m17n.org>
parents: 27816
diff changeset
62 (setq final-char (charset-iso-final-char (car l)))
29268
4165d44fcd68 (encoded-kbd-iso2022-designation-map): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 29267
diff changeset
63 (if (> final-char 0)
29267
00ff62c583fe (encoded-kbd-iso2022-designation-map): Pay attention to that
Kenichi Handa <handa@m17n.org>
parents: 27816
diff changeset
64 (define-key map (char-to-string final-char)
00ff62c583fe (encoded-kbd-iso2022-designation-map): Pay attention to that
Kenichi Handa <handa@m17n.org>
parents: 27816
diff changeset
65 'encoded-kbd-iso2022-designation))
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
66 (setq l (cdr l)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 "Keymap for handling ISO2022 designation sequence in Encoded-kbd mode.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 (fset 'encoded-kbd-iso2022-designation-prefix
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 encoded-kbd-iso2022-designation-map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 (defvar encoded-kbd-iso2022-non-ascii-map
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 (let ((map (make-keymap))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 (i 32))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 (while (< i 128)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76 (define-key map (char-to-string i) 'encoded-kbd-self-insert-iso2022-7bit)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 (setq i (1+ i)))
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
78 (define-key map "\e" 'encoded-kbd-iso2022-esc-prefix)
19434
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
79 (setq i 160)
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
80 (while (< i 256)
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
81 (define-key map (vector i) 'encoded-kbd-handle-8bit)
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
82 (setq i (1+ i)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83 map)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 "Keymap for handling non-ASCII character set in Encoded-kbd mode.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 ;; One of the symbols `sjis', `iso2022-7', `iso2022-8', or `big5' to
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 ;; denote what kind of coding-system we are now handling in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 ;; Encoded-kbd mode.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 (defvar encoded-kbd-coding nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
91 ;; Keep information of designation state of ISO2022 encoding. When
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
92 ;; Encoded-kbd mode is on, this is set to a vector of length 4, the
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
93 ;; elements are character sets currently designated to graphic
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
94 ;; registers 0 thru 3.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 (defvar encoded-kbd-iso2022-designations nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 (put 'encoded-kbd-iso2022-designations 'permanent-local t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
99 ;; Keep information of invocation state of ISO2022 encoding. When
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
100 ;; Encoded-kbd mode is on, this is set to a vector of length 3,
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
101 ;; graphic register numbers currently invoked to graphic plane 1 and
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
102 ;; 2, and a single shifted graphic register number.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 (defvar encoded-kbd-iso2022-invocations nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 (put 'encoded-kbd-iso2022-invocations 'permanent-local t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 (defun encoded-kbd-iso2022-designation ()
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 22521
diff changeset
108 "Do ISO2022 designation according to the current key in Encoded-kbd mode.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 The following key sequence may cause multilingual text insertion."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 (let ((key-seq (this-command-keys))
19434
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
112 (prev-g0-charset (aref encoded-kbd-iso2022-designations
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
113 (aref encoded-kbd-iso2022-invocations 0)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 intermediate-char final-char
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 reg dimension chars charset)
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
116 (if (= (length key-seq) 4)
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
117 ;; ESC $ <intermediate-char> <final-char>
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
118 (setq intermediate-char (aref key-seq 2)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 dimension 2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 chars (if (< intermediate-char ?,) 94 96)
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
121 final-char (aref key-seq 3)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 reg (mod intermediate-char 4))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 (if (= (aref key-seq 1) ?$)
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
124 ;; ESC $ <final-char>
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 (setq dimension 2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 chars 94
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
127 final-char (aref key-seq 2)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 reg 0)
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
129 ;; ESC <intermediate-char> <final-char>
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
130 (setq intermediate-char (aref key-seq 1)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 dimension 1
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 chars (if (< intermediate-char ?,) 94 96)
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
133 final-char (aref key-seq 2)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 reg (mod intermediate-char 4))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 (if (setq charset (iso-charset dimension chars final-char))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 (aset encoded-kbd-iso2022-designations reg charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 (error "Character set of DIMENSION %s, CHARS %s, FINAL-CHAR `%c' is not supported"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 dimension chars final-char))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
140 (if (memq (aref encoded-kbd-iso2022-designations
19434
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
141 (aref encoded-kbd-iso2022-invocations 0))
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
142 '(ascii latin-jisx0201))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 ;; Graphic plane 0 (0x20..0x7f) is for ASCII. We don't have
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 ;; to handle characters in this range specially.
19434
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
145 (if (not (memq prev-g0-charset '(ascii latin-jisx0201)))
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 22521
diff changeset
146 ;; We must exit recursive edit now.
19434
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
147 (throw 'exit nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 ;; Graphic plane 0 is for non-ASCII.
19434
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
149 (if (memq prev-g0-charset '(ascii latin-jisx0201))
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 22521
diff changeset
150 ;; We must handle keys specially.
19434
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
151 (let ((overriding-local-map encoded-kbd-iso2022-non-ascii-map))
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
152 (recursive-edit))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 (defun encoded-kbd-handle-8bit ()
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 22521
diff changeset
155 "Handle an 8-bit character entered in Encoded-kbd mode."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 (cond ((eq encoded-kbd-coding 'iso2022-7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 (error "Can't handle the character code %d" last-command-char))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 ((eq encoded-kbd-coding 'iso2022-8)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 (cond ((= last-command-char ?\216)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 (aset encoded-kbd-iso2022-invocations 2 2))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 ((= last-command-char ?\217)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 (aset encoded-kbd-iso2022-invocations 2 3))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166
24393
fcaabeb8aece (encoded-kbd-handle-8bit): Allow inputting ?\240.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
167 ((>= last-command-char ?\240)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 (encoded-kbd-self-insert-iso2022-8bit))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 (t
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 (error "Can't handle the character code %d"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 last-command-char))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 ((eq encoded-kbd-coding 'sjis)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 (encoded-kbd-self-insert-sjis))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 (t
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 (encoded-kbd-self-insert-big5))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 (defun encoded-kbd-self-insert-iso2022-7bit ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 (interactive)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 (let* ((charset (aref encoded-kbd-iso2022-designations
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 (or (aref encoded-kbd-iso2022-invocations 2)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 (aref encoded-kbd-iso2022-invocations 0))))
25042
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
185 (char (if (= (charset-dimension charset) 1)
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
186 (make-char charset last-command-char)
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
187 (make-char charset last-command-char (read-char-exclusive)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188 (aset encoded-kbd-iso2022-invocations 2 nil)
25042
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
189 (setq unread-command-events (cons char unread-command-events))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 (defun encoded-kbd-self-insert-iso2022-8bit ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 (interactive)
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
193 (cond
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
194 ((= last-command-char ?\216) ; SS2 (Single Shift 2)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
195 (aset encoded-kbd-iso2022-invocations 2 2))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
196 ((= last-command-char ?\217) ; SS3 (Single Shift 3)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
197 (aset encoded-kbd-iso2022-invocations 2 3))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
198 (t
44451
7798da904366 Fix up indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41715
diff changeset
199 (let* ((charset (aref encoded-kbd-iso2022-designations
7798da904366 Fix up indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41715
diff changeset
200 (or (aref encoded-kbd-iso2022-invocations 2)
7798da904366 Fix up indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41715
diff changeset
201 (aref encoded-kbd-iso2022-invocations 1))))
7798da904366 Fix up indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41715
diff changeset
202 (char (if (= (charset-dimension charset) 1)
7798da904366 Fix up indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41715
diff changeset
203 (make-char charset last-command-char)
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
204 (make-char charset last-command-char
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
205 (read-char-exclusive)))))
44451
7798da904366 Fix up indentation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41715
diff changeset
206 (aset encoded-kbd-iso2022-invocations 2 nil)
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
207 (setq unread-command-events (cons char unread-command-events))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
209 (defun encoded-kbd-self-insert-sjis ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210 (interactive)
25042
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
211 (let ((char (if (or (< last-command-char ?\xA0) (>= last-command-char ?\xE0))
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
212 (decode-sjis-char (+ (ash last-command-char 8)
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
213 (read-char-exclusive)))
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
214 (make-char 'katakana-jisx0201 last-command-char))))
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
215 (setq unread-command-events (cons char unread-command-events))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 (defun encoded-kbd-self-insert-big5 ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 (interactive)
25042
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
219 (let ((char (decode-big5-char (+ (ash last-command-char 8)
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
220 (read-char-exclusive)))))
bf96605e00ee (encoded-kbd-self-insert-iso2022-7bit): Don't insert the character
Kenichi Handa <handa@m17n.org>
parents: 24393
diff changeset
221 (setq unread-command-events (cons char unread-command-events))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
223 (defun encoded-kbd-self-insert-ccl ()
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
224 (interactive)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
225 (let ((str (char-to-string last-command-char))
36954
798d1ac75e95 (encoded-kbd-self-insert-ccl): Call ccl-execute-on-string directly so
Kenichi Handa <handa@m17n.org>
parents: 29268
diff changeset
226 (ccl (car (aref (coding-system-spec (keyboard-coding-system)) 4)))
37095
416e07ad047e (encoded-kbd-self-insert-ccl):
Kenichi Handa <handa@m17n.org>
parents: 36954
diff changeset
227 (vec [nil nil nil nil nil nil nil nil nil])
36954
798d1ac75e95 (encoded-kbd-self-insert-ccl): Call ccl-execute-on-string directly so
Kenichi Handa <handa@m17n.org>
parents: 29268
diff changeset
228 result)
798d1ac75e95 (encoded-kbd-self-insert-ccl): Call ccl-execute-on-string directly so
Kenichi Handa <handa@m17n.org>
parents: 29268
diff changeset
229 (while (= (length (setq result (ccl-execute-on-string ccl vec str t))) 0)
37095
416e07ad047e (encoded-kbd-self-insert-ccl):
Kenichi Handa <handa@m17n.org>
parents: 36954
diff changeset
230 (dotimes (i 9) (aset vec i nil))
416e07ad047e (encoded-kbd-self-insert-ccl):
Kenichi Handa <handa@m17n.org>
parents: 36954
diff changeset
231 (setq str (format "%s%c" str (read-char-exclusive))))
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
232 (setq unread-command-events
37238
3f6a34e25c92 (encoded-kbd-self-insert-ccl):
Dave Love <fx@gnu.org>
parents: 37095
diff changeset
233 (append result unread-command-events))))
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
234
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
235 (defun encoded-kbd-setup-keymap (coding)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
236 ;; At first, reset the keymap.
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
237 (setcdr encoded-kbd-mode-map nil)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
238 ;; Then setup the keymap according to the keyboard coding system.
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
239 (cond
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
240 ((eq encoded-kbd-coding 'sjis)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
241 (let ((i 128))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
242 (while (< i 256)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
243 (define-key encoded-kbd-mode-map
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
244 (vector i) 'encoded-kbd-self-insert-sjis)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
245 (setq i (1+ i)))))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
246
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
247 ((eq encoded-kbd-coding 'big5)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
248 (let ((i 161))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
249 (while (< i 255)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
250 (define-key encoded-kbd-mode-map
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
251 (vector i) 'encoded-kbd-self-insert-big5)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
252 (setq i (1+ i)))))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
253
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
254 ((eq encoded-kbd-coding 'iso2022-7)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
255 (define-key encoded-kbd-mode-map "\e" 'encoded-kbd-iso2022-esc-prefix))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47817
diff changeset
256
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
257 ((eq encoded-kbd-coding 'iso2022-8)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
258 (define-key encoded-kbd-mode-map
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
259 (vector ?\216) 'encoded-kbd-self-insert-iso2022-8bit)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
260 (define-key encoded-kbd-mode-map
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
261 (vector ?\217) 'encoded-kbd-self-insert-iso2022-8bit)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
262 (let ((i 160))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
263 (while (< i 256)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
264 (define-key encoded-kbd-mode-map
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
265 (vector i) 'encoded-kbd-self-insert-iso2022-8bit)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
266 (setq i (1+ i)))))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
267
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
268 ((eq encoded-kbd-coding 'ccl)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
269 (let ((valid-codes (or (coding-system-get coding 'valid-codes)
36954
798d1ac75e95 (encoded-kbd-self-insert-ccl): Call ccl-execute-on-string directly so
Kenichi Handa <handa@m17n.org>
parents: 29268
diff changeset
270 '((128 . 255))))
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
271 elt from to)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
272 (while valid-codes
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
273 (setq elt (car valid-codes) valid-codes (cdr valid-codes))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
274 (if (consp elt)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
275 (setq from (car elt) to (cdr elt))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
276 (setq from (setq to elt)))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
277 (while (<= from to)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
278 (if (>= from 128)
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
279 (define-key encoded-kbd-mode-map
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
280 (vector from) 'encoded-kbd-self-insert-ccl))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
281 (setq from (1+ from))))))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
282
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
283 (t
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
284 (error "Invalid value in encoded-kbd-coding: %s" encoded-kbd-coding))))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
285
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
286
19268
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
287 ;; Input mode at the time Encoded-kbd mode is turned on is saved here.
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
288 (defvar saved-input-mode nil)
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
289
41715
3fb1c54eb631 (encoded-kbd-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41344
diff changeset
290 (put 'encoded-kbd-mode 'permanent-local t)
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
291 ;;;###autoload
41715
3fb1c54eb631 (encoded-kbd-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41344
diff changeset
292 (define-minor-mode encoded-kbd-mode
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293 "Toggle Encoded-kbd minor mode.
19268
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
294 With arg, turn Encoded-kbd mode on if and only if arg is positive.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295
19434
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
296 You should not turn this mode on manually, instead use the command
21700
e225fec97357 (encoded-kbd-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 19434
diff changeset
297 \\[set-keyboard-coding-system] which turns on or off this mode
19434
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
298 automatically.
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
299
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
300 In Encoded-kbd mode, a text sent from keyboard is accepted
31d9ded94ba4 (encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents: 19421
diff changeset
301 as a multilingual text encoded in a coding system set by
21700
e225fec97357 (encoded-kbd-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 19434
diff changeset
302 \\[set-keyboard-coding-system]."
41715
3fb1c54eb631 (encoded-kbd-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41344
diff changeset
303 :global t
3fb1c54eb631 (encoded-kbd-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41344
diff changeset
304 ;; We must at first reset input-mode to the original.
3fb1c54eb631 (encoded-kbd-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41344
diff changeset
305 (if saved-input-mode (apply 'set-input-mode saved-input-mode))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 (if encoded-kbd-mode
19268
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
307 (let ((coding (keyboard-coding-system)))
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
308 (setq saved-input-mode (current-input-mode))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309 (cond ((null coding)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47817
diff changeset
310 (setq encoded-kbd-mode nil)
19268
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
311 (error "No coding system for keyboard input is set"))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312
18697
2185491b8d24 (encoded-kbd-mode): Call coding-system-XXX instead of coding-vector-XXX.
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
313 ((= (coding-system-type coding) 1) ; SJIS
19268
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
314 (set-input-mode
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
315 (nth 0 saved-input-mode) (nth 1 saved-input-mode)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47817
diff changeset
316 'use-8th-bit (nth 3 saved-input-mode))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317 (setq encoded-kbd-coding 'sjis))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318
18697
2185491b8d24 (encoded-kbd-mode): Call coding-system-XXX instead of coding-vector-XXX.
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
319 ((= (coding-system-type coding) 2) ; ISO2022
2185491b8d24 (encoded-kbd-mode): Call coding-system-XXX instead of coding-vector-XXX.
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
320 (if (aref (coding-system-flags coding) 7) ; 7-bit only
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 (setq encoded-kbd-coding 'iso2022-7)
19268
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
322 (set-input-mode
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
323 (nth 0 saved-input-mode) (nth 1 saved-input-mode)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47817
diff changeset
324 'use-8th-bit (nth 3 saved-input-mode))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 (setq encoded-kbd-coding 'iso2022-8))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 (setq encoded-kbd-iso2022-designations (make-vector 4 nil))
18697
2185491b8d24 (encoded-kbd-mode): Call coding-system-XXX instead of coding-vector-XXX.
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
327 (let ((flags (coding-system-flags coding))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328 (i 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 (while (< i 4)
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
330 (if (charsetp (aref flags i))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331 (aset encoded-kbd-iso2022-designations i
19268
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
332 (aref flags i))
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
333 (if (charsetp (car-safe (aref flags i)))
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
334 (aset encoded-kbd-iso2022-designations i
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
335 (car (aref flags i)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336 (setq i (1+ i))))
17080
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
337 (setq encoded-kbd-iso2022-invocations (make-vector 3 nil))
d80a8a46437e Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
338 (aset encoded-kbd-iso2022-invocations 0 0)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 (aset encoded-kbd-iso2022-invocations 1 1))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340
18697
2185491b8d24 (encoded-kbd-mode): Call coding-system-XXX instead of coding-vector-XXX.
Kenichi Handa <handa@m17n.org>
parents: 18377
diff changeset
341 ((= (coding-system-type coding) 3) ; BIG5
19268
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
342 (set-input-mode
ecb55608fa91 (saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents: 18697
diff changeset
343 (nth 0 saved-input-mode) (nth 1 saved-input-mode)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47817
diff changeset
344 'use-8th-bit (nth 3 saved-input-mode))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 (setq encoded-kbd-coding 'big5))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
347 ((= (coding-system-type coding) 4) ; CCL based coding
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
348 (set-input-mode
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
349 (nth 0 saved-input-mode) (nth 1 saved-input-mode)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47817
diff changeset
350 'use-8th-bit (nth 3 saved-input-mode))
27816
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
351 (setq encoded-kbd-coding 'ccl))
321027008721 Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents: 25042
diff changeset
352
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 (t
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 (setq encoded-kbd-mode nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355 (error "Coding-system `%s' is not supported in Encoded-kbd mode"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 (keyboard-coding-system))))
41715
3fb1c54eb631 (encoded-kbd-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41344
diff changeset
357 (encoded-kbd-setup-keymap coding))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358
47817
8dcee128f3b5 Add `provide' call.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 44451
diff changeset
359 (provide 'encoded-kb)
8dcee128f3b5 Add `provide' call.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 44451
diff changeset
360
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 ;;; encoded-kb.el ends here