17052
|
1 ;; ethio-util.el -- utilities for Ethiopic
|
|
2
|
|
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
|
|
5
|
|
6 ;; Keywords: mule, multilingual, Chinese
|
|
7
|
|
8 ;; This file is part of GNU Emacs.
|
|
9
|
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
11 ;; it under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
|
15 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 ;; GNU General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
23
|
|
24 ;;; Code:
|
|
25
|
|
26 ;;
|
|
27 ;; ETHIOPIC UTILITY FUNCTIONS
|
|
28 ;;
|
|
29
|
|
30 ;; To automatically convert Ethiopic text to SERA format when sending mail,
|
|
31 ;; (add-hook 'mail-send-hook 'fidel-to-sera-mail)
|
|
32 ;;
|
|
33 ;; To automatically convert SERA format to Ethiopic when receiving mail,
|
|
34 ;; (add-hook 'rmail-show-message-hook 'sera-to-fidel-mail)
|
|
35 ;;
|
|
36 ;; To automatically convert Ethiopic text to SERA format when posting news,
|
|
37 ;; (add-hook 'news-inews-hook 'fidel-to-sera-mail)
|
|
38 ;;
|
|
39 ;; If the filename ends in ".sera", editing will be done in fidel
|
|
40 ;; while file I/O will be done in sera.
|
|
41
|
|
42 ;;
|
|
43 ;; SERA to FIDEL
|
|
44 ;;
|
|
45
|
|
46 (defconst sera-to-fidel-table
|
|
47 [
|
|
48 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
|
|
49 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
|
|
50 ;;; SP ! " # $ % & ' ( ) * + , - . /
|
|
51 nil nil nil nil nil nil nil ("") nil nil nil nil ("$(2$Q(B") nil ("$(2$P(B") nil
|
|
52 ;;; 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
|
|
53 nil nil nil nil nil nil nil nil nil nil ("$(2$S(B") ("$(2$R(B") nil nil nil nil nil
|
|
54 ;;; A
|
|
55 ("$(2"V(B" (?2 "$(2#b(B"))
|
|
56 ;;; B
|
|
57 ("$(2!F(B" (?e "$(2!A(B") (?u "$(2!B(B") (?i "$(2!C(B") (?a "$(2!D(B") (?E "$(2!E(B") (?o "$(2!G(B") (?| "$(2!F(B")
|
|
58 (?W "$(2!H(B" (?a "$(2!H(B")
|
|
59 (?e "$(2!F#L(B") (?u "$(2!F#M(B") (?i "$(2!F#N(B") (?E "$(2!F#P(B") (?' "$(2!F#M(B")))
|
|
60 ;;; C
|
|
61 ("$(2"8(B" (?e "$(2"3(B") (?u "$(2"4(B") (?i "$(2"5(B") (?a "$(2"6(B") (?E "$(2"7(B") (?o "$(2"9(B") (?| "$(2"8(B")
|
|
62 (?W "$(2":(B" (?a "$(2":(B")
|
|
63 (?e "$(2"8#L(B") (?u "$(2"8#M(B") (?i "$(2"8#N(B") (?E "$(2"8#P(B") (?' "$(2"8#M(B")))
|
|
64 ;;; D
|
|
65 ("$(2$0(B" (?e "$(2$+(B") (?u "$(2$,(B") (?i "$(2$-(B") (?a "$(2$.(B") (?E "$(2$/(B") (?o "$(2$1(B") (?| "$(2$0(B"))
|
|
66 ;;; E
|
|
67 ("$(2"W(B" (?2 "$(2#c(B"))
|
|
68 ;;; F
|
|
69 ("$(2"@(B" (?e "$(2";(B") (?u "$(2"<(B") (?i "$(2"=(B") (?a "$(2">(B") (?E "$(2"?(B") (?o "$(2"A(B") (?| "$(2"@(B")
|
|
70 (?W "$(2"B(B" (?a "$(2"B(B")
|
|
71 (?e "$(2"@#L(B") (?u "$(2"@#M(B") (?i "$(2"@#N(B") (?E "$(2"@#P(B") (?' "$(2"@#M(B")))
|
|
72 ;;; G
|
|
73 ("$(2$>(B" (?e "$(2$9(B") (?u "$(2$:(B") (?i "$(2$;(B") (?a "$(2$<(B") (?E "$(2$=(B") (?o "$(2$?(B") (?| "$(2$>(B"))
|
|
74 ;;; H
|
|
75 ("$(2$"(B" (?e "$(2#{(B") (?u "$(2#|(B") (?i "$(2#}(B") (?a "$(2#~(B") (?E "$(2$!(B") (?o "$(2$#(B") (?| "$(2$"(B"))
|
|
76 ;;; I
|
|
77 ("$(2"X(B" (?2 "$(2#d(B"))
|
|
78 ;;; J
|
|
79 ("$(2$7(B" (?e "$(2$2(B") (?u "$(2$3(B") (?i "$(2$4(B") (?a "$(2$5(B") (?E "$(2$6(B") (?o "$(2$8(B") (?| "$(2$7(B"))
|
|
80 ;;; K
|
|
81 ("$(2"x(B" (?e "$(2"s(B") (?u "$(2"t(B") (?i "$(2"u(B") (?a "$(2"v(B") (?E "$(2"w(B") (?o "$(2"y(B") (?| "$(2"x(B")
|
|
82 (?W "$(2"{(B" (?e "$(2"z(B") (?u "$(2"{(B") (?i "$(2"|(B") (?a "$(2"}(B") (?E "$(2"~(B")))
|
|
83 ;;; L
|
|
84 ("$(2!&(B" (?e "$(2!!(B") (?u "$(2!"(B") (?i "$(2!#(B") (?a "$(2!$(B") (?E "$(2!%(B") (?o "$(2!'(B") (?| "$(2!&(B")
|
|
85 (?W "$(2!((B" (?a "$(2!((B")
|
|
86 (?e "$(2!&#L(B") (?u "$(2!&#M(B") (?i "$(2!&#N(B") (?E "$(2!&#P(B") (?' "$(2!&#M(B")))
|
|
87 ;;; M
|
|
88 ("$(2!.(B" (?e "$(2!)(B") (?u "$(2!*(B") (?i "$(2!+(B") (?a "$(2!,(B") (?E "$(2!-(B") (?o "$(2!/(B") (?| "$(2!.(B")
|
|
89 (?W "$(2!0(B" (?a "$(2!0(B")
|
|
90 (?e "$(2!.#L(B") (?u "$(2!.#M(B") (?i "$(2!.#N(B") (?E "$(2!.#P(B") (?' "$(2!.#M(B")))
|
|
91 ;;; N
|
|
92 ("$(2!n(B" (?e "$(2!i(B") (?u "$(2!j(B") (?i "$(2!k(B") (?a "$(2!l(B") (?E "$(2!m(B") (?o "$(2!o(B") (?| "$(2!n(B")
|
|
93 (?W "$(2!p(B" (?a "$(2!p(B")
|
|
94 (?e "$(2!n#L(B") (?u "$(2!n#M(B") (?i "$(2!n#N(B") (?E "$(2!n#P(B") (?' "$(2!n#M(B")))
|
|
95 ;;; O
|
|
96 ("$(2"Y(B" (?2 "$(2#e(B"))
|
|
97 ;;; P
|
|
98 ("$(2$E(B" (?e "$(2$@(B") (?u "$(2$A(B") (?i "$(2$B(B") (?a "$(2$C(B") (?E "$(2$D(B") (?o "$(2$F(B") (?| "$(2$E(B"))
|
|
99 ;;; Q
|
|
100 ("$(2#2(B" (?e "$(2#-(B") (?u "$(2#.(B") (?i "$(2#/(B") (?a "$(2#0(B") (?E "$(2#1(B") (?o "$(2#3(B") (?| "$(2#2(B")
|
|
101 (?W "$(2#5(B" (?e "$(2#4(B") (?u "$(2#5(B") (?i "$(2#6(B") (?a "$(2#7(B") (?E "$(2#8(B")))
|
|
102 ;;; R
|
|
103 ("$(2!6(B" (?e "$(2!1(B") (?u "$(2!2(B") (?i "$(2!3(B") (?a "$(2!4(B") (?E "$(2!5(B") (?o "$(2!7(B") (?| "$(2!6(B")
|
|
104 (?W "$(2!8(B" (?a "$(2!8(B")
|
|
105 (?e "$(2!6#L(B") (?u "$(2!6#M(B") (?i "$(2!6#N(B") (?E "$(2!6#P(B") (?' "$(2!6#M(B")))
|
|
106 ;;; S
|
|
107 ("$(2"P(B" (?e "$(2"K(B") (?u "$(2"L(B") (?i "$(2"M(B") (?a "$(2"N(B") (?E "$(2"O(B") (?o "$(2"Q(B") (?| "$(2"P(B")
|
|
108 (?W "$(2"R(B" (?a "$(2"R(B")
|
|
109 (?e "$(2"P#L(B") (?u "$(2"P#M(B") (?i "$(2"P#N(B") (?E "$(2"P#P(B") (?' "$(2"P#M(B"))
|
|
110 (?2 "$(2#](B" (?| "$(2#](B")
|
|
111 (?e "$(2#X(B") (?u "$(2#Y(B") (?i "$(2#Z(B") (?a "$(2#[(B") (?E "$(2#\(B") (?o "$(2#^(B")
|
|
112 (?W "$(2"R(B"
|
|
113 (?a "$(2"R(B")
|
|
114 (?e "$(2#]#L(B") (?u "$(2#]#M(B") (?i "$(2#]#N(B") (?E "$(2#]#P(B") (?' "$(2#]#M(B"))))
|
|
115
|
|
116 ;;; T
|
|
117 ("$(2"0(B" (?e "$(2"+(B") (?u "$(2",(B") (?i "$(2"-(B") (?a "$(2".(B") (?E "$(2"/(B") (?o "$(2"1(B") (?| "$(2"0(B")
|
|
118 (?W "$(2"2(B" (?a "$(2"2(B")
|
|
119 (?e "$(2"0#L(B") (?u "$(2"0#M(B") (?i "$(2"0#N(B") (?E "$(2"0#P(B") (?' "$(2"0#M(B")))
|
|
120 ;;; U
|
|
121 ("$(2"T(B" (?2 "$(2#`(B"))
|
|
122 ;;; V
|
|
123 ("$(2!N(B" (?e "$(2!I(B") (?u "$(2!J(B") (?i "$(2!K(B") (?a "$(2!L(B") (?E "$(2!M(B") (?o "$(2!O(B") (?| "$(2!N(B")
|
|
124 (?W "$(2!P(B" (?a "$(2!P(B")
|
|
125 (?e "$(2!N#L(B") (?u "$(2!N#M(B") (?i "$(2!N#N(B") (?E "$(2!N#P(B") (?' "$(2!N#M(B")))
|
|
126 ;;; W
|
|
127 ("$(2#M(B" (?e "$(2#L(B") (?u "$(2#M(B") (?i "$(2#N(B") (?a "$(2#O(B") (?E "$(2#P(B"))
|
|
128 ;;; X
|
|
129 ("$(2#y(B" (?e "$(2#t(B") (?u "$(2#u(B") (?i "$(2#v(B") (?a "$(2#w(B") (?E "$(2#x(B") (?o "$(2#z(B") (?| "$(2#y(B"))
|
|
130 ;;; Y
|
|
131 ("$(2$)(B" (?e "$(2$$(B") (?u "$(2$%(B") (?i "$(2$&(B") (?a "$(2$'(B") (?E "$(2$((B") (?o "$(2$*(B") (?| "$(2$)(B"))
|
|
132 ;;; Z
|
|
133 ("$(2!~(B" (?e "$(2!y(B") (?u "$(2!z(B") (?i "$(2!{(B") (?a "$(2!|(B") (?E "$(2!}(B") (?o "$(2"!(B") (?| "$(2!~(B")
|
|
134 (?W "$(2""(B" (?a "$(2""(B")
|
|
135 (?e "$(2!~#L(B") (?u "$(2!~#M(B") (?i "$(2!~#N(B") (?E "$(2!~#P(B") (?' "$(2!~#M(B")))
|
|
136 ;;; [ \ ] ^ _
|
|
137 nil nil nil nil nil
|
|
138 ;;; `
|
|
139 ("`"
|
|
140 (?e "$(2#_(B") (?u "$(2#`(B") (?U "$(2#`(B") (?i "$(2#a(B") (?a "$(2#b(B") (?A "$(2#b(B")
|
|
141 (?E "$(2#c(B") (?I "$(2#d(B") (?o "$(2#e(B") (?O "$(2#e(B")
|
|
142 (?s "$(2#V(B"
|
|
143 (?e "$(2#Q(B") (?u "$(2#R(B") (?i "$(2#S(B") (?a "$(2#T(B") (?E "$(2#U(B") (?o "$(2#W(B") (?| "$(2#V(B")
|
|
144 (?W "$(2"J(B" (?a "$(2"J(B")
|
|
145 (?e "$(2#V#L(B") (?u "$(2#V#M(B") (?i "$(2#V#N(B") (?E "$(2#V#P(B") (?' "$(2#V#M(B")))
|
|
146 (?S "$(2#](B"
|
|
147 (?e "$(2#X(B") (?u "$(2#Y(B") (?i "$(2#Z(B") (?a "$(2#[(B") (?E "$(2#\(B") (?o "$(2#^(B") (?| "$(2#](B")
|
|
148 (?W "$(2"R(B" (?a "$(2"R(B")
|
|
149 (?e "$(2#]#L(B") (?u "$(2#]#M(B") (?i "$(2#]#N(B") (?E "$(2#]#P(B") (?' "$(2#]#M(B")))
|
|
150 (?h "$(2#k(B"
|
|
151 (?e "$(2#f(B") (?u "$(2#g(B") (?i "$(2#h(B") (?a "$(2#i(B") (?E "$(2#j(B") (?o "$(2#l(B") (?| "$(2#k(B")
|
|
152 (?W "$(2"c(B" (?e "$(2"b(B") (?u "$(2"c(B") (?i "$(2"d(B") (?a "$(2"e(B") (?E "$(2"f(B")))
|
|
153 (?k "$(2#r(B"
|
|
154 (?e "$(2#m(B") (?u "$(2#n(B") (?i "$(2#o(B") (?a "$(2#p(B") (?E "$(2#q(B") (?o "$(2#s(B") (?| "$(2#r(B")))
|
|
155 ;;; a
|
|
156 ("$(2"S(B" (?2 "$(2#b(B"))
|
|
157
|
|
158 ;;; b
|
|
159 ("$(2!F(B" (?e "$(2!A(B") (?u "$(2!B(B") (?i "$(2!C(B") (?a "$(2!D(B") (?E "$(2!E(B") (?o "$(2!G(B") (?| "$(2!F(B")
|
|
160 (?W "$(2!H(B" (?a "$(2!H(B")
|
|
161 (?e "$(2!F#L(B") (?u "$(2!F#M(B") (?i "$(2!F#N(B") (?E "$(2!F#P(B") (?' "$(2!F#M(B")))
|
|
162 ;;; c
|
|
163 ("$(2!^(B" (?e "$(2!Y(B") (?u "$(2!Z(B") (?i "$(2![(B") (?a "$(2!\(B") (?E "$(2!](B") (?o "$(2!_(B") (?| "$(2!^(B")
|
|
164 (?W "$(2!`(B" (?a "$(2!`(B")
|
|
165 (?e "$(2!^#L(B") (?u "$(2!^#M(B") (?i "$(2!^#N(B") (?E "$(2!^#P(B") (?' "$(2!^#M(B")))
|
|
166 ;;; d
|
|
167 ("$(2"((B" (?e "$(2"#(B") (?u "$(2"$(B") (?i "$(2"%(B") (?a "$(2"&(B") (?E "$(2"'(B") (?o "$(2")(B") (?| "$(2"((B")
|
|
168 (?W "$(2"*(B" (?a "$(2"*(B")
|
|
169 (?e "$(2"(#L(B") (?u "$(2"(#M(B") (?i "$(2"(#N(B") (?E "$(2"(#P(B") (?' "$(2"(#M(B")))
|
|
170 ;;; e
|
|
171 ("$(2"S(B" (?2 "$(2#_(B") (?3 "$(2"Z(B"))
|
|
172 ;;; f
|
|
173 ("$(2"@(B" (?e "$(2";(B") (?u "$(2"<(B") (?i "$(2"=(B") (?a "$(2">(B") (?E "$(2"?(B") (?o "$(2"A(B") (?| "$(2"@(B")
|
|
174 (?W "$(2"B(B" (?a "$(2"B(B")
|
|
175 (?e "$(2"@#L(B") (?u "$(2"@#M(B") (?i "$(2"@#N(B") (?E "$(2"@#P(B") (?' "$(2"@#M(B")))
|
|
176 ;;; g
|
|
177 ("$(2#>(B" (?e "$(2#9(B") (?u "$(2#:(B") (?i "$(2#;(B") (?a "$(2#<(B") (?E "$(2#=(B") (?o "$(2#?(B") (?| "$(2#>(B")
|
|
178 (?W "$(2#A(B" (?e "$(2#@(B") (?u "$(2#A(B") (?i "$(2#B(B") (?a "$(2#C(B") (?E "$(2#D(B")))
|
|
179 ;;; h
|
|
180 ("$(2"`(B" (?e "$(2"[(B") (?u "$(2"\(B") (?i "$(2"](B") (?a "$(2"^(B") (?E "$(2"_(B") (?o "$(2"a(B") (?| "$(2"`(B")
|
|
181 (?W "$(2"c(B" (?e "$(2"b(B") (?u "$(2"c(B") (?i "$(2"d(B") (?a "$(2"e(B") (?E "$(2"f(B"))
|
|
182 (?2 "$(2#k(B" (?e "$(2#f(B") (?u "$(2#g(B") (?i "$(2#h(B") (?a "$(2#i(B") (?E "$(2#j(B") (?o "$(2#l(B")
|
|
183 (?| "$(2#k(B")
|
|
184 (?W "$(2"c(B" (?e "$(2"b(B") (?u "$(2"c(B") (?i "$(2"d(B") (?a "$(2"e(B") (?E "$(2"f(B"))))
|
|
185 ;;; i
|
|
186 ("$(2"U(B" (?2 "$(2#a(B"))
|
|
187 ;;; j
|
|
188 ("$(2$7(B" (?e "$(2$2(B") (?u "$(2$3(B") (?i "$(2$4(B") (?a "$(2$5(B") (?E "$(2$6(B") (?o "$(2$8(B") (?| "$(2$7(B"))
|
|
189 ;;; k
|
|
190 ("$(2"l(B" (?e "$(2"g(B") (?u "$(2"h(B") (?i "$(2"i(B") (?a "$(2"j(B") (?E "$(2"k(B") (?o "$(2"m(B") (?| "$(2"l(B")
|
|
191 (?W "$(2"o(B" (?e "$(2"n(B") (?u "$(2"o(B") (?i "$(2"p(B") (?a "$(2"q(B") (?E "$(2"r(B"))
|
|
192 (?2 "$(2#r(B" (?e "$(2#m(B") (?u "$(2#n(B") (?i "$(2#o(B") (?a "$(2#p(B") (?E "$(2#q(B") (?o "$(2#s(B")
|
|
193 (?| "$(2#r(B")))
|
|
194 ;;; l
|
|
195 ("$(2!&(B" (?e "$(2!!(B") (?u "$(2!"(B") (?i "$(2!#(B") (?a "$(2!$(B") (?E "$(2!%(B") (?o "$(2!'(B") (?| "$(2!&(B")
|
|
196 (?W "$(2!((B" (?a "$(2!((B")
|
|
197 (?e "$(2!&#L(B") (?u "$(2!&#M(B") (?i "$(2!&#N(B") (?E "$(2!&#P(B") (?' "$(2!&#M(B")))
|
|
198 ;;; m
|
|
199 ("$(2!.(B" (?e "$(2!)(B") (?u "$(2!*(B") (?i "$(2!+(B") (?a "$(2!,(B") (?E "$(2!-(B") (?o "$(2!/(B") (?| "$(2!.(B")
|
|
200 (?W "$(2!0(B" (?a "$(2!0(B")
|
|
201 (?e "$(2!.#L(B") (?u "$(2!.#M(B") (?i "$(2!.#N(B") (?E "$(2!.#P(B") (?' "$(2!.#M(B")))
|
|
202 ;;; n
|
|
203 ("$(2!f(B" (?e "$(2!a(B") (?u "$(2!b(B") (?i "$(2!c(B") (?a "$(2!d(B") (?E "$(2!e(B") (?o "$(2!g(B") (?| "$(2!f(B")
|
|
204 (?W "$(2!h(B" (?a "$(2!h(B")
|
|
205 (?e "$(2!f#L(B") (?u "$(2!f#M(B") (?i "$(2!f#N(B") (?E "$(2!f#P(B") (?' "$(2!f#M(B")))
|
|
206 ;;; o
|
|
207 ("$(2"Y(B" (?2 "$(2#e(B"))
|
|
208 ;;; p
|
|
209 ("$(2$L(B" (?e "$(2$G(B") (?u "$(2$H(B") (?i "$(2$I(B") (?a "$(2$J(B") (?E "$(2$K(B") (?o "$(2$M(B") (?| "$(2$L(B"))
|
|
210 ;;; q
|
|
211 ("$(2#&(B" (?e "$(2#!(B") (?u "$(2#"(B") (?i "$(2##(B") (?a "$(2#$(B") (?E "$(2#%(B") (?o "$(2#'(B") (?| "$(2#&(B")
|
|
212 (?W "$(2#)(B" (?e "$(2#((B") (?u "$(2#)(B") (?i "$(2#*(B") (?a "$(2#+(B") (?E "$(2#,(B")))
|
|
213 ;;; r
|
|
214 ("$(2!6(B" (?e "$(2!1(B") (?u "$(2!2(B") (?i "$(2!3(B") (?a "$(2!4(B") (?E "$(2!5(B") (?o "$(2!7(B") (?| "$(2!6(B")
|
|
215 (?W "$(2!8(B" (?a "$(2!8(B")
|
|
216 (?e "$(2!6#L(B") (?u "$(2!6#M(B") (?i "$(2!6#N(B") (?E "$(2!6#P(B") (?' "$(2!6#M(B")))
|
|
217 ;;; s
|
|
218 ("$(2"H(B" (?e "$(2"C(B") (?u "$(2"D(B") (?i "$(2"E(B") (?a "$(2"F(B") (?E "$(2"G(B") (?o "$(2"I(B") (?| "$(2"H(B")
|
|
219 (?W "$(2"J(B" (?a "$(2"J(B")
|
|
220 (?e "$(2"H#L(B") (?u "$(2"H#M(B") (?i "$(2"H#N(B") (?E "$(2"H#P(B") (?' "$(2"H#M(B"))
|
|
221 (?2 "$(2#V(B" (?e "$(2#Q(B") (?u "$(2#R(B") (?i "$(2#S(B") (?a "$(2#T(B") (?E "$(2#U(B") (?o "$(2#W(B")
|
|
222 (?| "$(2#V(B")
|
|
223 (?W "$(2"J(B" (?a "$(2"J(B")
|
|
224 (?e "$(2#V#L(B") (?u "$(2#V#M(B") (?i "$(2#V#N(B") (?E "$(2#V#P(B")
|
|
225 (?' "$(2#V#M(B"))))
|
|
226 ;;; t
|
|
227 ("$(2!V(B" (?e "$(2!Q(B") (?u "$(2!R(B") (?i "$(2!S(B") (?a "$(2!T(B") (?E "$(2!U(B") (?o "$(2!W(B") (?| "$(2!V(B")
|
|
228 (?W "$(2!X(B" (?a "$(2!X(B")
|
|
229 (?e "$(2!V#L(B") (?u "$(2!V#M(B") (?i "$(2!V#N(B") (?E "$(2!V#P(B") (?' "$(2!V#M(B")))
|
|
230 ;;; u
|
|
231 ("$(2"T(B" (?2 "$(2#`(B"))
|
|
232 ;;; v
|
|
233 ("$(2!N(B" (?e "$(2!I(B") (?u "$(2!J(B") (?i "$(2!K(B") (?a "$(2!L(B") (?E "$(2!M(B") (?o "$(2!O(B") (?| "$(2!N(B")
|
|
234 (?W "$(2!P(B" (?a "$(2!P(B")
|
|
235 (?e "$(2!N#L(B") (?u "$(2!N#M(B") (?i "$(2!N#N(B") (?E "$(2!N#P(B") (?' "$(2!N#M(B")))
|
|
236 ;;; w
|
|
237 ("$(2#J(B" (?e "$(2#E(B") (?u "$(2#F(B") (?i "$(2#G(B") (?a "$(2#H(B") (?E "$(2#I(B") (?o "$(2#K(B") (?| "$(2#J(B")
|
|
238 (?W "$(2#M(B" (?e "$(2#L(B") (?u "$(2#M(B") (?i "$(2#N(B") (?a "$(2#O(B") (?E "$(2#P(B")))
|
|
239 ;;; x
|
|
240 ("$(2!>(B" (?e "$(2!9(B") (?u "$(2!:(B") (?i "$(2!;(B") (?a "$(2!<(B") (?E "$(2!=(B") (?o "$(2!?(B") (?| "$(2!>(B")
|
|
241 (?W "$(2!@(B" (?a "$(2!@(B")
|
|
242 (?e "$(2!>#L(B") (?u "$(2!>#M(B") (?i "$(2!>#N(B") (?E "$(2!>#P(B") (?' "$(2!>#M(B")))
|
|
243 ;;; y
|
|
244 ("$(2$)(B" (?e "$(2$$(B") (?u "$(2$%(B") (?i "$(2$&(B") (?a "$(2$'(B") (?E "$(2$((B") (?o "$(2$*(B") (?| "$(2$)(B"))
|
|
245 ;;; z
|
|
246 ("$(2!v(B" (?e "$(2!q(B") (?u "$(2!r(B") (?i "$(2!s(B") (?a "$(2!t(B") (?E "$(2!u(B") (?o "$(2!w(B") (?| "$(2!v(B")
|
|
247 (?W "$(2!x(B" (?a "$(2!x(B")
|
|
248 (?e "$(2!v#L(B") (?u "$(2!v#M(B") (?i "$(2!v#N(B") (?E "$(2!v#P(B") (?' "$(2!v#M(B")))
|
|
249 ])
|
|
250
|
|
251 ;;;###autoload
|
|
252 (defun sera-to-fidel-region (beg end &optional ascii-mode force)
|
|
253 "Translates the characters in region from SERA to FIDEL.
|
|
254
|
|
255 If the 1st optional parameter ASCII-MODE is non-NIL, assumes that the
|
|
256 region begins in ASCII script.
|
|
257
|
|
258 If the 2nd optional parametr FORCE is non-NIL, translates even if the
|
|
259 buffer is read-only."
|
|
260
|
|
261 (interactive "r\nP")
|
|
262 (save-excursion
|
|
263 (save-restriction
|
|
264 (narrow-to-region beg end)
|
|
265 (sera-to-fidel-buffer ascii-mode force))))
|
|
266
|
|
267 ;;;###autoload
|
|
268 (defun sera-to-fidel-buffer (&optional ascii-mode force)
|
|
269 "Translates the current buffer from SERA to FIDEL.
|
|
270
|
|
271 If the 1st optional parameter ASCII-MODE is non-NIL, assumes that the
|
|
272 current buffer begins in ASCII script.
|
|
273
|
|
274 If the 2nd optional panametr FORCE is non-NIL, translates even if the
|
|
275 buffer is read-only."
|
|
276
|
|
277 (interactive "P")
|
|
278 (if (and buffer-read-only
|
|
279 (not force)
|
|
280 (not (y-or-n-p "Buffer is read-only. Force to convert? ")))
|
|
281 (error ""))
|
|
282 (let (start pre fol hard table table2 (buffer-read-only nil))
|
|
283 (goto-char (point-min))
|
|
284 (while (not (eobp))
|
|
285 (setq start (point))
|
|
286 (forward-char 1)
|
|
287 (setq pre (preceding-char)
|
|
288 fol (following-char))
|
|
289
|
|
290 (if ascii-mode
|
|
291 (cond
|
|
292
|
|
293 ;; ascii mode, pre != \
|
|
294 ((/= pre ?\\ ))
|
|
295
|
|
296 ;; ascii mode, pre = \, fol = !
|
|
297 ((= fol ?!)
|
|
298 (backward-delete-char 1)
|
|
299 (delete-char 1)
|
|
300 (setq ascii-mode nil
|
|
301 hard (not hard)))
|
|
302
|
|
303 ;; hard ascii mode, pre = \, fol != !
|
|
304 (hard)
|
|
305
|
|
306 ;; soft ascii mode, pre = \, fol = {\ _ * < > 0..9 ~}
|
|
307 ((or (backward-delete-char 1) ; always nil
|
|
308 (eobp)
|
|
309 (sera-to-fidel-backslash)))
|
|
310
|
|
311 ;; soft ascii mode, pre = \, fol = SPC
|
|
312 ((= fol 32)
|
|
313 (delete-char 1)
|
|
314 (setq ascii-mode nil))
|
|
315
|
|
316 ;; soft ascii mode, pre = \, fol = .
|
|
317 ((= fol ?.)
|
|
318 (delete-char 1)
|
|
319 (insert ?$(2$P(B))
|
|
320
|
|
321 ;; soft ascii mode, pre = \, fol = ,
|
|
322 ((= fol ?,)
|
|
323 (delete-char 1)
|
|
324 (insert ?$(2$Q(B))
|
|
325
|
|
326 ;; soft ascii mode, pre = \, fol = ;
|
|
327 ((= fol ?\;)
|
|
328 (delete-char 1)
|
|
329 (insert ?$(2$R(B))
|
|
330
|
|
331 ;; soft ascii mode, pre = \, fol = :
|
|
332 ((= fol ?:)
|
|
333 (delete-char 1)
|
|
334 (insert ?$(2$S(B))
|
|
335
|
|
336 ;; soft ascii mode, pre = \, fol = others
|
|
337 (t
|
|
338 (setq ascii-mode nil)))
|
|
339
|
|
340 (cond
|
|
341
|
|
342 ;; very special: skip "<" to ">" (or "&" to ";") if in w3-mode
|
|
343 ((and (boundp 'sera-being-called-by-w3)
|
|
344 sera-being-called-by-w3
|
|
345 (or (= pre ?<) (= pre ?&)))
|
|
346 (search-forward (if (= pre ?<) ">" ";")
|
|
347 nil 0))
|
|
348
|
|
349 ;; ethio mode, pre != sera
|
|
350 ((or (< pre ?') (> pre ?z)))
|
|
351
|
|
352 ;; ethio mode, pre != \
|
|
353 ((/= pre ?\\ )
|
|
354 (setq table (aref sera-to-fidel-table pre))
|
|
355 (while (setq table2 (cdr (assoc (following-char) table)))
|
|
356 (setq table table2)
|
|
357 (forward-char 1))
|
|
358 (if (car table)
|
|
359 (progn
|
|
360 (delete-region start (point))
|
|
361 (insert (car table)))))
|
|
362
|
|
363 ;; ethio mode, pre = \, fol = !
|
|
364 ((= fol ?!)
|
|
365 (backward-delete-char 1)
|
|
366 (delete-char 1)
|
|
367 (setq ascii-mode t
|
|
368 hard (not hard)))
|
|
369
|
|
370 ;; hard ethio mode, pre = \, fol != !
|
|
371 (hard)
|
|
372
|
|
373 ;; soft ethio mode, pre = \, fol = {\ _ * < > 0..9 ~}
|
|
374 ((or (backward-delete-char 1) ; always nil
|
|
375 (eobp)
|
|
376 (sera-to-fidel-backslash)))
|
|
377
|
|
378 ;; soft ethio mode, pre = \, fol = SPC
|
|
379 ((= fol 32)
|
|
380 (delete-char 1)
|
|
381 (setq ascii-mode t))
|
|
382
|
|
383 ;; soft ethio mode, pre = \, fol = {. , ; : | ' `}
|
|
384 ((memq fol '(?. ?, ?\; ?: ?| ?' ?`))
|
|
385 (forward-char 1))
|
|
386
|
|
387 ;; soft ethio mode, pre = \, fol = others
|
|
388 (t
|
|
389 (setq ascii-mode t))))))
|
|
390 (goto-char (point-min)))
|
|
391
|
|
392 (defun sera-to-fidel-backslash ()
|
|
393 "Handle SERA backslash escapes common to ethio- and ascii-mode.
|
|
394 Returns t if something has been processed."
|
|
395 (let ((ch (following-char))
|
|
396 (converted t))
|
|
397 (if (and (>= ch ?1) (<= ch ?9))
|
|
398 (ethio-convert-digit)
|
|
399 (delete-char 1)
|
|
400 (cond
|
|
401 ((= ch ?\\ )
|
|
402 (insert ?\\ ))
|
|
403 ((= ch ?_)
|
|
404 (insert ?$(2$O(B))
|
|
405 ((= ch ?*)
|
|
406 (insert ?$(2$T(B))
|
|
407 ((= ch ?<)
|
|
408 (insert ?$(2$U(B))
|
|
409 ((= ch ?>)
|
|
410 (insert ?$(2$V(B))
|
|
411 ((= ch ?~)
|
|
412 (setq ch (following-char))
|
|
413 (delete-char 1)
|
|
414 (cond
|
|
415 ((= ch ?e)
|
|
416 (insert "$(2$k(B"))
|
|
417 ((= ch ?E)
|
|
418 (insert "$(2$l(B"))
|
|
419 ((= ch ?a)
|
|
420 (insert "$(2$m(B"))
|
|
421 ((= ch ?A)
|
|
422 (insert "$(2$n(B"))))
|
|
423 (t
|
|
424 (insert ch)
|
|
425 (backward-char 1)
|
|
426 (setq converted nil))))
|
|
427 converted))
|
|
428
|
|
429 (defun ethio-convert-digit ()
|
|
430 "Convert Arabic digits to Ethiopic digits."
|
|
431 (let (ch z)
|
|
432 (while (and (>= (setq ch (following-char)) ?1)
|
|
433 (<= ch ?9))
|
|
434 (delete-char 1)
|
|
435
|
|
436 ;; count up following zeros
|
|
437 (setq z 0)
|
|
438 (while (= (following-char) ?0)
|
|
439 (delete-char 1)
|
|
440 (setq z (1+ z)))
|
|
441
|
|
442 (cond
|
|
443
|
|
444 ;; first digit is 10, 20, ..., or 90
|
|
445 ((= (mod z 2) 1)
|
|
446 ;; (- ch 40) means ?1 -> 9, ?2 -> 10, etc.
|
|
447 (insert (aref [?$(2$`(B ?$(2$a(B ?$(2$b(B ?$(2$c(B ?$(2$d(B ?$(2$e(B ?$(2$f(B ?$(2$g(B ?$(2$h(B] (- ch ?1)))
|
|
448 (setq z (1- z)))
|
|
449
|
|
450 ;; first digit is 2, 3, ..., or 9
|
|
451 ((/= ch ?1)
|
|
452 (insert (aref [?$(2$X(B ?$(2$Y(B ?$(2$Z(B ?$(2$[(B ?$(2$\(B ?$(2$](B ?$(2$^(B ?$(2$_(B] (- ch ?2))))
|
|
453
|
|
454 ;; single 1
|
|
455 ((= z 0)
|
|
456 (insert "$(2$W(B")))
|
|
457
|
|
458 ;; 100
|
|
459 (if (= (mod z 4) 2)
|
|
460 (insert"$(2$i(B"))
|
|
461
|
|
462 ;; 10000
|
|
463 (insert-char ?$(2$j(B (/ z 4)))))
|
|
464
|
|
465 ;;;###autoload
|
|
466 (defun sera-to-fidel-mail (&optional arg)
|
|
467 "Does SERA to FIDEL conversion for reading/writing mail and news.
|
|
468
|
|
469 If the buffer contains the markers \"<sera>\" and \"</sera>\",
|
|
470 converts the segment between the two markers in Ethio start mode and
|
|
471 the subject field in ASCII start mode.
|
|
472
|
|
473 If invoked interactively and there is no marker, converts both the
|
|
474 whole body and the subject field in Ethio start mode.
|
|
475
|
|
476 For backward compatibility, \"<ethiopic>\" and \"<>\" can be used instead of
|
|
477 \"<sera>\" and \"</sera>\"."
|
|
478
|
|
479 (interactive "p")
|
|
480 (let* ((buffer-read-only nil) border)
|
|
481
|
|
482 (save-excursion
|
|
483 (goto-char (point-min))
|
|
484 (setq border
|
|
485 (search-forward
|
|
486 (if (eq major-mode 'rmail-mode)
|
|
487 "\n\n"
|
|
488 (concat "\n" mail-header-separator "\n"))))
|
|
489
|
|
490 (cond
|
|
491
|
|
492 ;; with markers
|
|
493 ((re-search-forward "^<sera>\n" nil t)
|
|
494 (goto-char (match-beginning 0))
|
|
495 (while (re-search-forward "^<sera>\n" nil t)
|
|
496 (replace-match "" nil t)
|
|
497 (sera-to-fidel-region
|
|
498 (point)
|
|
499 (progn
|
|
500 (if (re-search-forward "^</sera>\n" nil 0)
|
|
501 (replace-match "" nil t))
|
|
502 (point))))
|
|
503
|
|
504 (goto-char (point-min))
|
|
505 (if (re-search-forward "^Subject: " border t)
|
|
506 (sera-to-fidel-region
|
|
507 (point)
|
|
508 (progn (end-of-line) (point))
|
|
509 'ascii-start)))
|
|
510
|
|
511 ;; backward compatibility
|
|
512 ((re-search-forward "^<ethiopic>\n" nil t)
|
|
513 (goto-char (match-beginning 0))
|
|
514 (while (re-search-forward "^<ethiopic>\n" nil t)
|
|
515 (replace-match "" nil t)
|
|
516 (sera-to-fidel-region
|
|
517 (setq border (point))
|
|
518 (progn
|
|
519 (if (re-search-forward "^<>\n" nil 0)
|
|
520 (replace-match "" nil t))
|
|
521 (point))))
|
|
522
|
|
523 (goto-char (point-min))
|
|
524 (if (re-search-forward "^Subject: " border t)
|
|
525 (sera-to-fidel-region
|
|
526 (point)
|
|
527 (progn (end-of-line) (point))
|
|
528 'ascii-start)))
|
|
529
|
|
530 ;; interactive & no markers
|
|
531 (arg
|
|
532 (sera-to-fidel-region border (point-max))
|
|
533 (goto-char (point-min))
|
|
534 (if (re-search-forward "^Subject: " border t)
|
|
535 (sera-to-fidel-region
|
|
536 (point)
|
|
537 (progn (end-of-line) (point))))))
|
|
538
|
|
539 ;; adjust the rmail marker
|
|
540 (if (eq major-mode 'rmail-mode)
|
|
541 (set-marker
|
|
542 (aref rmail-message-vector (1+ rmail-current-message))
|
|
543 (point-max))))))
|
|
544
|
|
545 ;;;###autoload
|
|
546 (defun sera-to-fidel-marker ()
|
|
547 "If the buffer contains the markers \"<sera>\" and \"</sera>\",
|
|
548 converts the segment between the two markers from SERA to Fidel
|
|
549 in Ethio start mode. The markers will not be removed."
|
|
550
|
|
551 (interactive)
|
|
552 (if (and buffer-read-only
|
|
553 (not (y-or-n-p "Buffer is read-only. Force to convert? ")))
|
|
554 (error ""))
|
|
555 (save-excursion
|
|
556 (goto-char (point-min))
|
|
557 (while (re-search-forward "<sera>" nil t)
|
|
558 (sera-to-fidel-region
|
|
559 (point)
|
|
560 (if (re-search-forward "</sera>" nil t)
|
|
561 (match-beginning 0)
|
|
562 (point-max))
|
|
563 nil
|
|
564 'force))))
|
|
565
|
|
566 ;;
|
|
567 ;; FIDEL to SERA
|
|
568 ;;
|
|
569
|
|
570 (defconst fidel-to-sera-map
|
|
571 ["le" "lu" "li" "la" "lE" "l" "lo" "lWa"
|
|
572 "me" "mu" "mi" "ma" "mE" "m" "mo" "mWa"
|
|
573 "re" "ru" "ri" "ra" "rE" "r" "ro" "rWa"
|
|
574 "xe" "xu" "xi" "xa" "xE" "x" "xo" "xWa"
|
|
575 "be" "bu" "bi" "ba" "bE" "b" "bo" "bWa"
|
|
576 "ve" "vu" "vi" "va" "vE" "v" "vo" "vWa"
|
|
577 "te" "tu" "ti" "ta" "tE" "t" "to" "tWa"
|
|
578 "ce" "cu" "ci" "ca" "cE" "c" "co" "cWa"
|
|
579 "ne" "nu" "ni" "na" "nE" "n" "no" "nWa"
|
|
580 "Ne" "Nu" "Ni" "Na" "NE" "N" "No" "NWa"
|
|
581 "ze" "zu" "zi" "za" "zE" "z" "zo" "zWa"
|
|
582 "Ze" "Zu" "Zi" "Za" "ZE" "Z" "Zo" "ZWa"
|
|
583 "de" "du" "di" "da" "dE" "d" "do" "dWa"
|
|
584 "Te" "Tu" "Ti" "Ta" "TE" "T" "To" "TWa"
|
|
585 "Ce" "Cu" "Ci" "Ca" "CE" "C" "Co" "CWa"
|
|
586 "fe" "fu" "fi" "fa" "fE" "f" "fo" "fWa"
|
|
587 "se" "su" "si" "sa" "sE" "s" "so" "sWa"
|
|
588 "Se" "Su" "Si" "Sa" "SE" "S" "So" "SWa"
|
|
589 "a" "u" "i" "A" "E" "I" "o" "e3"
|
|
590 "he" "hu" "hi" "ha" "hE" "h" "ho" "hWe" "hWu" "hWi" "hWa" "hWE"
|
|
591 "ke" "ku" "ki" "ka" "kE" "k" "ko" "kWe" "kWu" "kWi" "kWa" "kWE"
|
|
592 "Ke" "Ku" "Ki" "Ka" "KE" "K" "Ko" "KWe" "KWu" "KWi" "KWa" "KWE"
|
|
593 "qe" "qu" "qi" "qa" "qE" "q" "qo" "qWe" "qWu" "qWi" "qWa" "qWE"
|
|
594 "Qe" "Qu" "Qi" "Qa" "QE" "Q" "Qo" "QWe" "QWu" "QWi" "QWa" "QWE"
|
|
595 "ge" "gu" "gi" "ga" "gE" "g" "go" "gWe" "gWu" "gWi" "gWa" "gWE"
|
|
596 "we" "wu" "wi" "wa" "wE" "w" "wo" "wWe" "wWu" "wWi" "wWa" "wWE"
|
|
597 "`se" "`su" "`si" "`sa" "`sE" "`s" "`so"
|
|
598 "`Se" "`Su" "`Si" "`Sa" "`SE" "`S" "`So"
|
|
599 "`e" "`u" "`i" "`a" "`E" "`I" "`o"
|
|
600 "`he" "`hu" "`hi" "`ha" "`hE" "`h" "`ho"
|
|
601 "`ke" "`ku" "`ki" "`ka" "`kE" "`k" "`ko"
|
|
602 "Xe" "Xu" "Xi" "Xa" "XE" "X" "Xo"
|
|
603 "He" "Hu" "Hi" "Ha" "HE" "H" "Ho"
|
|
604 "ye" "yu" "yi" "ya" "yE" "y" "yo"
|
|
605 "De" "Du" "Di" "Da" "DE" "D" "Do"
|
|
606 "je" "ju" "ji" "ja" "jE" "j" "jo"
|
|
607 "Ge" "Gu" "Gi" "Ga" "GE" "G" "Go"
|
|
608 "Pe" "Pu" "Pi" "Pa" "PE" "P" "Po"
|
|
609 "pe" "pu" "pi" "pa" "pE" "p" "po"
|
|
610 " " "\\_" "." "," ";" ":" "\\*" "\\<" "\\>"
|
|
611 "1" "2" "3" "4" "5" "6" "7" "8" "9"
|
|
612 "10" "20" "30" "40" "50" "60" "70" "80" "90"
|
|
613 "100" "10000"
|
|
614 "\\~e" "\\~E" "\\~a" "\\~A"])
|
|
615
|
|
616 (defvar ethio-use-tigrigna-style nil
|
|
617 "*If non-NIL, use \"e\" instead of \"a\" for the first lone vowel
|
|
618 translation in sera-to-fidel and fidel-to-sera conversions.")
|
|
619
|
|
620 (defvar ethio-quote-vowel-always nil
|
|
621 "*If non-NIL, lone vowels are always transcribed by \"an apostrophe
|
|
622 + the vowel\" except at word initial. Otherwise, they are quoted by
|
|
623 an apostrophe only if the preceding Ethiopic character is a lone
|
|
624 consonant.")
|
|
625
|
|
626 (defvar ethio-W-sixth-always nil
|
|
627 "*If non-NIL, the Wu-form of a 12-form consonant is transcribed by
|
|
628 \"W'\" instead of \"Wu\".")
|
|
629
|
|
630 (defvar ethio-numeric-reduction 0
|
|
631 "*Degree of reduction in transcribing Ethiopic digits by Arabic
|
|
632 digits. For example, $(2$`$_$i$g$](B ({10}{9}{100}{80}{7}) will be
|
|
633 transcribed by:
|
|
634 \10\9\100\80\7 if ETHIO-NUMERIC-REDUCTION is 0,
|
|
635 \109100807 is 1,
|
|
636 \10900807 is 2.")
|
|
637
|
|
638 ;;;###autoload
|
|
639 (defun fidel-to-sera-region (begin end &optional ascii-mode force)
|
|
640 "Replaces all the FIDEL characters in the region to sera format.
|
|
641
|
|
642 If the 1st optional parameter ASCII-MODE is non-NIL, converts the
|
|
643 region so that it begins in ASCII script.
|
|
644
|
|
645 If the 2nd optional parameter FORCE is non-NIL, converts even if the
|
|
646 buffer is read-only."
|
|
647
|
|
648 (interactive "r\nP")
|
|
649 (save-excursion
|
|
650 (save-restriction
|
|
651 (narrow-to-region begin end)
|
|
652 (fidel-to-sera-buffer ascii-mode force))))
|
|
653
|
|
654 ;;;###autoload
|
|
655 (defun fidel-to-sera-buffer (&optional ascii-mode force)
|
|
656 "Replace all the FIDEL characters in the current buffer to sera format.
|
|
657
|
|
658 If the 1st optional parameter ASCII-MODE is non-NIL,
|
|
659 convert the current buffer so that it begins in ASCII script.
|
|
660
|
|
661 If the 2nd optional parameter FORCE is non-NIL, converts even if the
|
|
662 buffer is read-only.
|
|
663
|
|
664 See also the description of the variables ethio-use-tigrigna-style,
|
|
665 ethio-quote-vowel-on-demand and ethio-numeric-reduction."
|
|
666
|
|
667 (interactive "P")
|
|
668 (if (and buffer-read-only
|
|
669 (not force)
|
|
670 (not (y-or-n-p "Buffer is read-only. Force to convert? ")))
|
|
671 (error ""))
|
|
672
|
|
673 ;; user's preference in transcription
|
|
674 (aset fidel-to-sera-map 144 (if ethio-use-tigrigna-style "e" "a"))
|
|
675 (let ((i 160)
|
|
676 (x (if ethio-W-sixth-always
|
|
677 '("hW'" "kW'" "KW'" "qW'" "QW'" "gW'" "wW'")
|
|
678 '("hWu" "kWu" "KWu" "qWu" "QWu" "gWu" "wWu"))))
|
|
679 (while x
|
|
680 (aset fidel-to-sera-map i (car x))
|
|
681 (setq i (+ i 12)
|
|
682 x (cdr x))))
|
|
683
|
|
684 ;; main conversion routine
|
|
685 (let ((lonec nil) ; if lonec = t, previous char was a lone consonant.
|
|
686 (fidel nil) ; if fidel = t, previous char was a fidel.
|
|
687 (digit nil) ; if digit = t, previous char was an Ethiopic digit.
|
|
688 (buffer-read-only nil)
|
|
689 ch)
|
|
690 (goto-char (point-min))
|
|
691 (while (not (eobp))
|
|
692 (setq ch (following-char))
|
|
693
|
|
694 ;; ethiopic charactes
|
|
695 (if (eq (char-charset ch) 'ethiopic)
|
|
696 (progn
|
|
697 (setq ch (char-to-ethiocode ch))
|
|
698 (delete-char 1)
|
|
699
|
|
700 (cond
|
|
701
|
|
702 ;; fidels
|
|
703 ((<= ch 326)
|
|
704 (if ascii-mode
|
|
705 (insert "\\ "))
|
|
706 (if (and (memq ch '(144 145 146 147 148 150 151)) ; (auiAEoe3)
|
|
707 (or lonec
|
|
708 (and ethio-quote-vowel-always
|
|
709 fidel)))
|
|
710 (insert "'"))
|
|
711 (insert (aref fidel-to-sera-map ch))
|
|
712 (setq ascii-mode nil
|
|
713 lonec (ethio-lone-consonant-p ch)
|
|
714 fidel t
|
|
715 digit nil))
|
|
716
|
|
717 ;; punctuations and symbols
|
|
718 ((or (< ch 336) (> ch 355))
|
|
719 (if (and ascii-mode
|
|
720 (memq ch '(329 330 331 332))) ; (.,;:)
|
|
721 (insert "\\"))
|
|
722 (insert (aref fidel-to-sera-map ch))
|
|
723 (setq lonec nil
|
|
724 fidel nil
|
|
725 digit nil))
|
|
726
|
|
727 ;; now CH must be an ethiopic digit
|
|
728
|
|
729 ;; reduction = 0 or leading digit
|
|
730 ((or (= ethio-numeric-reduction 0)
|
|
731 (not digit))
|
|
732 (insert "\\" (aref fidel-to-sera-map ch))
|
|
733 (setq lonec nil
|
|
734 fidel nil
|
|
735 digit t))
|
|
736
|
|
737 ;; reduction = 2 and following 10s, 100s, 10000s
|
|
738 ((and (= ethio-numeric-reduction 2)
|
|
739 (memq ch '(345 354 355)))
|
|
740 (insert (substring (aref fidel-to-sera-map ch) 1))
|
|
741 (setq lonec nil
|
|
742 fidel nil
|
|
743 digit t))
|
|
744
|
|
745 ;; ordinary following digits
|
|
746 (t
|
|
747 (insert (aref fidel-to-sera-map ch))
|
|
748 (setq lonec nil
|
|
749 fidel nil
|
|
750 digit t))))
|
|
751
|
|
752 ;; non-ethiopic characters
|
|
753 (cond
|
|
754
|
|
755 ;; backslash is always quoted
|
|
756 ((= ch ?\\ )
|
|
757 (insert "\\"))
|
|
758
|
|
759 ;; nothing to do if in ascii-mode
|
|
760 (ascii-mode)
|
|
761
|
|
762 ;; ethio-mode -> ascii-mode
|
|
763 ((or (and (>= ch ?a) (<= ch ?z))
|
|
764 (and (>= ch ?A) (<= ch ?Z))
|
|
765 (memq ch '(?| ?' ?`)))
|
|
766 (insert "\\ ")
|
|
767 (setq ascii-mode t))
|
|
768
|
|
769 ;; ascii punctuations in ethio-mode
|
|
770 ((memq ch '(?. ?, ?\; ?:))
|
|
771 (insert "\\")))
|
|
772
|
|
773 (forward-char 1)
|
|
774 (setq lonec nil
|
|
775 fidel nil
|
|
776 digit nil)))
|
|
777
|
|
778 ;; a few modifications for readability
|
|
779 (goto-char (point-min))
|
|
780 (while (re-search-forward "\\([]!\"#$%&()*+/<=>?@[^_-]+\\)\\\\ " nil t)
|
|
781 (replace-match "\\\\ \\1"))
|
|
782
|
|
783 (goto-char (point-min))
|
|
784 (while (re-search-forward "\n\\([ \t]*\\)\\\\ " nil t)
|
|
785 (replace-match "\\\\\n\\1")))
|
|
786
|
|
787 (goto-char (point-min)))
|
|
788
|
|
789 (defun ethio-lone-consonant-p (code)
|
|
790 "If the ethiocode CODE is an Ethiopic lone consonant, return t."
|
|
791 (cond
|
|
792 ((< code 144)
|
|
793 (= (mod code 8) 5))
|
|
794 ((< code 153)
|
|
795 nil)
|
|
796 ((< code 236)
|
|
797 (= (mod code 12) 1))
|
|
798 ((< code 327)
|
|
799 (= (mod code 7) 3))))
|
|
800
|
|
801 ;;;###autoload
|
|
802 (defun fidel-to-sera-mail ()
|
|
803 "Does FIDEL to SERA conversion for reading/writing mail and news.
|
|
804
|
|
805 If the buffer contains at least one Ethiopic character,
|
|
806 1) inserts the string \"<sera>\" right after the header-body separator,
|
|
807 2) inserts \"</sera>\" at the end of the buffer,
|
|
808 3) converts the body into SERA in Ethiopic start mode, and
|
|
809 4) converts the subject field in ASCII start mode."
|
|
810
|
|
811 (interactive)
|
|
812 (save-excursion
|
|
813 (goto-char (point-min))
|
|
814 (if (re-search-forward "\\cE" nil t)
|
|
815 (let ((buffer-read-only nil) border)
|
|
816
|
|
817 (goto-char (point-min))
|
|
818 (setq border
|
|
819 (search-forward
|
|
820 (if (eq major-mode 'rmail-mode)
|
|
821 "\n\n"
|
|
822 (concat "\n" mail-header-separator "\n"))))
|
|
823 (insert "<sera>\n")
|
|
824
|
|
825 (fidel-to-sera-region (point) (point-max))
|
|
826
|
|
827 (goto-char (point-max))
|
|
828 (if (/= (preceding-char) ?\n)
|
|
829 (insert "\n"))
|
|
830 (insert "</sera>\n")
|
|
831
|
|
832 (goto-char (point-min))
|
|
833 (if (re-search-forward "^Subject: " border t)
|
|
834 (fidel-to-sera-region
|
|
835 (point)
|
|
836 (progn (end-of-line) (point))
|
|
837 'ascii-start))
|
|
838
|
|
839 ;; adjust the rmail marker
|
|
840 (if (eq major-mode 'rmail-mode)
|
|
841 (set-marker
|
|
842 (aref rmail-message-vector (1+ rmail-current-message))
|
|
843 (point-max))))
|
|
844
|
|
845 (message "No Ethiopic characters in this buffer."))))
|
|
846
|
|
847 ;;;###autoload
|
|
848 (defun fidel-to-sera-marker ()
|
|
849 "If the buffer contains the markers \"<sera>\" and \"</sera>\",
|
|
850 converts the segment between the two markers from Fidel to SERA
|
|
851 in Ethio start mode. The markers will not be removed."
|
|
852
|
|
853 (interactive)
|
|
854 (if (and buffer-read-only
|
|
855 (not (y-or-n-p "Buffer is read-only. Force to convert? ")))
|
|
856 (error ""))
|
|
857 (save-excursion
|
|
858 (goto-char (point-min))
|
|
859 (while (re-search-forward "^<sera>\n" nil t)
|
|
860 (fidel-to-sera-region
|
|
861 (point)
|
|
862 (if (re-search-forward "^</sera>\n" nil t)
|
|
863 (match-beginning 0)
|
|
864 (point-max))
|
|
865 nil
|
|
866 'force))))
|
|
867
|
|
868 ;;
|
|
869 ;; file I/O hooks
|
|
870 ;;
|
|
871
|
|
872 (if (not (assoc "\\.sera$" auto-mode-alist))
|
|
873 (setq auto-mode-alist
|
|
874 (cons '("\\.sera$" . sera-to-fidel-find-file) auto-mode-alist)))
|
|
875 (add-hook 'write-file-hooks 'fidel-to-sera-write-file)
|
|
876 (add-hook 'after-save-hook 'sera-to-fidel-after-save)
|
|
877
|
|
878 ;;;###autoload
|
|
879 (defun sera-to-fidel-find-file ()
|
|
880 "Intended to be called when a file whose name ends in \".sera\" is read in."
|
|
881 (sera-to-fidel-buffer nil 'force)
|
|
882 (set-buffer-modified-p nil)
|
|
883 nil)
|
|
884
|
|
885 ;;;###autoload
|
|
886 (defun fidel-to-sera-write-file ()
|
|
887 "Intended to be used as write-file-hooks for the files
|
|
888 whose name ends in \".sera\"."
|
|
889 (if (string-match "\\.sera$" (buffer-file-name))
|
|
890 (save-excursion
|
|
891 (fidel-to-sera-buffer nil 'force)
|
|
892 (set-buffer-modified-p nil)))
|
|
893 nil)
|
|
894
|
|
895 ;;;###autoload
|
|
896 (defun sera-to-fidel-after-save ()
|
|
897 "Intended to be used as after-save-hook for the files
|
|
898 whose name ends in \".sera\"."
|
|
899 (if (string-match "\\.sera$" (buffer-file-name))
|
|
900 (save-excursion
|
|
901 (sera-to-fidel-buffer nil 'force)
|
|
902 (set-buffer-modified-p nil)))
|
|
903 nil)
|
|
904
|
|
905 ;;
|
|
906 ;; vowel modification
|
|
907 ;;
|
|
908
|
|
909 ;;;###autoload
|
|
910 (defun ethio-modify-vowel ()
|
|
911 "Modify the vowel of the FIDEL that is under the cursor."
|
|
912 (interactive)
|
|
913 (let ((ch (following-char)) newch base vowel)
|
|
914 (if (eq (char-charset ch) 'ethiopic)
|
|
915 (setq ch (char-to-ethiocode ch))
|
|
916 (error "Not a valid character."))
|
|
917 (if (or (and (>= ch 144) (<= ch 151)) ; lone vowels
|
|
918 (and (>= ch 250) (<= ch 256)) ; secondary lone vowels
|
|
919 (>= ch 327)) ; not FIDEL
|
|
920 (error "Not a valid character."))
|
|
921 (message "Modify vowel to: ")
|
|
922 (if (null (setq vowel (memq (read-char) '(?e ?u ?i ?a ?E ?' ?o))))
|
|
923 (error "Not a valid vowel.")
|
|
924 ;; ?e -> 0, ?u -> 1, ?i -> 2, ?a -> 3, ?E -> 4, ?' -> 5, ?o -> 6
|
|
925 (setq vowel (- 7 (length vowel))))
|
|
926
|
|
927 (cond
|
|
928
|
|
929 ;; 8-form consonant
|
|
930 ((<= ch 143)
|
|
931 (setq base (* (/ ch 8) 8))
|
|
932 (cond
|
|
933 ((< (mod ch 8) 7) ; e-form <= ch <= o-form
|
|
934 (setq newch (+ base vowel)))
|
|
935 ((= vowel 3) ; 3 = a
|
|
936 (setq newch (+ base 7))) ; (+ base 7) = Wa-form
|
|
937 ((= vowel 5) ; 5 = '
|
|
938 (setq newch
|
|
939 (cons (+ base 5) ; (+ base 5) = lone consonant
|
|
940 232))) ; 232 = Wu
|
|
941 (t
|
|
942 (setq newch
|
|
943 (cons (+ base 5) ; (+ base 5) = lone consonant
|
|
944 (+ 231 vowel)))))) ; 231 = We
|
|
945
|
|
946 ;; 12-form consonant
|
|
947 ((<= ch 235)
|
|
948 (setq ch (- ch 152) ; 152 = 12-form consonant offset
|
|
949 base (* (/ ch 12) 12))
|
|
950 (cond
|
|
951 ((< (mod ch 12) 7) ; e-form <= ch <= o-form
|
|
952 (setq newch (+ base vowel 152)))
|
|
953 ((< vowel 5) ; We-form <= ch <= WE-form
|
|
954 (setq newch (+ base vowel 159))) ; 159 = 152 (offset) + 7 (We-form)
|
|
955 ((= vowel 5) ; 5 = ' (= u in this case)
|
|
956 (setq newch (+ base 160))) ; 160 = 152 (offset) + 8 (Wu-form)
|
|
957 (t
|
|
958 (error "Not a valid vowel."))))
|
|
959
|
|
960 ;; 7-form consonant
|
|
961 (t ; 236 = 7-form consonant offset
|
|
962 (setq newch (+ (* (/ (- ch 236) 7) 7) vowel 236))))
|
|
963
|
|
964 (delete-char 1)
|
|
965
|
|
966 (cond
|
|
967 ((consp newch)
|
|
968 (insert (ethiocode-to-char (car newch))
|
|
969 (ethiocode-to-char (cdr newch)))
|
|
970 (backward-char 2))
|
|
971 (t
|
|
972 (insert (ethiocode-to-char newch))
|
|
973 (backward-char 1)))))
|
|
974
|
|
975 (defun ethiocode-to-char (code)
|
|
976 (make-char 'ethiopic (/ code 94) (mod code 94)))
|
|
977
|
|
978 (defun char-to-ethiocode (ch)
|
|
979 (and (eq (char-charset ch) 'ethiopic)
|
|
980 (let ((char-components (split-char ch)))
|
|
981 (+ (* (- (nth char-components 1) 161) 94)
|
|
982 (- (nth char-components 2) 161)))))
|
|
983
|
|
984 ;;
|
|
985 ;; space replacement
|
|
986 ;;
|
|
987
|
|
988 ;;;###autoload
|
|
989 (defun ethio-replace-space (ch begin end)
|
|
990 "In the specified region, replace spaces between two Ethiopic characters."
|
|
991 (interactive "*cReplace spaces to: 1 (sg col), 2 (dbl col), 3 (Ethiopic)\nr")
|
|
992 (if (not (memq ch '(?1 ?2 ?3)))
|
|
993 (error ""))
|
|
994 (save-excursion
|
|
995 (save-restriction
|
|
996 (narrow-to-region begin end)
|
|
997 (goto-char (point-min))
|
|
998
|
|
999 (cond
|
|
1000
|
|
1001 ((= ch ?1)
|
|
1002
|
|
1003 ;; A double column space or an Ethiopic word separator is always
|
|
1004 ;; converted to an ASCII space.
|
|
1005 (while (re-search-forward "[$(2$N$O(B]" nil t)
|
|
1006 (replace-match " " nil nil)))
|
|
1007
|
|
1008 ((= ch ?2)
|
|
1009
|
|
1010 ;; An Ethiopic word separator is always converted to
|
|
1011 ;; a double column space.
|
|
1012 (while (search-forward "$(2$O(B" nil t)
|
|
1013 (replace-match "$(2$N(B"))
|
|
1014
|
|
1015 (goto-char (point-min))
|
|
1016
|
|
1017 ;; ASCII spaces are converted only if they are placed
|
|
1018 ;; between two Ethiopic characters.
|
|
1019 (while (re-search-forward "\\(\\cE\\)\\( \\)\\( *\\cE\\)" nil t)
|
|
1020
|
|
1021 ;; Converting the first ASCII space
|
|
1022 (replace-match "\\1$(2$N(B\\3")
|
|
1023
|
|
1024 ;; A double column space is \cE, so going back to the just
|
|
1025 ;; converted double column space makes it possible to find
|
|
1026 ;; the following ASCII spaces.
|
|
1027 (goto-char (match-beginning 2))))
|
|
1028
|
|
1029 ((= ch ?3)
|
|
1030
|
|
1031 ;; If more than one consecutive space (either ASCII or double
|
|
1032 ;; width) is found between two Ethiopic characters, the first
|
|
1033 ;; space will be converted to an Ethiopic word separator.
|
|
1034 (let (pred succ)
|
|
1035 (while (re-search-forward "[ $(2$N(B]\\([ $(2$N(B]*\\)" nil t)
|
|
1036 (and (setq pred (char-before (match-beginning 0)))
|
|
1037 (eq (char-charset pred) 'ethiopic)
|
|
1038 (setq succ (char-after (match-end 0)))
|
|
1039 (eq (char-charset succ) 'ethiopic)
|
|
1040 (replace-match "$(2$O(B\\1" nil nil)))))))))
|
|
1041
|
|
1042 ;;
|
|
1043 ;; special characters
|
|
1044 ;;
|
|
1045
|
|
1046 ;;;###autoload
|
|
1047 (defun ethio-input-special-character (arg)
|
|
1048 "Allow the user to input special characters."
|
|
1049 (interactive "*cInput number: 1.$(2$k(B 2.$(2$l(B 3.$(2$m(B 4.$(2$n(B")
|
|
1050 (cond
|
|
1051 ((= arg ?1)
|
|
1052 (insert ?$(2$k(B))
|
|
1053 ((= arg ?2)
|
|
1054 (insert ?$(2$l(B))
|
|
1055 ((= arg ?3)
|
|
1056 (insert ?$(2$m(B))
|
|
1057 ((= arg ?4)
|
|
1058 (insert ?$(2$n(B))
|
|
1059 (t
|
|
1060 (error ""))))
|
|
1061
|
|
1062 ;;
|
|
1063 (provide 'language/ethio-util)
|
|
1064
|
|
1065 ;;; Local Variables:
|
|
1066 ;;; generated-autoload-file: "../loaddefs.el"
|
|
1067 ;;; End:
|
|
1068 ;;; ethio-util.el ends here
|