]> code.delx.au - gnu-emacs/blob - lisp/language/cyril-util.el
(thai-pre-write-conversion): Use with-temp-buffer.
[gnu-emacs] / lisp / language / cyril-util.el
1 ;;; cyril-util.el --- utilities for Cyrillic scripts
2
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
4
5 ;; Keywords: mule, multilingual, Cyrillic
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Code:
25
26 ;;;###autoload
27 (defun setup-cyrillic-iso-environment ()
28 "Setup multilingual environment (MULE) for Cyrillic ISO-8859-5 users."
29 (interactive)
30 (set-language-environment "Cyrillic-ISO"))
31
32 ;;;###autoload
33 (defun setup-cyrillic-koi8-environment ()
34 "Setup multilingual environment (MULE) for Cyrillic KOI8 users."
35 (interactive)
36 (set-language-environment "Cyrillic-KOI8"))
37
38 ;;;###autoload
39 (defun setup-cyrillic-alternativnyj-environment ()
40 "Setup multilingual environment (MULE) for Cyrillic ALTERNATIVNYJ users."
41 (interactive)
42 (set-language-environment "Cyrillic-ALT"))
43
44 ;;;###autoload
45 (defun cyrillic-encode-koi8-r-char (char)
46 "Return KOI8-R external character code of CHAR if appropriate."
47 (aref (char-table-extra-slot cyrillic-koi8-r-nonascii-translation-table 0)
48 char))
49
50 ;;;###autoload
51 (defun cyrillic-encode-alternativnyj-char (char)
52 "Return ALTERNATIVNYJ external character code of CHAR if appropriate."
53 (aref (char-table-extra-slot
54 cyrillic-alternativnyj-nonascii-translation-table 0)
55 char))
56
57 \f
58 ;; Display
59
60 ;; Written by Valery Alexeev <valery@math.uga.edu>.
61
62 (defvar cyrillic-language-alist
63 (list '("Belorussian") '("Bulgarian") '("Macedonian")
64 '("Russian") '("Serbo-Croatian") '("Ukrainian"))
65 "*List of known cyrillic languages")
66
67 ;;;###autoload
68 (defun standard-display-cyrillic-translit (&optional cyrillic-language)
69 "Display a cyrillic buffer using a transliteration.
70 For readability, the table is slightly
71 different from the one used for the input method `cyrillic-translit'.
72
73 The argument is a string which specifies which language you are using;
74 that affects the choice of transliterations slightly.
75 Possible values are listed in 'cyrillic-language-alist'.
76 If the argument is t, we use the default cyrillic transliteration.
77 If the argument is nil, we return the display table to its standard state."
78 (interactive
79 (list
80 (let* ((completion-ignore-case t))
81 (completing-read
82 "Cyrillic language (default nil): "
83 cyrillic-language-alist nil t nil nil nil))))
84
85 (or standard-display-table
86 (setq standard-display-table (make-display-table)))
87
88 (if (equal cyrillic-language "")
89 (setq cyrillic-language nil))
90
91 (if (null cyrillic-language)
92 (setq standard-display-table (make-display-table))
93 (aset standard-display-table ?\e,LP\e(B [?a])
94 (aset standard-display-table ?\e,LQ\e(B [?b])
95 (aset standard-display-table ?\e,LR\e(B [?v])
96 (aset standard-display-table ?\e,LS\e(B [?g])
97 (aset standard-display-table ?\e,LT\e(B [?d])
98 (aset standard-display-table ?\e,LU\e(B [?e])
99 (aset standard-display-table ?\e,Lq\e(B [?y?o])
100 (aset standard-display-table ?\e,LV\e(B [?z?h])
101 (aset standard-display-table ?\e,LW\e(B [?z])
102 (aset standard-display-table ?\e,LX\e(B [?i])
103 (aset standard-display-table ?\e,LY\e(B [?j])
104 (aset standard-display-table ?\e,LZ\e(B [?k])
105 (aset standard-display-table ?\e,L[\e(B [?l])
106 (aset standard-display-table ?\e,L\\e(B [?m])
107 (aset standard-display-table ?\e,L]\e(B [?n])
108 (aset standard-display-table ?\e,L^\e(B [?o])
109 (aset standard-display-table ?\e,L_\e(B [?p])
110 (aset standard-display-table ?\e,L`\e(B [?r])
111 (aset standard-display-table ?\e,La\e(B [?s])
112 (aset standard-display-table ?\e,Lb\e(B [?t])
113 (aset standard-display-table ?\e,Lc\e(B [?u])
114 (aset standard-display-table ?\e,Ld\e(B [?f])
115 (aset standard-display-table ?\e,Le\e(B [?k?h])
116 (aset standard-display-table ?\e,Lf\e(B [?t?s])
117 (aset standard-display-table ?\e,Lg\e(B [?c?h])
118 (aset standard-display-table ?\e,Lh\e(B [?s?h])
119 (aset standard-display-table ?\e,Li\e(B [?s?c?h])
120 (aset standard-display-table ?\e,Lj\e(B [?~])
121 (aset standard-display-table ?\e,Lk\e(B [?y])
122 (aset standard-display-table ?\e,Ll\e(B [?'])
123 (aset standard-display-table ?\e,Lm\e(B [?e?'])
124 (aset standard-display-table ?\e,Ln\e(B [?y?u])
125 (aset standard-display-table ?\e,Lo\e(B [?y?a])
126
127 (aset standard-display-table ?\e,L0\e(B [?A])
128 (aset standard-display-table ?\e,L1\e(B [?B])
129 (aset standard-display-table ?\e,L2\e(B [?V])
130 (aset standard-display-table ?\e,L3\e(B [?G])
131 (aset standard-display-table ?\e,L4\e(B [?D])
132 (aset standard-display-table ?\e,L5\e(B [?E])
133 (aset standard-display-table ?\e,L!\e(B [?Y?o])
134 (aset standard-display-table ?\e,L6\e(B [?Z?h])
135 (aset standard-display-table ?\e,L7\e(B [?Z])
136 (aset standard-display-table ?\e,L8\e(B [?I])
137 (aset standard-display-table ?\e,L9\e(B [?J])
138 (aset standard-display-table ?\e,L:\e(B [?K])
139 (aset standard-display-table ?\e,L;\e(B [?L])
140 (aset standard-display-table ?\e,L<\e(B [?M])
141 (aset standard-display-table ?\e,L=\e(B [?N])
142 (aset standard-display-table ?\e,L>\e(B [?O])
143 (aset standard-display-table ?\e,L?\e(B [?P])
144 (aset standard-display-table ?\e,L@\e(B [?R])
145 (aset standard-display-table ?\e,LA\e(B [?S])
146 (aset standard-display-table ?\e,LB\e(B [?T])
147 (aset standard-display-table ?\e,LC\e(B [?U])
148 (aset standard-display-table ?\e,LD\e(B [?F])
149 (aset standard-display-table ?\e,LE\e(B [?K?h])
150 (aset standard-display-table ?\e,LF\e(B [?T?s])
151 (aset standard-display-table ?\e,LG\e(B [?C?h])
152 (aset standard-display-table ?\e,LH\e(B [?S?h])
153 (aset standard-display-table ?\e,LI\e(B [?S?c?h])
154 (aset standard-display-table ?\e,LJ\e(B [?~])
155 (aset standard-display-table ?\e,LK\e(B [?Y])
156 (aset standard-display-table ?\e,LL\e(B [?'])
157 (aset standard-display-table ?\e,LM\e(B [?E?'])
158 (aset standard-display-table ?\e,LN\e(B [?Y?u])
159 (aset standard-display-table ?\e,LO\e(B [?Y?a])
160
161 (aset standard-display-table ?\e,Lt\e(B [?i?e])
162 (aset standard-display-table ?\e,Lw\e(B [?i])
163 (aset standard-display-table ?\e,L~\e(B [?u])
164 (aset standard-display-table ?\e,Lr\e(B [?d?j])
165 (aset standard-display-table ?\e,L{\e(B [?c?h?j])
166 (aset standard-display-table ?\e,Ls\e(B [?g?j])
167 (aset standard-display-table ?\e,Lu\e(B [?s])
168 (aset standard-display-table ?\e,L|\e(B [?k])
169 (aset standard-display-table ?\e,Lv\e(B [?i])
170 (aset standard-display-table ?\e,Lx\e(B [?j])
171 (aset standard-display-table ?\e,Ly\e(B [?l?j])
172 (aset standard-display-table ?\e,Lz\e(B [?n?j])
173 (aset standard-display-table ?\e,L\7f\e(B [?d?z])
174
175 (aset standard-display-table ?\e,L$\e(B [?Y?e])
176 (aset standard-display-table ?\e,L'\e(B [?Y?i])
177 (aset standard-display-table ?\e,L.\e(B [?U])
178 (aset standard-display-table ?\e,L"\e(B [?D?j])
179 (aset standard-display-table ?\e,L+\e(B [?C?h?j])
180 (aset standard-display-table ?\e,L#\e(B [?G?j])
181 (aset standard-display-table ?\e,L%\e(B [?S])
182 (aset standard-display-table ?\e,L,\e(B [?K])
183 (aset standard-display-table ?\e,L&\e(B [?I])
184 (aset standard-display-table ?\e,L(\e(B [?J])
185 (aset standard-display-table ?\e,L)\e(B [?L?j])
186 (aset standard-display-table ?\e,L*\e(B [?N?j])
187 (aset standard-display-table ?\e,L/\e(B [?D?j])
188
189 (when (equal cyrillic-language "Bulgarian")
190 (aset standard-display-table ?\e,Li\e(B [?s?h?t])
191 (aset standard-display-table ?\e,LI\e(B [?S?h?t])
192 (aset standard-display-table ?\e,Ln\e(B [?i?u])
193 (aset standard-display-table ?\e,LN\e(B [?I?u])
194 (aset standard-display-table ?\e,Lo\e(B [?i?a])
195 (aset standard-display-table ?\e,LO\e(B [?I?a]))
196
197 (when (equal cyrillic-language "Ukrainian") ; based on the official
198 ; transliteration table
199 (aset standard-display-table ?\e,LX\e(B [?y])
200 (aset standard-display-table ?\e,L8\e(B [?Y])
201 (aset standard-display-table ?\e,LY\e(B [?i])
202 (aset standard-display-table ?\e,L9\e(B [?Y])
203 (aset standard-display-table ?\e,Ln\e(B [?i?u])
204 (aset standard-display-table ?\e,Lo\e(B [?i?a]))))
205
206
207 ;;
208 (provide 'cyril-util)
209
210 ;;; cyril-util.el ends here
211
212 ;; Local Variables:
213 ;; buffer-file-coding-system: iso-2022-7bit
214 ;; End: