1;;; cyril-util.el --- utilities for Cyrillic scripts  -*- lexical-binding: t; -*-
2
3;; Copyright (C) 1997-1998, 2001-2021 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 3 of the License, or
12;; (at your option) 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.  If not, see <https://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;;; Code:
25
26;; Fixme: are the next two useful?
27
28;;;###autoload
29(defun cyrillic-encode-koi8-r-char (char)
30  "Return KOI8-R external character code of CHAR if appropriate."
31  (encode-char char 'koi8-r))
32
33;;;###autoload
34(defun cyrillic-encode-alternativnyj-char (char)
35  "Return ALTERNATIVNYJ external character code of CHAR if appropriate."
36  (encode-char char 'alternativnyj))
37
38
39;; Display
40
41;; Written by Valery Alexeev <valery@math.uga.edu>.
42
43(defvar cyrillic-language-alist
44      (list '("Belarusian") '("Bulgarian") '("Macedonian")
45	    '("Russian") '("Serbo-Croatian") '("Ukrainian"))
46      "List of known cyrillic languages.")
47
48;;;###autoload
49(defun standard-display-cyrillic-translit (&optional cyrillic-language)
50  "Display a Cyrillic buffer using a transliteration.
51For readability, the table is slightly
52different from the one used for the input method `cyrillic-translit'.
53
54The argument is a string which specifies which language you are using;
55that affects the choice of transliterations slightly.
56Possible values are listed in `cyrillic-language-alist'.
57If the argument is t, we use the default cyrillic transliteration.
58If the argument is nil, we return the display table to its standard state."
59  (interactive
60   (list
61    (let* ((completion-ignore-case t))
62      (completing-read
63       (format-prompt "Cyrillic language" "nil")
64       cyrillic-language-alist nil t nil nil nil))))
65
66  (or standard-display-table
67      (setq standard-display-table (make-display-table)))
68
69  (if (equal cyrillic-language "")
70      (setq cyrillic-language nil))
71
72  (if (null cyrillic-language)
73      (setq standard-display-table (make-display-table))
74    (aset standard-display-table ?а  [?a])
75    (aset standard-display-table ?б  [?b])
76    (aset standard-display-table ?в  [?v])
77    (aset standard-display-table ?г  [?g])
78    (aset standard-display-table ?д  [?d])
79    (aset standard-display-table ?е  [?e])
80    (aset standard-display-table ?ё  [?y ?o])
81    (aset standard-display-table ?ж  [?z ?h])
82    (aset standard-display-table ?з  [?z])
83    (aset standard-display-table ?и  [?i])
84    (aset standard-display-table ?й  [?j])
85    (aset standard-display-table ?к  [?k])
86    (aset standard-display-table ?л  [?l])
87    (aset standard-display-table ?м  [?m])
88    (aset standard-display-table ?н  [?n])
89    (aset standard-display-table ?о  [?o])
90    (aset standard-display-table ?п  [?p])
91    (aset standard-display-table ?р  [?r])
92    (aset standard-display-table ?с  [?s])
93    (aset standard-display-table ?т  [?t])
94    (aset standard-display-table ?у  [?u])
95    (aset standard-display-table ?ф  [?f])
96    (aset standard-display-table ?х  [?k ?h])
97    (aset standard-display-table ?ц  [?t ?s])
98    (aset standard-display-table ?ч  [?c ?h])
99    (aset standard-display-table ?ш  [?s ?h])
100    (aset standard-display-table ?щ  [?s ?c ?h])
101    (aset standard-display-table ?ъ  [?~])
102    (aset standard-display-table ?ы  [?y])
103    (aset standard-display-table ?ь  [?'])
104    (aset standard-display-table ?э  [?e ?'])
105    (aset standard-display-table ?ю  [?y ?u])
106    (aset standard-display-table ?я  [?y ?a])
107
108    (aset standard-display-table ?А  [?A])
109    (aset standard-display-table ?Б  [?B])
110    (aset standard-display-table ?В  [?V])
111    (aset standard-display-table ?Г  [?G])
112    (aset standard-display-table ?Д  [?D])
113    (aset standard-display-table ?Е  [?E])
114    (aset standard-display-table ?Ё  [?Y ?o])
115    (aset standard-display-table ?Ж  [?Z ?h])
116    (aset standard-display-table ?З  [?Z])
117    (aset standard-display-table ?И  [?I])
118    (aset standard-display-table ?Й  [?J])
119    (aset standard-display-table ?К  [?K])
120    (aset standard-display-table ?Л  [?L])
121    (aset standard-display-table ?М  [?M])
122    (aset standard-display-table ?Н  [?N])
123    (aset standard-display-table ?О  [?O])
124    (aset standard-display-table ?П  [?P])
125    (aset standard-display-table ?Р  [?R])
126    (aset standard-display-table ?С  [?S])
127    (aset standard-display-table ?Т  [?T])
128    (aset standard-display-table ?У  [?U])
129    (aset standard-display-table ?Ф  [?F])
130    (aset standard-display-table ?Х  [?K ?h])
131    (aset standard-display-table ?Ц  [?T ?s])
132    (aset standard-display-table ?Ч  [?C ?h])
133    (aset standard-display-table ?Ш  [?S ?h])
134    (aset standard-display-table ?Щ  [?S ?c ?h])
135    (aset standard-display-table ?Ъ  [?~])
136    (aset standard-display-table ?Ы  [?Y])
137    (aset standard-display-table ?Ь  [?'])
138    (aset standard-display-table ?Э  [?E ?'])
139    (aset standard-display-table ?Ю  [?Y ?u])
140    (aset standard-display-table ?Я  [?Y ?a])
141
142    (aset standard-display-table ?є  [?i ?e])
143    (aset standard-display-table ?ї  [?i])
144    (aset standard-display-table ?ў  [?u])
145    (aset standard-display-table ?ђ  [?d ?j])
146    (aset standard-display-table ?ћ  [?c ?h ?j])
147    (aset standard-display-table ?ѓ  [?g ?j])
148    (aset standard-display-table ?ѕ  [?s])
149    (aset standard-display-table ?ќ  [?k])
150    (aset standard-display-table ?і  [?i])
151    (aset standard-display-table ?ј  [?j])
152    (aset standard-display-table ?љ  [?l ?j])
153    (aset standard-display-table ?њ  [?n ?j])
154    (aset standard-display-table ?џ  [?d ?z])
155    (aset standard-display-table ?ґ  [?g])
156
157    (aset standard-display-table ?Є  [?Y ?e])
158    (aset standard-display-table ?Ї  [?Y ?i])
159    (aset standard-display-table ?Ў  [?U])
160    (aset standard-display-table ?Ђ  [?D ?j])
161    (aset standard-display-table ?Ћ  [?C ?h ?j])
162    (aset standard-display-table ?Ѓ  [?G ?j])
163    (aset standard-display-table ?Ѕ  [?S])
164    (aset standard-display-table ?Ќ  [?K])
165    (aset standard-display-table ?І  [?I])
166    (aset standard-display-table ?Ј  [?J])
167    (aset standard-display-table ?Љ  [?L ?j])
168    (aset standard-display-table ?Њ  [?N ?j])
169    (aset standard-display-table ?Џ  [?D ?j])
170    (aset standard-display-table ?Ґ  [?G])
171
172    (when (equal cyrillic-language "Bulgarian")
173      (aset standard-display-table ?щ [?s ?h ?t])
174      (aset standard-display-table ?Щ [?S ?h ?t])
175      (aset standard-display-table ?ю [?i ?u])
176      (aset standard-display-table ?Ю [?I ?u])
177      (aset standard-display-table ?я [?i ?a])
178      (aset standard-display-table ?Я [?I ?a]))
179
180    (when (equal cyrillic-language "Ukrainian")	; based on the official
181					; transliteration table
182      (aset standard-display-table ?и [?y])
183      (aset standard-display-table ?И [?Y])
184      (aset standard-display-table ?й [?i])
185      (aset standard-display-table ?Й [?Y])
186      (aset standard-display-table ?ю [?i ?u])
187      (aset standard-display-table ?я [?i ?a])
188      (aset standard-display-table ?г [?h])
189      (aset standard-display-table ?Г [?H]))))
190
191;;
192(provide 'cyril-util)
193
194;; Local Variables:
195;; coding: utf-8
196;; End:
197
198;;; cyril-util.el ends here
199