Make describe-cyrillic-environment-map and
[bpt/emacs.git] / lisp / language / cyrillic.el
1 ;;; cyrillic.el --- Support for languages which use Cyrillic characters
2
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
5
6 ;; Keywords: multilingual, Cyrillic
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;; The character set ISO8859-5 is supported. KOI-8 and ALTERNATIVNYJ
28 ;; are converted to ISO8859-5 internally.
29
30 ;;; Code:
31
32 ;; Cyrillic (general)
33
34 (define-prefix-command 'describe-cyrillic-environment-map)
35 (define-key-after describe-language-environment-map [Cyrillic]
36 '("Cyrillic" . describe-cyrillic-environment-map)
37 t)
38
39 (define-prefix-command 'setup-cyrillic-environment-map)
40 (define-key-after setup-language-environment-map [Cyrillic]
41 '("Cyrillic" . setup-cyrillic-environment-map)
42 t)
43
44 ;; ISO-8859-5 staff
45
46 (make-coding-system
47 'cyrillic-iso-8bit 2 ?5
48 "ISO 2022 based 8-bit encoding for Cyrillic script (MIME:ISO-8859-5)"
49 '((ascii t) (cyrillic-iso8859-5 t) nil nil
50 nil ascii-eol ascii-cntl nil nil nil nil))
51
52 (define-coding-system-alias 'iso-8859-5 'cyrillic-iso-8bit)
53
54 (set-language-info-alist
55 "Cyrillic-ISO" '((setup-function . (setup-cyrillic-iso-environment
56 . setup-cyrillic-environment-map))
57 (charset . (cyrillic-iso8859-5))
58 (coding-system . (cyrillic-iso-8bit))
59 (sample-text . "Russian (\e,L@caaZXY\e(B) \e,L7T`PRabRcYbU\e(B!")
60 (documentation . ("Support for Cyrillic ISO-8859-5."
61 . describe-cyrillic-environment-map))))
62
63 ;; KOI-8 staff
64
65 (define-ccl-program ccl-decode-koi8
66 '(3
67 ((read r0)
68 (loop
69 (write-read-repeat
70 r0
71 [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
72 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
73 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
74 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
75 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
76 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
77 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
78 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
79 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
80 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
81 32 32 32 ?\e,Lq\e(B 32 32 32 32 32 32 32 32 32 32 32 32
82 32 32 32 ?\e,L!\e(B 32 32 32 32 32 32 32 32 32 32 32 32
83 ?\e,Ln\e(B ?\e,LP\e(B ?\e,LQ\e(B ?\e,Lf\e(B ?\e,LT\e(B ?\e,LU\e(B ?\e,Ld\e(B ?\e,LS\e(B ?\e,Le\e(B ?\e,LX\e(B ?\e,LY\e(B ?\e,LZ\e(B ?\e,L[\e(B ?\e,L\\e(B ?\e,L]\e(B ?\e,L^\e(B
84 ?\e,L_\e(B ?\e,Lo\e(B ?\e,L`\e(B ?\e,La\e(B ?\e,Lb\e(B ?\e,Lc\e(B ?\e,LV\e(B ?\e,LR\e(B ?\e,Ll\e(B ?\e,Lk\e(B ?\e,LW\e(B ?\e,Lh\e(B ?\e,Lm\e(B ?\e,Li\e(B ?\e,Lg\e(B ?\e,Lj\e(B
85 ?\e,LN\e(B ?\e,L0\e(B ?\e,L1\e(B ?\e,LF\e(B ?\e,L4\e(B ?\e,L5\e(B ?\e,LD\e(B ?\e,L3\e(B ?\e,LE\e(B ?\e,L8\e(B ?\e,L9\e(B ?\e,L:\e(B ?\e,L;\e(B ?\e,L<\e(B ?\e,L=\e(B ?\e,L>\e(B
86 ?\e,L?\e(B ?\e,LO\e(B ?\e,L@\e(B ?\e,LA\e(B ?\e,LB\e(B ?\e,LC\e(B ?\e,L6\e(B ?\e,L2\e(B ?\e,LL\e(B ?\e,LK\e(B ?\e,L7\e(B ?\e,LH\e(B ?\e,LM\e(B ?\e,LI\e(B ?\e,LG\e(B ?\e,LJ\e(B ]))))
87 "CCL program to decode KOI8.")
88
89 (define-ccl-program ccl-encode-koi8
90 `(1
91 ((read r0)
92 (loop
93 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
94 (write-read-repeat r0)
95 ((read r0)
96 (r0 -= 160)
97 (write-read-repeat
98 r0
99 [ 32 179 32 32 32 32 32 32 32 32 32 32 32 32 32 32
100 225 226 247 231 228 229 246 250 233 234 235 236 237 238 239 240
101 242 243 244 245 230 232 227 254 251 253 255 249 248 252 224 241
102 193 194 215 199 196 197 214 218 201 202 203 204 205 206 207 208
103 210 211 212 213 198 200 195 222 219 221 223 217 216 220 192 209
104 32 163 32 32 32 32 32 32 32 32 32 32 32 32 32 32])
105 )))))
106 "CCL program to encode KOI8.")
107
108 (make-coding-system
109 'cyrillic-koi8 4
110 ;; We used to use ?K. It is true that ?K is more strictly correct,
111 ;; but it is also used for Korean.
112 ;; So people who use koi8 for languages other than Russian
113 ;; will have to forgive us.
114 ?R "KOI8 8-bit encoding for Cyrillic (MIME: KOI8-R)"
115 (cons ccl-decode-koi8 ccl-encode-koi8))
116
117 (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
118 (define-coding-system-alias 'koi8 'cyrillic-koi8)
119
120 (define-ccl-program ccl-encode-koi8-font
121 '(0
122 ((r1 -= 160)
123 (r1 = r1
124 [ 32 179 32 32 32 32 32 32 32 32 32 32 32 32 32 32
125 225 226 247 231 228 229 246 250 233 234 235 236 237 238 239 240
126 242 243 244 245 230 232 227 254 251 253 255 249 248 252 224 241
127 193 194 215 199 196 197 214 218 201 202 203 204 205 206 207 208
128 210 211 212 213 198 200 195 222 219 221 223 217 216 220 192 209
129 32 163 32 32 32 32 32 32 32 32 32 32 32 32 32 32])
130 ))
131 "CCL program to encode Cyrillic chars to KOI font.")
132
133 (setq font-ccl-encoder-alist
134 (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
135
136 (set-language-info-alist
137 "Cyrillic-KOI8" '((setup-function . (setup-cyrillic-koi8-environment
138 . setup-cyrillic-environment-map))
139 (charset . (cyrillic-iso8859-5))
140 (coding-system . (cyrillic-koi8))
141 (sample-text . "Russian (\e,L@caaZXY\e(B) \e,L7T`PRabRcYbU\e(B!")
142 (documentation . ("Support for Cyrillic KOI-8."
143 . describe-cyrillic-environment-map))))
144
145 ;;; ALTERNATIVNYJ staff
146
147 (define-ccl-program ccl-decode-alternativnyj
148 '(3
149 ((read r0)
150 (loop
151 (write-read-repeat
152 r0
153 [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
154 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
155 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
156 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
157 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
158 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
159 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
160 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
161 ?\e,L0\e(B ?\e,L1\e(B ?\e,L2\e(B ?\e,L3\e(B ?\e,L4\e(B ?\e,L5\e(B ?\e,L6\e(B ?\e,L7\e(B ?\e,L8\e(B ?\e,L9\e(B ?\e,L:\e(B ?\e,L;\e(B ?\e,L<\e(B ?\e,L=\e(B ?\e,L>\e(B ?\e,L?\e(B
162 ?\e,L@\e(B ?\e,LA\e(B ?\e,LB\e(B ?\e,LC\e(B ?\e,LD\e(B ?\e,LE\e(B ?\e,LF\e(B ?\e,LG\e(B ?\e,LH\e(B ?\e,LI\e(B ?\e,LJ\e(B ?\e,LK\e(B ?\e,LL\e(B ?\e,LM\e(B ?\e,LN\e(B ?\e,LO\e(B
163 ?\e,LP\e(B ?\e,LQ\e(B ?\e,LR\e(B ?\e,LS\e(B ?\e,LT\e(B ?\e,LU\e(B ?\e,LV\e(B ?\e,LW\e(B ?\e,LX\e(B ?\e,LY\e(B ?\e,LZ\e(B ?\e,L[\e(B ?\e,L\\e(B ?\e,L]\e(B ?\e,L^\e(B ?\e,L_\e(B
164 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
165 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
166 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
167 ?\e,L`\e(B ?\e,La\e(B ?\e,Lb\e(B ?\e,Lc\e(B ?\e,Ld\e(B ?\e,Le\e(B ?\e,Lf\e(B ?\e,Lg\e(B ?\e,Lh\e(B ?\e,Li\e(B ?\e,Lj\e(B ?\e,Lk\e(B ?\e,Ll\e(B ?\e,Lm\e(B ?\e,Ln\e(B ?\e,Lo\e(B
168 ?\e,L!\e(B ?\e,Lq\e(B 32 32 32 32 32 32 32 32 32 32 32 32 32 ?\e,Lp\e(B]))))
169 "CCL program to decode Alternativnyj.")
170
171 (define-ccl-program ccl-encode-alternativnyj
172 `(1
173 ((read r0)
174 (loop
175 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
176 (write-read-repeat r0)
177 ((read r0)
178 (r0 -= 160)
179 (write-read-repeat
180 r0
181 [ 32 240 32 32 32 32 32 32 32 32 32 32 32 32 32 32
182 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
183 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
184 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
185 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
186 255 241 32 32 32 32 32 32 32 32 32 32 32 32 32 32])
187 )))))
188 "CCL program to encode Alternativnyj.")
189
190 (make-coding-system
191 'cyrillic-alternativnyj 4 ?A
192 "ALTERNATIVNYJ 8-bit encoding for Cyrillic"
193 (cons ccl-decode-alternativnyj ccl-encode-alternativnyj))
194
195 (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
196
197 (define-ccl-program ccl-encode-alternativnyj-font
198 '(0
199 ((r1 -= 160)
200 (r1 = r1
201 [ 32 240 32 32 32 32 32 32 32 32 32 32 32 32 32 32
202 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
203 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
204 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
205 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
206 255 241 32 32 32 32 32 32 32 32 32 32 32 32 32 32])
207 ))
208 "CCL program to encode Cyrillic chars to Alternativnyj font.")
209
210 (setq font-ccl-encoder-alist
211 (cons (cons "alternativnyj" ccl-encode-alternativnyj-font)
212 font-ccl-encoder-alist))
213
214 (set-language-info-alist
215 "Cyrillic-ALT" '((setup-function . (setup-cyrillic-alternativnyj-environment
216 . setup-cyrillic-environment-map))
217 (charset . (cyrillic-iso8859-5))
218 (coding-system . (cyrillic-alternativnyj))
219 (sample-text . "Russian (\e,L@caaZXY\e(B) \e,L7T`PRabRcYbU\e(B!")
220 (documentation . ("Support for Cyrillic ALTERNATIVNYJ."
221 . describe-cyrillic-environment-map))))
222
223 ;;; cyrillic.el ends here