Mercurial > emacs
annotate lisp/international/encoded-kb.el @ 61247:d11749d2bcff
(bibtex-url): Use format to generate the url.
(bibtex-generate-url-list): Update docstring accordingly. Put the
complex example in the docstring.
(bibtex-font-lock-url): Use pop.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 03 Apr 2005 21:26:11 +0000 |
parents | fa3ef0f9b02e |
children | 00b61538c205 befae6bafecb |
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 | 2 |
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 | 5 |
6 ;; This file is part of GNU Emacs. | |
7 | |
8 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
9 ;; it under the terms of the GNU General Public License as published by | |
10 ;; the Free Software Foundation; either version 2, or (at your option) | |
11 ;; any later version. | |
12 | |
13 ;; GNU Emacs is distributed in the hope that it will be useful, | |
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;; GNU General Public License for more details. | |
17 | |
18 ;; You should have received a copy of the GNU General Public License | |
17071 | 19 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 ;; Boston, MA 02111-1307, USA. | |
17052 | 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 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
27 ;; Usually this map is empty (even if Encoded-kbd mode is on), but if |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
28 ;; the keyboard coding system is iso-2022-based, it defines dummy key |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
29 ;; bindings for ESC $ ..., etc. so that those bindings in |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
30 ;; key-translation-map take effect. |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
31 (defconst encoded-kbd-mode-map (make-sparse-keymap) |
17052 | 32 "Keymap for Encoded-kbd minor mode.") |
33 | |
34 ;; Subsidiary keymaps for handling ISO2022 escape sequences. | |
35 | |
36 (defvar encoded-kbd-iso2022-esc-map | |
37 (let ((map (make-sparse-keymap))) | |
38 (define-key map "$" 'encoded-kbd-iso2022-esc-dollar-prefix) | |
39 (define-key map "(" 'encoded-kbd-iso2022-designation-prefix) | |
40 (define-key map ")" 'encoded-kbd-iso2022-designation-prefix) | |
41 (define-key map "," 'encoded-kbd-iso2022-designation-prefix) | |
42 (define-key map "-" 'encoded-kbd-iso2022-designation-prefix) | |
43 map) | |
44 "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
|
45 (fset 'encoded-kbd-iso2022-esc-prefix encoded-kbd-iso2022-esc-map) |
17052 | 46 |
47 (defvar encoded-kbd-iso2022-esc-dollar-map | |
48 (let ((map (make-sparse-keymap))) | |
49 (define-key map "(" 'encoded-kbd-iso2022-designation-prefix) | |
50 (define-key map ")" 'encoded-kbd-iso2022-designation-prefix) | |
51 (define-key map "," 'encoded-kbd-iso2022-designation-prefix) | |
52 (define-key map "-" 'encoded-kbd-iso2022-designation-prefix) | |
53 (define-key map "@" 'encoded-kbd-iso2022-designation) | |
54 (define-key map "A" 'encoded-kbd-iso2022-designation) | |
55 (define-key map "B" 'encoded-kbd-iso2022-designation) | |
56 map) | |
17080
d80a8a46437e
Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
57 "Keymap for handling ESC $ sequence in Encoded-kbd mode.") |
17052 | 58 (fset 'encoded-kbd-iso2022-esc-dollar-prefix |
59 encoded-kbd-iso2022-esc-dollar-map) | |
60 | |
61 (defvar encoded-kbd-iso2022-designation-map | |
62 (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
|
63 (l charset-list) |
00ff62c583fe
(encoded-kbd-iso2022-designation-map): Pay attention to that
Kenichi Handa <handa@m17n.org>
parents:
27816
diff
changeset
|
64 final-char) |
17080
d80a8a46437e
Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
65 (while l |
29267
00ff62c583fe
(encoded-kbd-iso2022-designation-map): Pay attention to that
Kenichi Handa <handa@m17n.org>
parents:
27816
diff
changeset
|
66 (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
|
67 (if (> final-char 0) |
29267
00ff62c583fe
(encoded-kbd-iso2022-designation-map): Pay attention to that
Kenichi Handa <handa@m17n.org>
parents:
27816
diff
changeset
|
68 (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
|
69 'encoded-kbd-iso2022-designation)) |
17080
d80a8a46437e
Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
70 (setq l (cdr l))) |
17052 | 71 map) |
72 "Keymap for handling ISO2022 designation sequence in Encoded-kbd mode.") | |
73 (fset 'encoded-kbd-iso2022-designation-prefix | |
74 encoded-kbd-iso2022-designation-map) | |
75 | |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
76 ;; 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
|
77 ;; 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
|
78 ;; 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
|
79 ;; registers 0 thru 3. |
17052 | 80 |
81 (defvar encoded-kbd-iso2022-designations nil) | |
82 (put 'encoded-kbd-iso2022-designations 'permanent-local t) | |
83 | |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
84 ;; 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
|
85 ;; 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
|
86 ;; 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
|
87 ;; 2, and a single shifted graphic register number. |
17052 | 88 |
89 (defvar encoded-kbd-iso2022-invocations nil) | |
90 (put 'encoded-kbd-iso2022-invocations 'permanent-local t) | |
91 | |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
92 (defsubst encoded-kbd-last-key () |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
93 (let ((keys (this-single-command-keys))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
94 (aref keys (1- (length keys))))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
95 |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
96 (defun encoded-kbd-iso2022-designation (ignore) |
23196 | 97 "Do ISO2022 designation according to the current key in Encoded-kbd mode. |
17052 | 98 The following key sequence may cause multilingual text insertion." |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
99 (let ((key-seq (this-single-command-keys)) |
19434
31d9ded94ba4
(encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents:
19421
diff
changeset
|
100 (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
|
101 (aref encoded-kbd-iso2022-invocations 0))) |
17052 | 102 intermediate-char final-char |
103 reg dimension chars charset) | |
17080
d80a8a46437e
Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
104 (if (= (length key-seq) 4) |
d80a8a46437e
Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
105 ;; ESC $ <intermediate-char> <final-char> |
d80a8a46437e
Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
106 (setq intermediate-char (aref key-seq 2) |
17052 | 107 dimension 2 |
108 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
|
109 final-char (aref key-seq 3) |
17052 | 110 reg (mod intermediate-char 4)) |
111 (if (= (aref key-seq 1) ?$) | |
17080
d80a8a46437e
Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
112 ;; ESC $ <final-char> |
17052 | 113 (setq dimension 2 |
114 chars 94 | |
17080
d80a8a46437e
Many changes to cope with the above change.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
115 final-char (aref key-seq 2) |
17052 | 116 reg 0) |
17080
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 1) |
17052 | 119 dimension 1 |
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 2) |
17052 | 122 reg (mod intermediate-char 4)))) |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
123 (aset encoded-kbd-iso2022-designations reg |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
124 (iso-charset dimension chars final-char))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
125 "") |
17052 | 126 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
127 (defun encoded-kbd-iso2022-single-shift (ignore) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
128 (let ((char (encoded-kbd-last-key))) |
59711
fa3ef0f9b02e
(encoded-kbd-iso2022-single-shift):
Kenichi Handa <handa@m17n.org>
parents:
56598
diff
changeset
|
129 (aset encoded-kbd-iso2022-invocations 2 (if (= char ?\216) 2 3))) |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
130 "") |
17052 | 131 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
132 (defun encoded-kbd-self-insert-iso2022-7bit (ignore) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
133 (let ((char (encoded-kbd-last-key)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
134 (charset (aref encoded-kbd-iso2022-designations |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
135 (or (aref encoded-kbd-iso2022-invocations 2) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
136 (aref encoded-kbd-iso2022-invocations 0))))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
137 (aset encoded-kbd-iso2022-invocations 2 nil) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
138 (vector (if (= (charset-dimension charset) 1) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
139 (make-char charset char) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
140 (make-char charset char (read-char-exclusive)))))) |
17052 | 141 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
142 (defun encoded-kbd-self-insert-iso2022-8bit (ignore) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
143 (let ((char (encoded-kbd-last-key)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
144 (charset (aref encoded-kbd-iso2022-designations |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
145 (or (aref encoded-kbd-iso2022-invocations 2) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
146 (aref encoded-kbd-iso2022-invocations 1))))) |
17052 | 147 (aset encoded-kbd-iso2022-invocations 2 nil) |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
148 (vector (if (= (charset-dimension charset) 1) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
149 (make-char charset char) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
150 (make-char charset char (read-char-exclusive)))))) |
17052 | 151 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
152 (defun encoded-kbd-self-insert-sjis (ignore) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
153 (let ((char (encoded-kbd-last-key))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
154 (vector |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
155 (if (or (< char ?\xA0) (>= char ?\xE0)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
156 (decode-sjis-char (+ (ash char 8) (read-char-exclusive))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
157 (make-char 'katakana-jisx0201 char))))) |
17052 | 158 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
159 (defun encoded-kbd-self-insert-big5 (ignore) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
160 (let ((char (encoded-kbd-last-key))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
161 (vector |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
162 (decode-big5-char (+ (ash char 8) (read-char-exclusive)))))) |
17052 | 163 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
164 (defun encoded-kbd-self-insert-ccl (ignore) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
165 (let ((str (char-to-string (encoded-kbd-last-key))) |
36954
798d1ac75e95
(encoded-kbd-self-insert-ccl): Call ccl-execute-on-string directly so
Kenichi Handa <handa@m17n.org>
parents:
29268
diff
changeset
|
166 (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
|
167 (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
|
168 result) |
798d1ac75e95
(encoded-kbd-self-insert-ccl): Call ccl-execute-on-string directly so
Kenichi Handa <handa@m17n.org>
parents:
29268
diff
changeset
|
169 (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
|
170 (dotimes (i 9) (aset vec i nil)) |
416e07ad047e
(encoded-kbd-self-insert-ccl):
Kenichi Handa <handa@m17n.org>
parents:
36954
diff
changeset
|
171 (setq str (format "%s%c" str (read-char-exclusive)))) |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
172 (vector (aref result 0)))) |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
173 |
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
174 (defun encoded-kbd-setup-keymap (coding) |
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
175 ;; At first, reset the keymap. |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
176 (define-key encoded-kbd-mode-map "\e" nil) |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
177 ;; 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
|
178 (cond |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
179 ((eq (coding-system-type coding) 1) ; SJIS |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
180 (let ((i 128)) |
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
181 (while (< i 256) |
56598
3caaa79fcb7e
(encoded-kbd-setup-keymap): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
56597
diff
changeset
|
182 (define-key key-translation-map |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
183 (vector i) 'encoded-kbd-self-insert-sjis) |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
184 (setq i (1+ i)))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
185 8) |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
186 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
187 ((eq (coding-system-type coding) 3) ; Big5 |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
188 (let ((i 161)) |
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
189 (while (< i 255) |
56598
3caaa79fcb7e
(encoded-kbd-setup-keymap): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
56597
diff
changeset
|
190 (define-key key-translation-map |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
191 (vector i) 'encoded-kbd-self-insert-big5) |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
192 (setq i (1+ i)))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
193 8) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47817
diff
changeset
|
194 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
195 ((eq (coding-system-type coding) 2) ; ISO-2022 |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
196 (let ((flags (coding-system-flags coding)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
197 use-designation) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
198 (if (aref flags 8) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
199 nil ; Don't support locking-shift. |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
200 (setq encoded-kbd-iso2022-designations (make-vector 4 nil) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
201 encoded-kbd-iso2022-invocations (make-vector 3 nil)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
202 (dotimes (i 4) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
203 (if (aref flags i) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
204 (if (charsetp (aref flags i)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
205 (aset encoded-kbd-iso2022-designations |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
206 i (aref flags i)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
207 (setq use-designation t) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
208 (if (charsetp (car-safe (aref flags i))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
209 (aset encoded-kbd-iso2022-designations |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
210 i (car (aref flags i))))))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
211 (aset encoded-kbd-iso2022-invocations 0 0) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
212 (if (aref encoded-kbd-iso2022-designations 1) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
213 (aset encoded-kbd-iso2022-invocations 1 1)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
214 (when use-designation |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
215 (define-key encoded-kbd-mode-map "\e" 'encoded-kbd-iso2022-esc-prefix) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
216 (define-key key-translation-map "\e" 'encoded-kbd-iso2022-esc-prefix)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
217 (when (or (aref flags 2) (aref flags 3)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
218 (define-key key-translation-map |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
219 [?\216] 'encoded-kbd-iso2022-single-shift) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
220 (define-key key-translation-map |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
221 [?\217] 'encoded-kbd-iso2022-single-shift)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
222 (or (eq (aref flags 0) 'ascii) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
223 (dotimes (i 96) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
224 (define-key key-translation-map |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
225 (vector (+ 32 i)) 'encoded-kbd-self-insert-iso2022-7bit))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
226 (if (aref flags 7) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
227 t |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
228 (dotimes (i 96) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
229 (define-key key-translation-map |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
230 (vector (+ 160 i)) 'encoded-kbd-self-insert-iso2022-8bit)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
231 8)))) |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
232 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
233 ((eq (coding-system-type coding) 4) ; CCL-base |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
234 (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
|
235 '((128 . 255)))) |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
236 elt from to valid) |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
237 (while valid-codes |
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
238 (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
|
239 (if (consp elt) |
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
240 (setq from (car elt) to (cdr elt)) |
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
241 (setq from (setq to elt))) |
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
242 (while (<= from to) |
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
243 (if (>= from 128) |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
244 (define-key key-translation-map |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
245 (vector from) 'encoded-kbd-self-insert-ccl)) |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
246 (setq from (1+ from)))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
247 8)) |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
248 |
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
249 (t |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
250 nil))) |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
251 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
252 ;; key-translation-map at the time Encoded-kbd mode is turned on is |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
253 ;; saved here. |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
254 (defvar saved-key-translation-map nil) |
27816
321027008721
Be sure to update minor-mode-alist
Kenichi Handa <handa@m17n.org>
parents:
25042
diff
changeset
|
255 |
19268
ecb55608fa91
(saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18697
diff
changeset
|
256 ;; 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
|
257 (defvar saved-input-mode nil) |
ecb55608fa91
(saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18697
diff
changeset
|
258 |
41715
3fb1c54eb631
(encoded-kbd-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41344
diff
changeset
|
259 (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
|
260 ;;;###autoload |
41715
3fb1c54eb631
(encoded-kbd-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41344
diff
changeset
|
261 (define-minor-mode encoded-kbd-mode |
17052 | 262 "Toggle Encoded-kbd minor mode. |
19268
ecb55608fa91
(saved-input-mode): New variable.
Kenichi Handa <handa@m17n.org>
parents:
18697
diff
changeset
|
263 With arg, turn Encoded-kbd mode on if and only if arg is positive. |
17052 | 264 |
19434
31d9ded94ba4
(encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents:
19421
diff
changeset
|
265 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
|
266 \\[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
|
267 automatically. |
31d9ded94ba4
(encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents:
19421
diff
changeset
|
268 |
31d9ded94ba4
(encoded-kbd-mode): Doc-string modified. Make this a
Kenichi Handa <handa@m17n.org>
parents:
19421
diff
changeset
|
269 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
|
270 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
|
271 \\[set-keyboard-coding-system]." |
41715
3fb1c54eb631
(encoded-kbd-mode): Use define-minor-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41344
diff
changeset
|
272 :global t |
17052 | 273 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
274 (if encoded-kbd-mode |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
275 ;; We are turning on Encoded-kbd mode. |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
276 (let ((coding (keyboard-coding-system)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
277 result) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
278 (or saved-key-translation-map |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
279 (if (keymapp key-translation-map) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
280 (setq saved-key-translation-map |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
281 (copy-keymap key-translation-map)) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
282 (setq key-translation-map (make-sparse-keymap)))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
283 (or saved-input-mode |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
284 (setq saved-input-mode |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
285 (current-input-mode))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
286 (setq result (and coding (encoded-kbd-setup-keymap coding))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
287 (if result |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
288 (if (eq result 8) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
289 (set-input-mode |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
290 (nth 0 saved-input-mode) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
291 (nth 1 saved-input-mode) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
292 'use-8th-bit |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
293 (nth 3 saved-input-mode))) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
294 (setq encoded-kbd-mode nil |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
295 saved-key-translation-map nil |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
296 saved-input-mode nil) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
297 (error "Unsupported coding system in Encoded-kbd mode: %S" |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
298 coding))) |
17052 | 299 |
56597
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
300 ;; We are turning off Encoded-kbd mode. |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
301 (setq key-translation-map saved-key-translation-map |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
302 saved-key-translation-map nil) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
303 (apply 'set-input-mode saved-input-mode) |
399c8a1fbe0b
The following changes are to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
304 (setq saved-input-mode nil))) |
17052 | 305 |
47817
8dcee128f3b5
Add `provide' call.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44451
diff
changeset
|
306 (provide 'encoded-kb) |
8dcee128f3b5
Add `provide' call.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
44451
diff
changeset
|
307 |
52401 | 308 ;;; arch-tag: 76f0f9b3-65e7-45c3-b692-59509a87ad44 |
17052 | 309 ;;; encoded-kb.el ends here |