XEmacs 21.2.11
[chise/xemacs-chise.git.1] / lisp / mule / 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 ;; Copyright (C) 1997 MORIOKA Tomohiko
6
7 ;; Keywords: multilingual, Cyrillic
8
9 ;; This file is part of XEmacs.
10
11 ;; XEmacs is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; XEmacs is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 ;; 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;; The character set ISO8859-5 is supported.  KOI-8 and ALTERNATIVNYJ
29 ;; are converted to ISO8859-5 internally.
30
31 ;;; Code:
32
33 ;; For syntax of Cyrillic
34 (modify-syntax-entry 'cyrillic-iso8859-5 "w")
35 (modify-syntax-entry ?\e,L-\e(B ".")
36 (modify-syntax-entry ?\e,Lp\e(B ".")
37 (modify-syntax-entry ?\e,L}\e(B ".")
38
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40 ;;; CYRILLIC
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42
43 ;; (define-prefix-command 'describe-cyrillic-environment-map)
44 ;; (define-key-after describe-language-environment-map [Cyrillic]
45 ;;   '("Cyrillic" . describe-cyrillic-environment-map)
46 ;;   t)
47
48 ;; (define-prefix-command 'setup-cyrillic-environment-map)
49 ;; (define-key-after setup-language-environment-map [Cyrillic]
50 ;;   '("Cyrillic" . setup-cyrillic-environment-map)
51 ;;   t)
52
53 \f
54 ;; ISO-8859-5 staff
55
56 ;; (make-coding-system
57 ;;  'cyrillic-iso-8bit 2 ?5
58 ;;  "ISO 2022 based 8-bit encoding for Cyrillic script (MIME:ISO-8859-5)"
59 ;;  '((ascii t) (cyrillic-iso8859-5 t) nil nil
60 ;;    nil ascii-eol ascii-cntl nil nil nil nil))
61
62 ;; (define-coding-system-alias 'iso-8859-5 'cyrillic-iso-8bit)
63
64 (make-coding-system
65  'iso-8859-5 'iso2022
66  "MIME ISO-8859-5"
67  '(charset-g0 ascii
68    charset-g1 cyrillic-iso8859-5
69    charset-g2 t
70    charset-g3 t
71    mnemonic "ISO8/Cyr"
72    ))
73
74 (set-language-info-alist
75  "Cyrillic-ISO" '((setup-function . (setup-cyrillic-iso-environment
76                                      . setup-cyrillic-environment-map))
77                   (charset . (cyrillic-iso8859-5))
78                   (tutorial . "TUTORIAL.ru")
79                   (coding-system . (iso-8859-5))
80                   (sample-text . "Russian (\e,L@caaZXY\e(B)       \e,L7T`PRabRcYbU\e(B!")
81                   (documentation . ("Support for Cyrillic ISO-8859-5."
82                                     . describe-cyrillic-environment-map))))
83
84 ;; KOI-8 staff
85
86 (define-ccl-program ccl-decode-koi8
87   '(3
88     ((read r0)
89      (loop
90        (write-read-repeat
91         r0
92         [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
93            16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
94            32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
95            48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
96            64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
97            80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
98            96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
99            112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
100            128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
101            144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
102             32  32  32 ?\e,Lq\e(B   32  32  32  32  32  32  32  32  32  32  32  32
103             32  32  32 ?\e,L!\e(B   32  32  32  32  32  32  32  32  32  32  32  32
104            ?\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 
105            ?\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 
106            ?\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 
107            ?\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 ]))))
108   "CCL program to decode KOI8.")
109
110 (define-ccl-program ccl-encode-koi8
111   `(1
112     ((read r0)
113      (loop
114        (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
115            (write-read-repeat r0)
116          ((read r0)
117           (r0 -= 160)
118           (write-read-repeat
119            r0
120            [ 32 179  32  32  32  32  32  32  32  32  32  32  32  32  32  32
121                 225 226 247 231 228 229 246 250 233 234 235 236 237 238 239 240
122                 242 243 244 245 230 232 227 254 251 253 255 249 248 252 224 241
123                 193 194 215 199 196 197 214 218 201 202 203 204 205 206 207 208
124                 210 211 212 213 198 200 195 222 219 221 223 217 216 220 192 209
125                 32 163  32  32  32  32  32  32  32  32  32  32  32  32  32  32])
126           )))))
127   "CCL program to encode KOI8.")
128
129 ;(make-coding-system
130 ;  'cyrillic-koi8 4
131 ;  ;; We used to use ?K.  It is true that ?K is more strictly correct,
132 ;  ;; but it is also used for Korean.
133 ;  ;; So people who use koi8 for languages other than Russian
134 ;  ;; will have to forgive us.
135 ;  ?R "KOI8 8-bit encoding for Cyrillic (MIME: KOI8-R)"
136 ;  (cons ccl-decode-koi8 ccl-encode-koi8))
137
138 ;(define-coding-system-alias 'koi8-r 'cyrillic-koi8)
139 ;(define-coding-system-alias 'koi8 'cyrillic-koi8)
140
141 (make-coding-system
142  'koi8-r 'ccl
143  "Coding-system used for KOI8-R."
144  `(decode ,ccl-decode-koi8
145    encode ,ccl-encode-koi8
146    mnemonic "KOI8"))
147
148 ;(define-coding-system-alias 'koi8-r 'koi8)
149
150 ;; (define-ccl-program ccl-encode-koi8-font
151 ;;   '(0
152 ;;     ((r1 -= 160)
153 ;;      (r1 = r1
154 ;;          [ 32 179  32  32  32  32  32  32  32  32  32  32  32  32  32  32
155 ;;               225 226 247 231 228 229 246 250 233 234 235 236 237 238 239 240
156 ;;               242 243 244 245 230 232 227 254 251 253 255 249 248 252 224 241
157 ;;               193 194 215 199 196 197 214 218 201 202 203 204 205 206 207 208
158 ;;               210 211 212 213 198 200 195 222 219 221 223 217 216 220 192 209
159 ;;               32 163  32  32  32  32  32  32  32  32  32  32  32  32  32  32])
160 ;;      ))
161 ;;   "CCL program to encode Cyrillic chars to KOI font.")
162
163 ;; (setq font-ccl-encoder-alist
164 ;;       (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
165
166 (set-language-info-alist
167  "Cyrillic-KOI8" '((setup-function . (setup-cyrillic-koi8-environment
168                                       . setup-cyrillic-environment-map))
169                    (charset . (cyrillic-iso8859-5))
170                    (coding-system . (koi8-r))
171                    (tutorial . "TUTORIAL.ru")
172                    (sample-text . "Russian (\e,L@caaZXY\e(B)      \e,L7T`PRabRcYbU\e(B!")
173                    (documentation . ("Support for Cyrillic KOI-8."
174                                      . describe-cyrillic-environment-map))))
175
176 ;;; ALTERNATIVNYJ staff
177
178 (define-ccl-program ccl-decode-alternativnyj
179   '(3
180     ((read r0)
181      (loop
182        (write-read-repeat
183         r0
184         [  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
185                16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31
186                32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47
187                48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63
188                64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79
189                80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95
190                96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111
191                112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
192                ?\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
193                ?\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
194                ?\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
195                32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32
196                32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32
197                32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32
198                ?\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
199                ?\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]))))
200   "CCL program to decode Alternativnyj.")
201
202 (define-ccl-program ccl-encode-alternativnyj
203   `(1
204     ((read r0)
205      (loop
206        (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
207            (write-read-repeat r0)
208          ((read r0)
209           (r0 -= 160)
210           (write-read-repeat
211            r0
212            [ 32 240  32  32  32  32  32  32  32  32  32  32  32  32  32  32
213                 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
214                 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
215                 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
216                 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
217                 255 241  32  32  32  32  32  32  32  32  32  32  32  32  32  32])
218           )))))
219   "CCL program to encode Alternativnyj.")
220
221 ;; (make-coding-system
222 ;;  'alternativnyj 4
223 ;;  ?A "Coding-system used for Alternativnyj"
224 ;;  (cons ccl-decode-alternativnyj ccl-encode-alternativnyj))
225
226 (make-coding-system
227  'alternativnyj 'ccl
228  "Coding-system used for Alternativnyj"
229  `(decode ,ccl-decode-alternativnyj
230    encode ,ccl-encode-alternativnyj
231    mnemonic "Cy.Alt"))
232
233 ;; (define-ccl-program ccl-encode-alternativnyj-font
234 ;;   '(0
235 ;;     ((r1 -= 160)
236 ;;      (r1 = r1
237 ;;       [ 32 240  32  32  32  32  32  32  32  32  32  32  32  32  32  32
238 ;;        128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
239 ;;        144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
240 ;;        160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
241 ;;        224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
242 ;;        255 241  32  32  32  32  32  32  32  32  32  32  32  32  32  32])
243 ;;      ))
244 ;;   "CCL program to encode Cyrillic chars to Alternativnyj font.")
245
246 ;; (setq font-ccl-encoder-alist
247 ;;       (cons (cons "alternativnyj" ccl-encode-alternativnyj-font)
248 ;;             font-ccl-encoder-alist))
249
250 (set-language-info-alist
251  "Cyrillic-ALT" '((setup-function . (setup-cyrillic-alternativnyj-environment
252                                      . setup-cyrillic-environment-map))
253                   (charset . (cyrillic-iso8859-5))
254                   (coding-system . (alternativnyj))
255                   (tutorial . "TUTORIAL.ru")
256                   (sample-text . "Russian (\e,L@caaZXY\e(B)       \e,L7T`PRabRcYbU\e(B!")
257                   (documentation . ("Support for Cyrillic ALTERNATIVNYJ."
258                                     . describe-cyrillic-environment-map))))
259
260 ;;; GENERAL
261
262 (defun setup-cyrillic-environment ()
263   "Setup multilingual environment for Cyrillic users."
264   (interactive)
265   (setq primary-language "Cyrillic")
266
267   (setq coding-category-iso-8-1 'iso-8859-5)
268
269   (set-coding-priority
270    '(coding-category-iso-7
271      coding-category-iso-8-1))
272
273   (setq-default buffer-file-coding-system 'iso-8859-5)
274   (set-terminal-coding-system 'iso-8859-5)
275   (set-keyboard-coding-system 'iso-8859-5)
276
277   (setq default-input-method '("Cyrillic" . "quail-yawerty"))
278   )
279
280 (defun describe-cyrillic-support ()
281   "Describe how Emacs support Cyrillic."
282   (interactive)
283   (describe-language-support-internal "Cyrillic"))
284
285 (set-language-info-alist
286  "Cyrillic" '((setup-function . setup-cyrillic-environment)
287               (describe-function . describe-cyrillic-support)
288               (charset . (cyrillic-iso8859-5))
289               (tutorial . "TUTORIAL.ru")
290               (coding-system . (iso-8859-5 koi8-r alternativnyj))
291               (sample-text . "Russian (\e,L@caaZXY\e(B) \e,L7T`PRabRcYbU\e(B!")
292               (documentation . nil)))
293
294 ;;; cyrillic.el ends here