cyril-util.el 7.8 KB

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