412
|
1 ;;; cyrillic.el --- Support for languages which use Cyrillic characters
|
333
|
2
|
398
|
3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
|
333
|
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")
|
412
|
35 (modify-syntax-entry ?.LN- ".")
|
|
36 (modify-syntax-entry ?.LNp ".")
|
|
37 (modify-syntax-entry ?.LN} ".")
|
333
|
38
|
|
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
40 ;;; CYRILLIC
|
|
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
42
|
412
|
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
|
333
|
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)"
|
412
|
59 ;; '((ascii t) (cyrillic-iso8859-5 t) nil nil
|
|
60 ;; nil ascii-eol ascii-cntl nil nil nil nil))
|
333
|
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
|
412
|
75 "Cyrillic-ISO" '((setup-function . (setup-cyrillic-iso-environment
|
|
76 . setup-cyrillic-environment-map))
|
|
77 (charset . (cyrillic-iso8859-5))
|
333
|
78 (tutorial . "TUTORIAL.ru")
|
412
|
79 (coding-system . (iso-8859-5))
|
|
80 (sample-text . "Russian (.LN@NcNaNaNZNXNY) N7NTN`NPNRNaNbNRNcNYNbNU!")
|
|
81 (documentation . ("Support for Cyrillic ISO-8859-5."
|
|
82 . describe-cyrillic-environment-map))))
|
333
|
83
|
|
84 ;; KOI-8 staff
|
|
85
|
398
|
86 (eval-and-compile
|
|
87
|
|
88 (defvar cyrillic-koi8-r-decode-table
|
|
89 [
|
|
90 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
91 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
92 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
93 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
94 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
95 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
96 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
97 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
98 ?$B(!(B ?$B("(B ?$B(#(B ?$B($(B ?$B(&(B ?$B(%(B ?$B('(B ?$B()(B ?$B(((B ?$B(*(B ?$B(+(B 32 ?$(G#'(B ?$(G#+(B ?$(G#/(B 32
|
412
|
99 144 ?$(C"F(B 146 147 ?$B"#(B 149 ?$B"e(B ?$A!V(B ?$A!\(B ?$A!](B ?.AN 32 ?N0 ?N2 ?N7 ?Nw
|
|
100 ?$(G#D(B 32 32 ?.LNq 32 32 32 32 32 32 32 32 32 32 32 ?$(G#E(B
|
|
101 32 32 ?$(G#G(B ?.LN! 32 32 32 32 32 32 32 32 ?$(G#F(B 32 32 ?.AN)
|
|
102 ?.LNn ?NP ?NQ ?Nf ?NT ?NU ?Nd ?NS ?Ne ?NX ?NY ?NZ ?N[ ?N\ ?N] ?N^
|
|
103 ?.LN_ ?No ?N` ?Na ?Nb ?Nc ?NV ?NR ?Nl ?Nk ?NW ?Nh ?Nm ?Ni ?Ng ?Nj
|
|
104 ?.LNN ?N0 ?N1 ?NF ?N4 ?N5 ?ND ?N3 ?NE ?N8 ?N9 ?N: ?N; ?N< ?N= ?N>
|
|
105 ?.LN? ?NO ?N@ ?NA ?NB ?NC ?N6 ?N2 ?NL ?NK ?N7 ?NH ?NM ?NI ?NG ?NJ ]
|
398
|
106 "Cyrillic KOI8-R decoding table.")
|
|
107
|
|
108 (defvar cyrillic-koi8-r-encode-table
|
|
109 (let ((table (make-vector 256 32))
|
|
110 (i 0))
|
|
111 (while (< i 256)
|
|
112 (let* ((ch (aref cyrillic-koi8-r-decode-table i))
|
412
|
113 (split (split-char-or-char-int ch)))
|
398
|
114 (cond ((eq (car split) 'cyrillic-iso8859-5)
|
|
115 (aset table (logior (nth 1 split) 128) i)
|
|
116 )
|
|
117 ((eq ch 32))
|
|
118 ((eq (car split) 'ascii)
|
|
119 (aset table ch i)
|
|
120 )))
|
|
121 (setq i (1+ i)))
|
|
122 table)
|
|
123 "Cyrillic KOI8-R encoding table.")
|
|
124
|
|
125 )
|
|
126
|
333
|
127 (define-ccl-program ccl-decode-koi8
|
398
|
128 `(3
|
333
|
129 ((read r0)
|
|
130 (loop
|
398
|
131 (write-read-repeat r0 ,cyrillic-koi8-r-decode-table))))
|
333
|
132 "CCL program to decode KOI8.")
|
|
133
|
|
134 (define-ccl-program ccl-encode-koi8
|
|
135 `(1
|
|
136 ((read r0)
|
|
137 (loop
|
398
|
138 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
139 (write-read-repeat r0)
|
|
140 ((read r0)
|
|
141 (write-read-repeat r0 , cyrillic-koi8-r-encode-table))))))
|
333
|
142 "CCL program to encode KOI8.")
|
|
143
|
412
|
144 ;(make-coding-system
|
|
145 ; 'cyrillic-koi8 4
|
|
146 ; ;; We used to use ?K. It is true that ?K is more strictly correct,
|
|
147 ; ;; but it is also used for Korean.
|
|
148 ; ;; So people who use koi8 for languages other than Russian
|
|
149 ; ;; will have to forgive us.
|
|
150 ; ?R "KOI8 8-bit encoding for Cyrillic (MIME: KOI8-R)"
|
|
151 ; (cons ccl-decode-koi8 ccl-encode-koi8))
|
333
|
152
|
412
|
153 ;(define-coding-system-alias 'koi8-r 'cyrillic-koi8)
|
|
154 ;(define-coding-system-alias 'koi8 'cyrillic-koi8)
|
333
|
155
|
|
156 (make-coding-system
|
|
157 'koi8-r 'ccl
|
|
158 "Coding-system used for KOI8-R."
|
|
159 `(decode ,ccl-decode-koi8
|
|
160 encode ,ccl-encode-koi8
|
|
161 mnemonic "KOI8"))
|
|
162
|
412
|
163 ;(define-coding-system-alias 'koi8-r 'koi8)
|
333
|
164
|
|
165 ;; (define-ccl-program ccl-encode-koi8-font
|
412
|
166 ;; '(0
|
|
167 ;; ((r1 -= 160)
|
|
168 ;; (r1 = r1
|
|
169 ;; [ 32 179 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
170 ;; 225 226 247 231 228 229 246 250 233 234 235 236 237 238 239 240
|
|
171 ;; 242 243 244 245 230 232 227 254 251 253 255 249 248 252 224 241
|
|
172 ;; 193 194 215 199 196 197 214 218 201 202 203 204 205 206 207 208
|
|
173 ;; 210 211 212 213 198 200 195 222 219 221 223 217 216 220 192 209
|
|
174 ;; 32 163 32 32 32 32 32 32 32 32 32 32 32 32 32 32])
|
|
175 ;; ))
|
333
|
176 ;; "CCL program to encode Cyrillic chars to KOI font.")
|
|
177
|
|
178 ;; (setq font-ccl-encoder-alist
|
|
179 ;; (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
|
|
180
|
|
181 (set-language-info-alist
|
412
|
182 "Cyrillic-KOI8" '((setup-function . (setup-cyrillic-koi8-environment
|
|
183 . setup-cyrillic-environment-map))
|
|
184 (charset . (cyrillic-iso8859-5))
|
|
185 (coding-system . (koi8-r))
|
333
|
186 (tutorial . "TUTORIAL.ru")
|
412
|
187 (sample-text . "Russian (.LN@NcNaNaNZNXNY) N7NTN`NPNRNaNbNRNcNYNbNU!")
|
|
188 (documentation . ("Support for Cyrillic KOI-8."
|
|
189 . describe-cyrillic-environment-map))))
|
333
|
190
|
|
191 ;;; ALTERNATIVNYJ staff
|
|
192
|
|
193 (define-ccl-program ccl-decode-alternativnyj
|
412
|
194 '(3
|
333
|
195 ((read r0)
|
|
196 (loop
|
412
|
197 (write-read-repeat
|
|
198 r0
|
|
199 [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
200 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
201 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
202 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
203 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
204 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
205 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
206 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
207 ?.LN0 ?N1 ?N2 ?N3 ?N4 ?N5 ?N6 ?N7 ?N8 ?N9 ?N: ?N; ?N< ?N= ?N> ?N?
|
|
208 ?.LN@ ?NA ?NB ?NC ?ND ?NE ?NF ?NG ?NH ?NI ?NJ ?NK ?NL ?NM ?NN ?NO
|
|
209 ?.LNP ?NQ ?NR ?NS ?NT ?NU ?NV ?NW ?NX ?NY ?NZ ?N[ ?N\ ?N] ?N^ ?N_
|
|
210 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
211 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
212 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
213 ?.LN` ?Na ?Nb ?Nc ?Nd ?Ne ?Nf ?Ng ?Nh ?Ni ?Nj ?Nk ?Nl ?Nm ?Nn ?No
|
|
214 ?.LN! ?Nq 32 32 32 32 32 32 32 32 32 32 32 32 32 ?Np]))))
|
333
|
215 "CCL program to decode Alternativnyj.")
|
|
216
|
|
217 (define-ccl-program ccl-encode-alternativnyj
|
|
218 `(1
|
|
219 ((read r0)
|
|
220 (loop
|
412
|
221 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
222 (write-read-repeat r0)
|
|
223 ((read r0)
|
|
224 (r0 -= 160)
|
|
225 (write-read-repeat
|
|
226 r0
|
|
227 [ 32 240 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
228 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
|
229 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
|
230 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
|
231 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
|
|
232 255 241 32 32 32 32 32 32 32 32 32 32 32 32 32 32])
|
|
233 )))))
|
333
|
234 "CCL program to encode Alternativnyj.")
|
|
235
|
|
236 ;; (make-coding-system
|
412
|
237 ;; 'alternativnyj 4
|
|
238 ;; ?A "Coding-system used for Alternativnyj"
|
|
239 ;; (cons ccl-decode-alternativnyj ccl-encode-alternativnyj))
|
333
|
240
|
|
241 (make-coding-system
|
|
242 'alternativnyj 'ccl
|
|
243 "Coding-system used for Alternativnyj"
|
|
244 `(decode ,ccl-decode-alternativnyj
|
|
245 encode ,ccl-encode-alternativnyj
|
|
246 mnemonic "Cy.Alt"))
|
|
247
|
|
248 ;; (define-ccl-program ccl-encode-alternativnyj-font
|
|
249 ;; '(0
|
412
|
250 ;; ((r1 -= 160)
|
|
251 ;; (r1 = r1
|
|
252 ;; [ 32 240 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
253 ;; 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
|
254 ;; 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
|
255 ;; 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
|
256 ;; 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
|
|
257 ;; 255 241 32 32 32 32 32 32 32 32 32 32 32 32 32 32])
|
|
258 ;; ))
|
333
|
259 ;; "CCL program to encode Cyrillic chars to Alternativnyj font.")
|
|
260
|
|
261 ;; (setq font-ccl-encoder-alist
|
|
262 ;; (cons (cons "alternativnyj" ccl-encode-alternativnyj-font)
|
|
263 ;; font-ccl-encoder-alist))
|
|
264
|
412
|
265 (set-language-info-alist
|
|
266 "Cyrillic-ALT" '((setup-function . (setup-cyrillic-alternativnyj-environment
|
|
267 . setup-cyrillic-environment-map))
|
|
268 (charset . (cyrillic-iso8859-5))
|
|
269 (coding-system . (alternativnyj))
|
|
270 (tutorial . "TUTORIAL.ru")
|
|
271 (sample-text . "Russian (.LN@NcNaNaNZNXNY) N7NTN`NPNRNaNbNRNcNYNbNU!")
|
|
272 (documentation . ("Support for Cyrillic ALTERNATIVNYJ."
|
|
273 . describe-cyrillic-environment-map))))
|
|
274
|
|
275 ;;; GENERAL
|
|
276
|
|
277 (defun setup-cyrillic-environment ()
|
|
278 "Setup multilingual environment for Cyrillic users."
|
|
279 (interactive)
|
|
280 (setq primary-language "Cyrillic")
|
|
281
|
|
282 (setq coding-category-iso-8-1 'iso-8859-5)
|
|
283
|
|
284 (set-coding-priority
|
|
285 '(coding-category-iso-7
|
|
286 coding-category-iso-8-1))
|
|
287
|
|
288 (setq-default buffer-file-coding-system 'iso-8859-5)
|
|
289 (set-terminal-coding-system 'iso-8859-5)
|
|
290 (set-keyboard-coding-system 'iso-8859-5)
|
|
291
|
|
292 (setq default-input-method '("Cyrillic" . "quail-yawerty"))
|
|
293 )
|
|
294
|
|
295 (defun describe-cyrillic-support ()
|
|
296 "Describe how Emacs support Cyrillic."
|
|
297 (interactive)
|
|
298 (describe-language-support-internal "Cyrillic"))
|
398
|
299
|
333
|
300 (set-language-info-alist
|
412
|
301 "Cyrillic" '((setup-function . setup-cyrillic-environment)
|
|
302 (describe-function . describe-cyrillic-support)
|
|
303 (charset . (cyrillic-iso8859-5))
|
|
304 (tutorial . "TUTORIAL.ru")
|
|
305 (coding-system . (iso-8859-5 koi8-r alternativnyj))
|
|
306 (sample-text . "Russian (.LN@NcNaNaNZNXNY) N7NTN`NPNRNaNbNRNcNYNbNU!")
|
|
307 (documentation . nil)))
|
333
|
308
|
|
309 ;;; cyrillic.el ends here
|