Mercurial > emacs
annotate lisp/language/ethio-util.el @ 17768:93caf447ed72
Make functions setup-LANGUAGE-environment
interactive and add new functions describe-LANGUAGE-support for
all LANGUAGEs supported. Remove resisterations of input methods
which use the function encoded-kbd-select-terminal.
Typo in comment fixed.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 12 May 1997 07:00:09 +0000 |
parents | a3ca5e15c82a |
children | ade41b936c3e |
rev | line source |
---|---|
17315
a3ca5e15c82a
Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents:
17314
diff
changeset
|
1 ;;; ethio-util.el --- utilities for Ethiopic |
17052 | 2 |
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. | |
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
5 | |
17299 | 6 ;; Keywords: mule, multilingual, Ethiopic |
17052 | 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 | |
17314
f438ebf1c679
Fix FSF address in comment.
Kenichi Handa <handa@m17n.org>
parents:
17299
diff
changeset
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
f438ebf1c679
Fix FSF address in comment.
Kenichi Handa <handa@m17n.org>
parents:
17299
diff
changeset
|
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
f438ebf1c679
Fix FSF address in comment.
Kenichi Handa <handa@m17n.org>
parents:
17299
diff
changeset
|
23 ;; Boston, MA 02111-1307, USA. |
17299 | 24 |
25 ;; Author: TAKAHASHI Naoto <ntakahas@etl.go.jp> | |
17052 | 26 |
27 ;;; Code: | |
28 | |
29 ;; | |
30 ;; ETHIOPIC UTILITY FUNCTIONS | |
31 ;; | |
32 | |
17299 | 33 ;; If the filename ends in ".sera", editing is done in fidel |
34 ;; but file I/O is done in SERA. | |
35 ;; | |
36 ;; If the filename ends in ".java", editing is done in fidel | |
37 ;; but file I/O is done in the \uXXXX style, where XXXX is | |
38 ;; the Unicode codepoint for the Ethiopic character. | |
39 ;; | |
40 ;; If the filename ends in ".tex", editing is done in fidel | |
41 ;; but file I/O is done in EthioTeX format. | |
42 ;; | |
17052 | 43 ;; To automatically convert Ethiopic text to SERA format when sending mail, |
17299 | 44 ;; (add-hook 'mail-send-hook 'ethio-fidel-to-sera-mail) |
17052 | 45 ;; |
46 ;; To automatically convert SERA format to Ethiopic when receiving mail, | |
17299 | 47 ;; (add-hook 'rmail-show-message-hook 'ethio-sera-to-fidel-mail) |
17052 | 48 ;; |
49 ;; To automatically convert Ethiopic text to SERA format when posting news, | |
17299 | 50 ;; (add-hook 'news-inews-hook 'ethio-fidel-to-sera-mail) |
51 | |
52 ;; | |
53 ;; users' preference | |
17052 | 54 ;; |
17299 | 55 |
56 (defvar ethio-primary-language 'tigrigna | |
57 "*Symbol that defines the primary language in SERA --> FIDEL conversion. | |
58 The value should be one of: `tigrigna', `amharic' or `english'.") | |
59 | |
60 (defvar ethio-secondary-language 'english | |
61 "*Symbol that defines the secondary language in SERA --> FIDEL conversion. | |
62 The value should be one of: `tigrigna', `amharic' or `english'.") | |
63 | |
64 (defvar ethio-use-colon-for-colon nil | |
65 "*Non-nil means associate ASCII colon with Ethiopic colon. | |
66 If nil, associate ASCII colon with Ethiopic word separator, i.e., two | |
67 vertically stacked dots. All SERA <--> FIDEL converters refer this | |
68 variable.") | |
69 | |
70 (defvar ethio-use-three-dot-question nil | |
71 "*Non-nil means associate ASCII question mark with Ethiopic old style question mark (three vertically stacked dots). | |
72 If nil, associate ASCII question mark with Ethiopic stylised question | |
73 mark. All SERA <--> FIDEL converters refer this variable.") | |
74 | |
75 (defvar ethio-quote-vowel-always nil | |
76 "*Non-nil means always put an apostrophe before an isolated vowel (except at word initial) in FIDEL --> SERA conversion. | |
77 If nil, put an apostrophe only between a sixth-form consonant and an | |
78 isolated vowel.") | |
79 | |
80 (defvar ethio-W-sixth-always nil | |
81 "*Non-nil means convert the Wu-form of a 12-form consonant to \"W'\" instead of \"Wu\" in FIDEL --> SERA conversion.") | |
82 | |
83 (defvar ethio-numeric-reduction 0 | |
84 "*Degree of reduction in converting Ethiopic digits into Arabic digits. | |
85 Should be 0, 1 or 2. | |
86 For example, ({10}{9}{100}{80}{7}) is converted into: | |
87 `10`9`100`80`7 if `ethio-numeric-reduction' is 0, | |
88 `109100807 if `ethio-numeric-reduction' is 1, | |
89 `10900807 if `ethio-numeric-reduction' is 2.") | |
90 | |
91 (defvar ethio-implicit-period-conversion t | |
92 "*Non-nil means replacing the Ethiopic dot at the end of an Ethiopic sentence | |
93 with an Ethiopic full stop.") | |
94 | |
95 (defvar ethio-java-save-lowercase nil | |
96 "*Non-nil means save Ethiopic characters in lowercase hex numbers to Java files. | |
97 If nil, use uppercases.") | |
17052 | 98 |
99 ;; | |
100 ;; SERA to FIDEL | |
101 ;; | |
17299 | 102 |
103 (defconst ethio-sera-to-fidel-table | |
17052 | 104 [ |
105 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil | |
106 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil | |
17299 | 107 ;;; SP |
108 (" " | |
109 (?: (if ethio-use-colon-for-colon " $(3$l(B" "$(3$h(B") | |
110 (32 (if ethio-use-colon-for-colon " $(3$l(B " "$(3$h(B")) | |
111 (?- " $(3$m(B") | |
112 (?: " $(3$i(B") | |
113 (?| (if ethio-use-colon-for-colon " $(3$l(B|" " $(3$h(B|") | |
114 (?: " $(3$o(B")))) | |
115 | |
116 ;;; ! " # $ % & ' | |
117 nil nil nil nil nil nil ("" (?' "$(3%s(B")) | |
118 ;;; ( ) * + , - . | |
119 nil nil nil nil ("$(3$j(B") ("-" (?: "$(3$l(B")) ("$(3%u(B") | |
120 ;;; / 0 1 2 3 4 5 6 7 8 9 | |
121 nil nil nil nil nil nil nil nil nil nil nil | |
122 ;;; : | |
123 ((if ethio-use-colon-for-colon "$(3$l(B" "$(3$h(B") | |
124 (32 (if ethio-use-colon-for-colon "$(3$l(B " "$(3$h(B")) | |
125 (?- "$(3$m(B") | |
126 (?: "$(3$i(B") | |
127 (?| (if ethio-use-colon-for-colon "$(3$l(B|" "$(3$h(B|") | |
128 (?: "$(3$o(B"))) | |
129 ;;; ; < = > | |
130 ("$(3$k(B") ("<" (?< "$(3%v(B")) nil (">" (?> "$(3%w(B")) | |
131 ;;; ? | |
132 ((if ethio-use-three-dot-question "$(3$n(B" "$(3%x(B")) | |
133 ;;; @ | |
134 nil | |
17052 | 135 ;;; A |
17299 | 136 ("$(3"f(B" (?2 "$(3#8(B")) |
17052 | 137 ;;; B |
17299 | 138 ("$(3"((B" (?e "$(3"#(B") (?u "$(3"$(B") (?i "$(3"%(B") (?a "$(3"&(B") (?E "$(3"'(B") (?o "$(3")(B") |
139 (?W "$(3%b(B" (?e "$(3%2(B") (?u "$(3%b(B") (?i "$(3%B(B") (?a "$(3"*(B") (?E "$(3%R(B"))) | |
17052 | 140 ;;; C |
17299 | 141 ("$(3$4(B" (?e "$(3$/(B") (?u "$(3$0(B") (?i "$(3$1(B") (?a "$(3$2(B") (?E "$(3$3(B") (?o "$(3$5(B") |
142 (?W "$(3$6(B" (?a "$(3$6(B") | |
143 (?e "$(3$4%n(B") (?u "$(3$4%r(B") (?i "$(3$4%o(B") (?E "$(3$4%q(B"))) | |
17052 | 144 ;;; D |
17299 | 145 ("$(3#b(B" (?e "$(3#](B") (?u "$(3#^(B") (?i "$(3#_(B") (?a "$(3#`(B") (?E "$(3#a(B") (?o "$(3#c(B") |
146 (?W "$(3#d(B" (?a "$(3#d(B") | |
147 (?e "$(3#b%n(B") (?u "$(3#b%r(B") (?i "$(3#b%o(B") (?E "$(3#b%q(B"))) | |
17052 | 148 ;;; E |
17299 | 149 ("$(3"g(B" (?2 "$(3#9(B")) |
17052 | 150 ;;; F |
17299 | 151 ("$(3$T(B" (?e "$(3$O(B") (?u "$(3$P(B") (?i "$(3$Q(B") (?a "$(3$R(B") (?E "$(3$S(B") (?o "$(3$U(B") |
152 (?W "$(3%d(B" (?e "$(3%4(B") (?u "$(3%d(B") (?i "$(3%D(B") (?a "$(3$V(B") (?E "$(3%T(B")) | |
153 (?Y "$(3$a(B" (?a "$(3$a(B"))) | |
17052 | 154 ;;; G |
17299 | 155 ("$(3$$(B" (?e "$(3#}(B") (?u "$(3#~(B") (?i "$(3$!(B") (?a "$(3$"(B") (?E "$(3$#(B") (?o "$(3$%(B") |
156 (?W "$(3%c(B" (?e "$(3%3(B") (?u "$(3%c(B") (?i "$(3%C(B") (?a "$(3$&(B") (?E "$(3%S(B"))) | |
17052 | 157 ;;; H |
17299 | 158 ("$(3!6(B" (?e "$(3!1(B") (?u "$(3!2(B") (?i "$(3!3(B") (?a "$(3!4(B") (?E "$(3!5(B") (?o "$(3!7(B") |
159 (?W "$(3!8(B" (?a "$(3!8(B") | |
160 (?e "$(3!6%n(B") (?u "$(3!6%r(B") (?i "$(3!6%o(B") (?E "$(3!6%q(B"))) | |
17052 | 161 ;;; I |
17299 | 162 ("$(3"h(B" (?2 "$(3#:(B")) |
17052 | 163 ;;; J |
17299 | 164 ("$(3#j(B" (?e "$(3#e(B") (?u "$(3#f(B") (?i "$(3#g(B") (?a "$(3#h(B") (?E "$(3#i(B") (?o "$(3#k(B") |
165 (?W "$(3#l(B" (?a "$(3#l(B") | |
166 (?e "$(3#j%n(B") (?u "$(3#j%r(B") (?i "$(3#j%o(B") (?E "$(3#j%q(B"))) | |
17052 | 167 ;;; K |
17299 | 168 ("$(3#"(B" (?e "$(3"{(B") (?u "$(3"|(B") (?i "$(3"}(B") (?a "$(3"~(B") (?E "$(3#!(B") (?o "$(3##(B") |
169 (?W "$(3#*(B" (?e "$(3#%(B") (?u "$(3#*(B") (?i "$(3#'(B") (?a "$(3#((B") (?E "$(3#)(B"))) | |
17052 | 170 ;;; L |
17299 | 171 ("$(3!.(B" (?e "$(3!)(B") (?u "$(3!*(B") (?i "$(3!+(B") (?a "$(3!,(B") (?E "$(3!-(B") (?o "$(3!/(B") |
172 (?W "$(3!0(B" (?a "$(3!0(B") | |
173 (?e "$(3!.%n(B") (?u "$(3!.%r(B") (?i "$(3!.%o(B") (?E "$(3!.%q(B"))) | |
17052 | 174 ;;; M |
17299 | 175 ("$(3!>(B" (?e "$(3!9(B") (?u "$(3!:(B") (?i "$(3!;(B") (?a "$(3!<(B") (?E "$(3!=(B") (?o "$(3!?(B") |
176 (?W "$(3%a(B" (?e "$(3%1(B") (?u "$(3%a(B") (?i "$(3%A(B") (?a "$(3!@(B") (?E "$(3%Q(B")) | |
177 (?Y "$(3$_(B" (?a "$(3$_(B"))) | |
17052 | 178 ;;; N |
17299 | 179 ("$(3"`(B" (?e "$(3"[(B") (?u "$(3"\(B") (?i "$(3"](B") (?a "$(3"^(B") (?E "$(3"_(B") (?o "$(3"a(B") |
180 (?W "$(3"b(B" (?a "$(3"b(B") | |
181 (?e "$(3"`%n(B") (?u "$(3"`%r(B") (?i "$(3"`%o(B") (?E "$(3"`%q(B"))) | |
17052 | 182 ;;; O |
17299 | 183 ("$(3"i(B" (?2 "$(3#;(B")) |
17052 | 184 ;;; P |
17299 | 185 ("$(3$<(B" (?e "$(3$7(B") (?u "$(3$8(B") (?i "$(3$9(B") (?a "$(3$:(B") (?E "$(3$;(B") (?o "$(3$=(B") |
186 (?W "$(3$>(B" (?a "$(3$>(B") | |
187 (?e "$(3$<%n(B") (?u "$(3$<%r(B") (?i "$(3$<%o(B") (?E "$(3$<%q(B"))) | |
17052 | 188 ;;; Q |
17299 | 189 ("$(3!v(B" (?e "$(3!q(B") (?u "$(3!r(B") (?i "$(3!s(B") (?a "$(3!t(B") (?E "$(3!u(B") (?o "$(3!w(B") |
190 (?W "$(3!~(B" (?e "$(3!y(B") (?u "$(3!~(B") (?i "$(3!{(B") (?a "$(3!|(B") (?E "$(3!}(B"))) | |
17052 | 191 ;;; R |
17299 | 192 ("$(3!N(B" (?e "$(3!I(B") (?u "$(3!J(B") (?i "$(3!K(B") (?a "$(3!L(B") (?E "$(3!M(B") (?o "$(3!O(B") |
193 (?W "$(3!P(B" (?a "$(3!P(B") | |
194 (?e "$(3!N%n(B") (?u "$(3!N%r(B") (?i "$(3!N%o(B") (?E "$(3!N%q(B")) | |
195 (?Y "$(3$`(B" (?a "$(3$`(B"))) | |
17052 | 196 ;;; S |
17299 | 197 ("$(3$D(B" (?e "$(3$?(B") (?u "$(3$@(B") (?i "$(3$A(B") (?a "$(3$B(B") (?E "$(3$C(B") (?o "$(3$E(B") |
198 (?W "$(3$F(B" (?a "$(3$F(B") | |
199 (?e "$(3$D%n(B") (?u "$(3$D%r(B") (?i "$(3$D%o(B") (?E "$(3$D%q(B")) | |
200 (?2 "$(3$L(B" | |
201 (?e "$(3$G(B") (?u "$(3$H(B") (?i "$(3$I(B") (?a "$(3$J(B") (?E "$(3$K(B") (?o "$(3$M(B") | |
202 (?W "$(3$F(B" (?a "$(3$F(B") | |
203 (?e "$(3$L%n(B") (?u "$(3$L%r(B") (?i "$(3$L%o(B") (?E "$(3$L%q(B")))) | |
17052 | 204 ;;; T |
17299 | 205 ("$(3$,(B" (?e "$(3$'(B") (?u "$(3$((B") (?i "$(3$)(B") (?a "$(3$*(B") (?E "$(3$+(B") (?o "$(3$-(B") |
206 (?W "$(3$.(B" (?a "$(3$.(B") | |
207 (?e "$(3$,%n(B") (?u "$(3$,%r(B") (?i "$(3$,%o(B") (?E "$(3$,%q(B"))) | |
17052 | 208 ;;; U |
17299 | 209 ("$(3"d(B" (?2 "$(3#6(B")) |
17052 | 210 ;;; V |
17299 | 211 ("$(3"0(B" (?e "$(3"+(B") (?u "$(3",(B") (?i "$(3"-(B") (?a "$(3".(B") (?E "$(3"/(B") (?o "$(3"1(B") |
212 (?W "$(3"2(B" (?a "$(3"2(B") | |
213 (?e "$(3"0%n(B") (?u "$(3"0%r(B") (?i "$(3"0%o(B") (?E "$(3"0%q(B"))) | |
17052 | 214 ;;; W |
17299 | 215 ("$(3%r(B" (?e "$(3%n(B") (?u "$(3%r(B") (?i "$(3%o(B") (?a "$(3%p(B") (?E "$(3%q(B")) |
17052 | 216 ;;; X |
17299 | 217 ("$(3%N(B" (?e "$(3%I(B") (?u "$(3%J(B") (?i "$(3%K(B") (?a "$(3%L(B") (?E "$(3%M(B") (?o "$(3%O(B")) |
17052 | 218 ;;; Y |
17299 | 219 ("$(3#R(B" (?e "$(3#M(B") (?u "$(3#N(B") (?i "$(3#O(B") (?a "$(3#P(B") (?E "$(3#Q(B") (?o "$(3#S(B") |
220 (?W "$(3#T(B" (?a "$(3#T(B") | |
221 (?e "$(3#R%n(B") (?u "$(3#R%r(B") (?i "$(3#R%o(B") (?E "$(3#R%q(B"))) | |
17052 | 222 ;;; Z |
17299 | 223 ("$(3#J(B" (?e "$(3#E(B") (?u "$(3#F(B") (?i "$(3#G(B") (?a "$(3#H(B") (?E "$(3#I(B") (?o "$(3#K(B") |
224 (?W "$(3#L(B" (?a "$(3#L(B") | |
225 (?e "$(3#J%n(B") (?u "$(3#J%r(B") (?i "$(3#J%o(B") (?E "$(3#J%q(B"))) | |
17052 | 226 ;;; [ \ ] ^ _ |
227 nil nil nil nil nil | |
228 ;;; ` | |
17299 | 229 ("" |
230 (?: "$(3$h(B") | |
231 (?? (if ethio-use-three-dot-question "$(3%x(B" "$(3$n(B")) | |
232 (?! "$(3%t(B") | |
233 (?e "$(3#5(B") (?u "$(3#6(B") (?U "$(3#6(B") (?i "$(3#7(B") (?a "$(3#8(B") (?A "$(3#8(B") | |
234 (?E "$(3#9(B") (?I "$(3#:(B") (?o "$(3#;(B") (?O "$(3#;(B") | |
235 (?g "$(3%^(B" | |
236 (?e "$(3%Y(B") (?u "$(3%Z(B") (?i "$(3%[(B") (?a "$(3%\(B") (?E "$(3%](B") (?o "$(3%_(B")) | |
237 (?h "$(3"H(B" | |
238 (?e "$(3"C(B") (?u "$(3"D(B") (?i "$(3"E(B") (?a "$(3"F(B") (?E "$(3"G(B") (?o "$(3"I(B") | |
239 (?W "$(3"P(B" (?e "$(3"K(B") (?u "$(3"P(B") (?i "$(3"M(B") (?a "$(3"N(B") (?E "$(3"O(B"))) | |
240 (?k "$(3%>(B" | |
241 (?e "$(3%9(B") (?u "$(3%:(B") (?i "$(3%;(B") (?a "$(3%<(B") (?E "$(3%=(B") (?o "$(3%?(B")) | |
242 (?s "$(3!F(B" | |
243 (?e "$(3!A(B") (?u "$(3!B(B") (?i "$(3!C(B") (?a "$(3!D(B") (?E "$(3!E(B") (?o "$(3!G(B") | |
244 (?W "$(3!H(B" (?a "$(3!H(B") | |
245 (?e "$(3!F%n(B") (?u "$(3!F%r(B") (?i "$(3!F%o(B") (?E "$(3!F%q(B"))) | |
246 (?S "$(3$L(B" | |
247 (?e "$(3$G(B") (?u "$(3$H(B") (?i "$(3$I(B") (?a "$(3$J(B") (?E "$(3$K(B") (?o "$(3$M(B") | |
248 (?W "$(3$F(B" (?a "$(3$F(B") | |
249 (?e "$(3$L%n(B") (?u "$(3$L%r(B") (?i "$(3$L%o(B") (?E "$(3$L%q(B"))) | |
250 (?q "$(3%.(B" (?e "$(3%)(B") (?u "$(3%*(B") (?i "$(3%+(B") (?a "$(3%,(B") (?E "$(3%-(B") (?o "$(3%/(B"))) | |
17052 | 251 ;;; a |
17299 | 252 ("$(3"f(B" (?2 "$(3#8(B")) |
17052 | 253 ;;; b |
17299 | 254 ("$(3"((B" (?e "$(3"#(B") (?u "$(3"$(B") (?i "$(3"%(B") (?a "$(3"&(B") (?E "$(3"'(B") (?o "$(3")(B") |
255 (?W "$(3%b(B" (?e "$(3%2(B") (?u "$(3%b(B") (?i "$(3%B(B") (?a "$(3"*(B") (?E "$(3%R(B"))) | |
17052 | 256 ;;; c |
17299 | 257 ("$(3"@(B" (?e "$(3";(B") (?u "$(3"<(B") (?i "$(3"=(B") (?a "$(3">(B") (?E "$(3"?(B") (?o "$(3"A(B") |
258 (?W "$(3"B(B" (?a "$(3"B(B") | |
259 (?e "$(3"@%n(B") (?u "$(3"@%r(B") (?i "$(3"@%o(B") (?E "$(3"@%q(B"))) | |
17052 | 260 ;;; d |
17299 | 261 ("$(3#Z(B" (?e "$(3#U(B") (?u "$(3#V(B") (?i "$(3#W(B") (?a "$(3#X(B") (?E "$(3#Y(B") (?o "$(3#[(B") |
262 (?W "$(3#\(B" (?a "$(3#\(B") | |
263 (?e "$(3#Z%o(B") (?u "$(3#Z%r(B") (?i "$(3#Z%p(B") (?E "$(3#Z%q(B"))) | |
17052 | 264 ;;; e |
17299 | 265 ("$(3"c(B" (?2 "$(3#5(B") (?a "$(3"j(B")) |
17052 | 266 ;;; f |
17299 | 267 ("$(3$T(B" (?e "$(3$O(B") (?u "$(3$P(B") (?i "$(3$Q(B") (?a "$(3$R(B") (?E "$(3$S(B") (?o "$(3$U(B") |
268 (?W "$(3%d(B" (?e "$(3%4(B") (?u "$(3%d(B") (?i "$(3%D(B") (?a "$(3$V(B") (?E "$(3%T(B")) | |
269 (?Y "$(3$a(B" (?a "$(3$a(B"))) | |
17052 | 270 ;;; g |
17299 | 271 ("$(3#r(B" (?e "$(3#m(B") (?u "$(3#n(B") (?i "$(3#o(B") (?a "$(3#p(B") (?E "$(3#q(B") (?o "$(3#s(B") |
272 (?W "$(3#z(B" (?e "$(3#u(B") (?u "$(3#z(B") (?i "$(3#w(B") (?a "$(3#x(B") (?E "$(3#y(B")) | |
273 (?2 "$(3%^(B" (?e "$(3%Y(B") (?u "$(3%Z(B") (?i "$(3%[(B") (?a "$(3%\(B") (?E "$(3%](B") (?o "$(3%_(B"))) | |
17052 | 274 ;;; h |
17299 | 275 ("$(3!&(B" (?e "$(3!!(B") (?u "$(3!"(B") (?i "$(3!#(B") (?a "$(3!$(B") (?E "$(3!%(B") (?o "$(3!'(B") |
276 (?W "$(3"P(B" (?e "$(3"K(B") (?u "$(3"P(B") (?i "$(3"M(B") (?a "$(3"N(B") (?E "$(3"O(B")) | |
277 (?2 "$(3"H(B" (?e "$(3"C(B") (?u "$(3"D(B") (?i "$(3"E(B") (?a "$(3"F(B") (?E "$(3"G(B") (?o "$(3"I(B") | |
278 (?W "$(3"P(B" (?e "$(3"K(B") (?u "$(3"P(B") (?i "$(3"M(B") (?a "$(3"N(B") (?E "$(3"O(B")))) | |
17052 | 279 ;;; i |
17299 | 280 ("$(3"e(B" (?2 "$(3#7(B")) |
17052 | 281 ;;; j |
17299 | 282 ("$(3#j(B" (?e "$(3#e(B") (?u "$(3#f(B") (?i "$(3#g(B") (?a "$(3#h(B") (?E "$(3#i(B") (?o "$(3#k(B") |
283 (?W "$(3#l(B" (?a "$(3#l(B") | |
284 (?e "$(3#j%n(B") (?u "$(3#j%r(B") (?i "$(3#j%o(B") (?E "$(3#j%q(B"))) | |
17052 | 285 ;;; k |
17299 | 286 ("$(3"p(B" (?e "$(3"k(B") (?u "$(3"l(B") (?i "$(3"m(B") (?a "$(3"n(B") (?E "$(3"o(B") (?o "$(3"q(B") |
287 (?W "$(3"x(B" (?e "$(3"s(B") (?u "$(3"x(B") (?i "$(3"u(B") (?a "$(3"v(B") (?E "$(3"w(B")) | |
288 (?2 "$(3%>(B" (?e "$(3%9(B") (?u "$(3%:(B") (?i "$(3%;(B") (?a "$(3%<(B") (?E "$(3%=(B") (?o "$(3%?(B"))) | |
17052 | 289 ;;; l |
17299 | 290 ("$(3!.(B" (?e "$(3!)(B") (?u "$(3!*(B") (?i "$(3!+(B") (?a "$(3!,(B") (?E "$(3!-(B") (?o "$(3!/(B") |
291 (?W "$(3!0(B" (?a "$(3!0(B") | |
292 (?e "$(3!.%n(B") (?u "$(3!.%r(B") (?i "$(3!.%o(B") (?E "$(3!.%q(B"))) | |
17052 | 293 ;;; m |
17299 | 294 ("$(3!>(B" (?e "$(3!9(B") (?u "$(3!:(B") (?i "$(3!;(B") (?a "$(3!<(B") (?E "$(3!=(B") (?o "$(3!?(B") |
295 (?W "$(3%a(B" (?e "$(3%1(B") (?u "$(3%a(B") (?i "$(3%A(B") (?a "$(3!@(B") (?E "$(3%Q(B")) | |
296 (?Y "$(3$_(B" (?a "$(3$_(B"))) | |
17052 | 297 ;;; n |
17299 | 298 ("$(3"X(B" (?e "$(3"S(B") (?u "$(3"T(B") (?i "$(3"U(B") (?a "$(3"V(B") (?E "$(3"W(B") (?o "$(3"Y(B") |
299 (?W "$(3"Z(B" (?a "$(3"Z(B") | |
300 (?e "$(3"X%n(B") (?u "$(3"X%r(B") (?i "$(3"X%o(B") (?E "$(3"X%q(B"))) | |
17052 | 301 ;;; o |
17299 | 302 ("$(3"i(B" (?2 "$(3#;(B")) |
17052 | 303 ;;; p |
17299 | 304 ("$(3$\(B" (?e "$(3$W(B") (?u "$(3$X(B") (?i "$(3$Y(B") (?a "$(3$Z(B") (?E "$(3$[(B") (?o "$(3$](B") |
305 (?W "$(3%e(B" (?e "$(3%5(B") (?u "$(3%e(B") (?i "$(3%E(B") (?a "$(3$^(B") (?E "$(3%U(B"))) | |
17052 | 306 ;;; q |
17299 | 307 ("$(3!f(B" (?e "$(3!a(B") (?u "$(3!b(B") (?i "$(3!c(B") (?a "$(3!d(B") (?E "$(3!e(B") (?o "$(3!g(B") |
308 (?W "$(3!n(B" (?e "$(3!i(B") (?u "$(3!n(B") (?i "$(3!k(B") (?a "$(3!l(B") (?E "$(3!m(B")) | |
309 (?2 "$(3%.(B" (?e "$(3%)(B") (?u "$(3%*(B") (?i "$(3%+(B") (?a "$(3%,(B") (?E "$(3%-(B") (?o "$(3%/(B"))) | |
17052 | 310 ;;; r |
17299 | 311 ("$(3!N(B" (?e "$(3!I(B") (?u "$(3!J(B") (?i "$(3!K(B") (?a "$(3!L(B") (?E "$(3!M(B") (?o "$(3!O(B") |
312 (?W "$(3!P(B" (?a "$(3!P(B") | |
313 (?e "$(3!N%n(B") (?u "$(3!N%r(B") (?i "$(3!N%o(B") (?E "$(3!N%q(B")) | |
314 (?Y "$(3$`(B" (?a "$(3$`(B"))) | |
17052 | 315 ;;; s |
17299 | 316 ("$(3!V(B" (?e "$(3!Q(B") (?u "$(3!R(B") (?i "$(3!S(B") (?a "$(3!T(B") (?E "$(3!U(B") (?o "$(3!W(B") |
317 (?W "$(3!X(B" (?a "$(3!X(B") | |
318 (?e "$(3!V%n(B") (?u "$(3!V%r(B") (?i "$(3!V%o(B") (?E "$(3!V%q(B")) | |
319 (?2 "$(3!F(B" (?e "$(3!A(B") (?u "$(3!B(B") (?i "$(3!C(B") (?a "$(3!D(B") (?E "$(3!E(B") (?o "$(3!G(B") | |
320 (?W "$(3!H(B" (?a "$(3!H(B") | |
321 (?e "$(3!F%n(B") (?u "$(3!F%r(B") (?i "$(3!F%o(B") (?E "$(3!F%q(B")))) | |
17052 | 322 ;;; t |
17299 | 323 ("$(3"8(B" (?e "$(3"3(B") (?u "$(3"4(B") (?i "$(3"5(B") (?a "$(3"6(B") (?E "$(3"7(B") (?o "$(3"9(B") |
324 (?W "$(3":(B" (?a "$(3":(B") | |
325 (?e "$(3"8%n(B") (?u "$(3"8%r(B") (?i "$(3"8%o(B") (?E "$(3"8%q(B"))) | |
17052 | 326 ;;; u |
17299 | 327 ("$(3"d(B" (?2 "$(3#6(B")) |
17052 | 328 ;;; v |
17299 | 329 ("$(3"0(B" (?e "$(3"+(B") (?u "$(3",(B") (?i "$(3"-(B") (?a "$(3".(B") (?E "$(3"/(B") (?o "$(3"1(B") |
330 (?W "$(3"2(B" (?a "$(3"2(B") | |
331 (?e "$(3"0%n(B") (?u "$(3"0%r(B") (?i "$(3"0%o(B") (?E "$(3"0%q(B"))) | |
17052 | 332 ;;; w |
17299 | 333 ("$(3#2(B" (?e "$(3#-(B") (?u "$(3#.(B") (?i "$(3#/(B") (?a "$(3#0(B") (?E "$(3#1(B") (?o "$(3#3(B") |
334 (?W "$(3%p(B" (?e "$(3%n(B") (?u "$(3%r(B") (?i "$(3%o(B") (?a "$(3%p(B") (?E "$(3%q(B"))) | |
17052 | 335 ;;; x |
17299 | 336 ("$(3!^(B" (?e "$(3!Y(B") (?u "$(3!Z(B") (?i "$(3![(B") (?a "$(3!\(B") (?E "$(3!](B") (?o "$(3!_(B") |
337 (?W "$(3!`(B" (?a "$(3!`(B") | |
338 (?e "$(3!^%n(B") (?u "$(3!^%r(B") (?i "$(3!^%o(B") (?E "$(3!^%q(B"))) | |
17052 | 339 ;;; y |
17299 | 340 ("$(3#R(B" (?e "$(3#M(B") (?u "$(3#N(B") (?i "$(3#O(B") (?a "$(3#P(B") (?E "$(3#Q(B") (?o "$(3#S(B") |
341 (?W "$(3#T(B" (?a "$(3#T(B") | |
342 (?e "$(3#R%n(B") (?u "$(3#R%r(B") (?i "$(3#R%o(B") (?E "$(3#R%q(B"))) | |
17052 | 343 ;;; z |
17299 | 344 ("$(3#B(B" (?e "$(3#=(B") (?u "$(3#>(B") (?i "$(3#?(B") (?a "$(3#@(B") (?E "$(3#A(B") (?o "$(3#C(B") |
345 (?W "$(3#D(B" (?a "$(3#D(B") | |
346 (?e "$(3#B%n(B") (?u "$(3#B%r(B") (?i "$(3#B%o(B") (?E "$(3#B%q(B"))) | |
347 ;;; { | } ~ DEL | |
348 nil nil nil nil nil | |
17052 | 349 ]) |
350 | |
351 ;;;###autoload | |
17299 | 352 (defun ethio-sera-to-fidel-region (beg end &optional secondary force) |
353 "Convert the characters in region from SERA to FIDEL. | |
354 The variable `ethio-primary-language' specifies the primary language | |
355 and `ethio-secondary-language' specifies the secondary. | |
17052 | 356 |
17299 | 357 If the 3rd parameter SECONDARY is given and non-nil, assume the region |
358 begins begins with the secondary language; otherwise with the primary | |
359 language. | |
17052 | 360 |
17299 | 361 If the 4th parameter FORCE is given and non-nil, perform conversion |
362 even if the buffer is read-only. | |
363 | |
364 See also the descriptions of the variables | |
365 `ethio-use-colen-for-colon' and | |
366 `ethio-use-three-dot-question'." | |
17052 | 367 |
368 (interactive "r\nP") | |
17299 | 369 (save-restriction |
370 (narrow-to-region beg end) | |
371 (ethio-sera-to-fidel-buffer secondary force))) | |
17052 | 372 |
373 ;;;###autoload | |
17299 | 374 (defun ethio-sera-to-fidel-buffer (&optional secondary force) |
375 "Convert the current buffer from SERA to FIDEL. | |
376 | |
377 The variable `ethio-primary-language' specifies the primary | |
378 language and `ethio-secondary-language' specifies the secondary. | |
17052 | 379 |
17299 | 380 If the 1st optional parameter SECONDARY is non-nil, assume the buffer |
381 begins with the secondary language; otherwise with the primary | |
382 language. | |
17052 | 383 |
17299 | 384 If the 2nd optional parametr FORCE is non-nil, perform conversion even if the |
385 buffer is read-only. | |
386 | |
387 See also the descriptions of the variables | |
388 `ethio-use-colen-for-colon' and | |
389 `ethio-use-three-dot-question'." | |
17052 | 390 |
391 (interactive "P") | |
17299 | 392 |
17052 | 393 (if (and buffer-read-only |
394 (not force) | |
395 (not (y-or-n-p "Buffer is read-only. Force to convert? "))) | |
396 (error "")) | |
17299 | 397 |
398 (let ((ethio-primary-language ethio-primary-language) | |
399 (ethio-secondary-language ethio-secondary-language) | |
400 (ethio-use-colon-for-colon ethio-use-colon-for-colon) | |
401 (ethio-use-three-dot-question ethio-use-three-dot-question) | |
402 ;; The above four variables may be changed temporary | |
403 ;; by tilde escapes during conversion. So we bind them to other | |
404 ;; variables but of the same names. | |
405 (buffer-read-only nil) | |
406 (case-fold-search nil) | |
407 current-language | |
408 next-language) | |
409 | |
410 (setq current-language | |
411 (if secondary | |
412 ethio-secondary-language | |
413 ethio-primary-language)) | |
414 | |
17052 | 415 (goto-char (point-min)) |
17299 | 416 |
17052 | 417 (while (not (eobp)) |
17299 | 418 (setq next-language |
419 (cond | |
420 ((eq current-language 'english) | |
421 (ethio-sera-to-fidel-english)) | |
422 ((eq current-language 'amharic) | |
423 (ethio-sera-to-fidel-ethio 'amharic)) | |
424 ((eq current-language 'tigrigna) | |
425 (ethio-sera-to-fidel-ethio 'tigrigna)) | |
426 (t ; we don't know what to do | |
427 (ethio-sera-to-fidel-english)))) | |
17052 | 428 |
17299 | 429 (setq current-language |
430 (cond | |
17052 | 431 |
17299 | 432 ;; when language tag is explicitly specified |
433 ((not (eq next-language 'toggle)) | |
434 next-language) | |
17052 | 435 |
17299 | 436 ;; found a toggle in a primary language section |
437 ((eq current-language ethio-primary-language) | |
438 ethio-secondary-language) | |
17052 | 439 |
17299 | 440 ;; found a toggle in a secondary, third, fourth, ... |
441 ;; language section | |
442 (t | |
443 ethio-primary-language)))) | |
17052 | 444 |
17299 | 445 ;; If ethio-implicit-period-conversion is non-nil, the |
446 ;; Ethiopic dot "$(3%u(B" at the end of an Ethiopic sentence is | |
447 ;; replaced with the Ethiopic full stop "$(3$i(B". | |
448 (if ethio-implicit-period-conversion | |
449 (progn | |
450 (goto-char (point-min)) | |
451 (while (re-search-forward "\\([$(3!!(B-$(3$a%)(B-$(3%e%n(B-$(3%r%s(B]\\)$(3%u(B\\([ \t]\\)" | |
452 nil t) | |
453 (replace-match "\\1$(3$i(B\\2")) | |
454 (goto-char (point-min)) | |
455 (while (re-search-forward "\\([$(3!!(B-$(3$a%)(B-$(3%e%n(B-$(3%r%s(B]\\)$(3%u(B$" nil t) | |
456 (replace-match "\\1$(3$i(B")))) | |
17052 | 457 |
17299 | 458 ;; gemination |
459 (goto-char (point-min)) | |
460 (while (re-search-forward "\\ce$(3%s(B" nil 0) | |
461 (compose-region | |
462 (save-excursion (backward-char 2) (point)) | |
463 (point))) | |
464 )) | |
465 | |
466 (defun ethio-sera-to-fidel-english nil | |
467 "Handle English section in SERA to FIDEL conversion. | |
468 Conversion stops when a language switch is found. Then delete that | |
469 switch and return the name of the new language as a symbol." | |
470 (let ((new-language nil)) | |
471 | |
472 (while (and (not (eobp)) (null new-language)) | |
473 (cond | |
17052 | 474 |
17299 | 475 ;; if no more "\", nothing to do. |
476 ((not (search-forward "\\" nil 0))) | |
477 | |
478 ;; hereafter point is put after a "\". | |
479 ;; first delete that "\", then check the following chars | |
480 | |
481 ;; "\\" : leave the second "\" | |
482 ((progn | |
483 (delete-backward-char 1) | |
484 (= (following-char) ?\\ )) | |
485 (forward-char 1)) | |
486 | |
487 ;; "\ " : delete the following " " | |
488 ((= (following-char) 32) | |
489 (delete-char 1) | |
490 (setq new-language 'toggle)) | |
17052 | 491 |
17299 | 492 ;; a language flag |
493 ((setq new-language (ethio-process-language-flag))) | |
494 | |
495 ;; just a "\" : not special sequence. | |
496 (t | |
497 (setq new-language 'toggle)))) | |
498 | |
499 new-language)) | |
17052 | 500 |
17299 | 501 (defun ethio-sera-to-fidel-ethio (lang) |
502 "Handle Ethiopic section in SERA to FIDEL conversion. | |
503 Conversion stops when a language switch is found. Then delete that | |
504 switch and return the name of the new language as a symbol. | |
505 | |
506 The parameter LANG (symbol, either `amharic' or `tigrigna') affects | |
507 the conversion of \"a\"." | |
508 | |
509 (let ((new-language nil) | |
510 (verbatim nil) | |
511 start table table2 ch) | |
17052 | 512 |
17299 | 513 (setcar (aref ethio-sera-to-fidel-table ?a) |
514 (if (eq lang 'tigrigna) "$(3"f(B" "$(3"c(B")) | |
515 | |
516 (while (and (not (eobp)) (null new-language)) | |
517 (setq ch (following-char)) | |
518 (cond | |
17052 | 519 |
17299 | 520 ;; skip from "<" to ">" (or from "&" to ";") if in w3-mode |
521 ((and (boundp 'sera-being-called-by-w3) | |
522 sera-being-called-by-w3 | |
523 (or (= ch ?<) (= ch ?&))) | |
524 (search-forward (if (= ch ?<) ">" ";") | |
525 nil 0)) | |
526 | |
527 ;; leave non-ASCII characters as they are | |
528 ((>= ch 128) | |
529 (forward-char 1)) | |
17052 | 530 |
17299 | 531 ;; ethiopic digits |
532 ((looking-at "`[1-9][0-9]*") | |
533 (delete-char 1) | |
534 (ethio-convert-digit)) | |
17052 | 535 |
17299 | 536 ;; if not seeing a "\", do sera to fidel conversion |
537 ((/= ch ?\\ ) | |
538 (setq start (point)) | |
539 (forward-char 1) | |
540 (setq table (aref ethio-sera-to-fidel-table ch)) | |
541 (while (setq table2 (cdr (assoc (following-char) table))) | |
542 (setq table table2) | |
543 (forward-char 1)) | |
544 (if (setq ch (car table)) | |
545 (progn | |
546 (delete-region start (point)) | |
547 (if (stringp ch) | |
548 (insert ch) | |
549 (insert (eval ch)))))) | |
17052 | 550 |
17299 | 551 ;; if control reaches here, we must be looking at a "\" |
17052 | 552 |
17299 | 553 ;; verbatim mode |
554 (verbatim | |
555 (if (looking-at "\\\\~! ?") | |
556 | |
557 ;; "\~!" or "\~! ". switch to non-verbatim mode | |
558 (progn | |
559 (replace-match "") | |
560 (setq verbatim nil)) | |
17052 | 561 |
17299 | 562 ;; "\" but not "\~!" nor "\~! ". skip the current "\". |
563 (forward-char 1))) | |
564 | |
565 ;; hereafter, non-verbatim mode and looking at a "\" | |
566 ;; first delete that "\", then check the following chars. | |
567 | |
568 ;; "\ " : delete the following " " | |
569 ((progn | |
17052 | 570 (delete-char 1) |
17299 | 571 (setq ch (following-char)) |
572 (= ch 32)) | |
573 (delete-char 1) | |
574 (setq new-language 'toggle)) | |
575 | |
576 ;; "\~!" or "\~! " : switch to verbatim mode | |
577 ((looking-at "~! ?") | |
578 (replace-match "") | |
579 (setq verbatim t)) | |
17052 | 580 |
17299 | 581 ;; a language flag |
582 ((setq new-language (ethio-process-language-flag))) | |
583 | |
584 ;; "\~" but not "\~!" nor a language flag | |
585 ((= ch ?~) | |
586 (delete-char 1) | |
587 (ethio-tilde-escape)) | |
588 | |
589 ;; ASCII punctuation escape. skip | |
590 ((looking-at "\\(,\\|\\.\\|;\\|:\\|'\\|`\\|\?\\|\\\\\\)+") | |
591 (goto-char (match-end 0))) | |
17052 | 592 |
17299 | 593 ;; "\", but not special sequence |
594 (t | |
595 (setq new-language 'toggle)))) | |
596 | |
597 new-language)) | |
598 | |
599 (defun ethio-process-language-flag nil | |
600 "Process a language flag of the form \"~lang\" or \"~lang1~lang2\". | |
17052 | 601 |
17299 | 602 If looking at \"~lang1~lang2\", set `ethio-primary-language' and |
603 `ethio-une-secondary-language' based on \"lang1\" and \"lang2\". | |
604 Then delete the language flag \"~lang1~lang2\" from the buffer. | |
605 Return value is the new primary language. | |
17052 | 606 |
17299 | 607 If looking at \"~lang\", delete that language flag \"~lang\" from the |
608 buffer and return that language. In this case | |
609 `ethio-primary-language' and `ethio-uni-secondary-language' | |
610 are left unchanged. | |
611 | |
612 If an unsupported language flag is found, just return nil without | |
613 changing anything." | |
614 | |
615 (let (lang1 lang2) | |
616 (cond | |
17052 | 617 |
17299 | 618 ;; ~lang1~lang2 |
619 ((and (looking-at | |
620 "~\\([a-z][a-z][a-z]?\\)~\\([a-z][a-z][a-z]?\\)[ \t\n\\]") | |
621 (setq lang1 | |
622 (ethio-flag-to-language | |
623 (buffer-substring (match-beginning 1) (match-end 1)))) | |
624 (setq lang2 | |
625 (ethio-flag-to-language | |
626 (buffer-substring (match-beginning 2) (match-end 2))))) | |
627 (setq ethio-primary-language lang1 | |
628 ethio-secondary-language lang2) | |
629 (delete-region (point) (match-end 2)) | |
630 (if (= (following-char) 32) | |
631 (delete-char 1)) | |
632 ethio-primary-language) | |
633 | |
634 ;; ~lang | |
635 ((and (looking-at "~\\([a-z][a-z][a-z]?\\)[ \t\n\\]") | |
636 (setq lang1 | |
637 (ethio-flag-to-language | |
638 (buffer-substring (match-beginning 1) (match-end 1))))) | |
639 (delete-region (point) (match-end 1)) | |
640 (if (= (following-char) 32) | |
641 (delete-char 1)) | |
642 lang1) | |
643 | |
644 ;; otherwise | |
645 (t | |
646 nil)))) | |
647 | |
648 (defun ethio-tilde-escape nil | |
649 "Handle a SERA tilde escape in Ethiopic section and delete it. | |
650 Delete the escape even it is not recognised." | |
651 | |
652 (let ((p (point)) command) | |
653 (skip-chars-forward "^ \t\n\\\\") | |
654 (setq command (buffer-substring p (point))) | |
655 (delete-region p (point)) | |
656 (if (= (following-char) 32) | |
657 (delete-char 1)) | |
658 | |
659 (cond | |
17052 | 660 |
17299 | 661 ;; \~-: |
662 ((string= command "-:") | |
663 (setq ethio-use-colon-for-colon t)) | |
664 | |
665 ;; \~`: | |
666 ((string= command "`:") | |
667 (setq ethio-use-colon-for-colon nil)) | |
668 | |
669 ;; \~? | |
670 ((string= command "?") | |
671 (setq ethio-use-three-dot-question nil)) | |
672 | |
673 ;; \~`| | |
674 ((string= command "`|") | |
675 (setq ethio-use-three-dot-question t)) | |
676 | |
677 ;; \~e | |
678 ((string= command "e") | |
679 (insert "$(3%j(B")) | |
680 | |
681 ;; \~E | |
682 ((string= command "E") | |
683 (insert "$(3%k(B")) | |
17052 | 684 |
17299 | 685 ;; \~a |
686 ((string= command "a") | |
687 (insert "$(3%l(B")) | |
688 | |
689 ;; \~A | |
690 ((string= command "A") | |
691 (insert "$(3%m(B")) | |
692 | |
693 ;; \~X | |
694 ((string= command "X") | |
695 (insert "$(3%i(B")) | |
696 | |
697 ;; unsupported tilde escape | |
698 (t | |
699 nil)))) | |
700 | |
701 (defun ethio-flag-to-language (flag) | |
702 (cond | |
703 ((or (string= flag "en") (string= flag "eng")) 'english) | |
704 ((or (string= flag "ti") (string= flag "tir")) 'tigrigna) | |
705 ((or (string= flag "am") (string= flag "amh")) 'amharic) | |
706 (t nil))) | |
707 | |
708 (defun ethio-convert-digit nil | |
17052 | 709 "Convert Arabic digits to Ethiopic digits." |
710 (let (ch z) | |
711 (while (and (>= (setq ch (following-char)) ?1) | |
712 (<= ch ?9)) | |
713 (delete-char 1) | |
714 | |
715 ;; count up following zeros | |
716 (setq z 0) | |
717 (while (= (following-char) ?0) | |
718 (delete-char 1) | |
719 (setq z (1+ z))) | |
720 | |
721 (cond | |
722 | |
723 ;; first digit is 10, 20, ..., or 90 | |
724 ((= (mod z 2) 1) | |
17299 | 725 (insert (aref [?$(3$y(B ?$(3$z(B ?$(3${(B ?$(3$|(B ?$(3$}(B ?$(3$~(B ?$(3%!(B ?$(3%"(B ?$(3%#(B] (- ch ?1))) |
17052 | 726 (setq z (1- z))) |
727 | |
728 ;; first digit is 2, 3, ..., or 9 | |
729 ((/= ch ?1) | |
17299 | 730 (insert (aref [?$(3$q(B ?$(3$r(B ?$(3$s(B ?$(3$t(B ?$(3$u(B ?$(3$v(B ?$(3$w(B ?$(3$x(B] (- ch ?2)))) |
17052 | 731 |
732 ;; single 1 | |
733 ((= z 0) | |
17299 | 734 (insert "$(3$p(B"))) |
17052 | 735 |
736 ;; 100 | |
737 (if (= (mod z 4) 2) | |
17299 | 738 (insert "$(3%$(B")) |
17052 | 739 |
740 ;; 10000 | |
17299 | 741 (insert-char ?$(3%%(B (/ z 4))))) |
17052 | 742 |
743 ;;;###autoload | |
17299 | 744 (defun ethio-sera-to-fidel-mail (&optional arg) |
745 "Convert SERA to FIDEL to read/write mail and news. | |
17052 | 746 |
747 If the buffer contains the markers \"<sera>\" and \"</sera>\", | |
17299 | 748 convert the segments between them into FIDEL. |
17052 | 749 |
17299 | 750 If invoked interactively and there is no marker, convert the subject field |
751 and the body into FIDEL using `ethio-sera-to-fidel-region'." | |
17052 | 752 |
753 (interactive "p") | |
17299 | 754 (let ((buffer-read-only nil) |
755 border) | |
17052 | 756 (save-excursion |
757 | |
17299 | 758 ;; look for the header-body separator |
759 (goto-char (point-min)) | |
760 (if (search-forward | |
761 (if (eq major-mode 'rmail-mode) | |
762 "\n\n" (concat "\n" mail-header-separator "\n")) | |
763 nil t) | |
764 (setq border (point)) | |
765 (error "header separator not found")) | |
766 | |
767 ;; note that the point is placed at the border | |
768 (if (or (re-search-forward "^<sera>$" nil t) | |
769 (progn | |
770 (goto-char (point-min)) | |
771 (re-search-forward "^Subject: <sera>" border t))) | |
17052 | 772 |
17299 | 773 ;; there are markers |
774 (progn | |
775 ;; we start with the body so that the border will not change | |
776 ;; use "^<sera>\n" instead of "^<sera>$" not to leave a blank line | |
777 (goto-char border) | |
778 (while (re-search-forward "^<sera>\n" nil t) | |
779 (replace-match "") | |
780 (ethio-sera-to-fidel-region | |
781 (point) | |
782 (progn | |
783 (if (re-search-forward "^</sera>\n" nil 0) | |
784 (replace-match "")) | |
785 (point)))) | |
786 ;; now process the subject | |
787 (goto-char (point-min)) | |
788 (if (re-search-forward "^Subject: <sera>" border t) | |
789 (ethio-sera-to-fidel-region | |
790 (progn (delete-backward-char 6) (point)) | |
791 (progn | |
792 (if (re-search-forward "</sera>$" (line-end-position) 0) | |
793 (replace-match "")) | |
794 (point))))) | |
17052 | 795 |
17299 | 796 ;; in case there are no marks but invoked interactively |
797 (if arg | |
798 (progn | |
799 (ethio-sera-to-fidel-region border (point-max)) | |
800 (goto-char (point-min)) | |
801 (if (re-search-forward "^Subject: " border t) | |
802 (ethio-sera-to-fidel-region (point) (line-end-position)))))) | |
17052 | 803 |
804 ;; adjust the rmail marker | |
805 (if (eq major-mode 'rmail-mode) | |
806 (set-marker | |
807 (aref rmail-message-vector (1+ rmail-current-message)) | |
808 (point-max)))))) | |
809 | |
810 ;;;###autoload | |
17299 | 811 (defun ethio-sera-to-fidel-marker (&optional force) |
812 "Convert the regions surrounded by \"<sera>\" and \"</sera>\" from SERA to FIDEL. | |
813 Assume that each region begins with `ethio-primary-language'. | |
814 The markers \"<sera>\" and \"</sera>\" themselves are not deleted." | |
815 (interactive "P") | |
17052 | 816 (if (and buffer-read-only |
17299 | 817 (not force) |
17052 | 818 (not (y-or-n-p "Buffer is read-only. Force to convert? "))) |
819 (error "")) | |
820 (save-excursion | |
821 (goto-char (point-min)) | |
822 (while (re-search-forward "<sera>" nil t) | |
17299 | 823 (ethio-sera-to-fidel-region |
17052 | 824 (point) |
825 (if (re-search-forward "</sera>" nil t) | |
826 (match-beginning 0) | |
827 (point-max)) | |
828 nil | |
829 'force)))) | |
830 | |
831 ;; | |
832 ;; FIDEL to SERA | |
833 ;; | |
834 | |
17299 | 835 (defconst ethio-fidel-to-sera-map |
836 [ "he" "hu" "hi" "ha" "hE" "h" "ho" "" ;; 0 - 7 | |
837 "le" "lu" "li" "la" "lE" "l" "lo" "lWa" ;; 8 | |
838 "He" "Hu" "Hi" "Ha" "HE" "H" "Ho" "HWa" ;; 16 | |
839 "me" "mu" "mi" "ma" "mE" "m" "mo" "mWa" ;; 24 | |
840 "`se" "`su" "`si" "`sa" "`sE" "`s" "`so" "`sWa" ;; 32 | |
841 "re" "ru" "ri" "ra" "rE" "r" "ro" "rWa" ;; 40 | |
842 "se" "su" "si" "sa" "sE" "s" "so" "sWa" ;; 48 | |
843 "xe" "xu" "xi" "xa" "xE" "x" "xo" "xWa" ;; 56 | |
844 "qe" "qu" "qi" "qa" "qE" "q" "qo" "" ;; 64 | |
845 "qWe" "" "qWi" "qWa" "qWE" "qW'" "" "" ;; 72 | |
846 "Qe" "Qu" "Qi" "Qa" "QE" "Q" "Qo" "" ;; 80 | |
847 "QWe" "" "QWi" "QWa" "QWE" "QW'" "" "" ;; 88 | |
848 "be" "bu" "bi" "ba" "bE" "b" "bo" "bWa" ;; 96 | |
849 "ve" "vu" "vi" "va" "vE" "v" "vo" "vWa" ;; 104 | |
850 "te" "tu" "ti" "ta" "tE" "t" "to" "tWa" ;; 112 | |
851 "ce" "cu" "ci" "ca" "cE" "c" "co" "cWa" ;; 120 | |
852 "`he" "`hu" "`hi" "`ha" "`hE" "`h" "`ho" "" ;; 128 | |
853 "hWe" "" "hWi" "hWa" "hWE" "hW'" "" "" ;; 136 | |
854 "ne" "nu" "ni" "na" "nE" "n" "no" "nWa" ;; 144 | |
855 "Ne" "Nu" "Ni" "Na" "NE" "N" "No" "NWa" ;; 152 | |
856 "e" "u" "i" "A" "E" "I" "o" "ea" ;; 160 | |
857 "ke" "ku" "ki" "ka" "kE" "k" "ko" "" ;; 168 | |
858 "kWe" "" "kWi" "kWa" "kWE" "kW'" "" "" ;; 176 | |
859 "Ke" "Ku" "Ki" "Ka" "KE" "K" "Ko" "" ;; 184 | |
860 "KWe" "" "KWi" "KWa" "KWE" "KW'" "" "" ;; 192 | |
861 "we" "wu" "wi" "wa" "wE" "w" "wo" "" ;; 200 | |
862 "`e" "`u" "`i" "`a" "`E" "`I" "`o" "" ;; 208 | |
863 "ze" "zu" "zi" "za" "zE" "z" "zo" "zWa" ;; 216 | |
864 "Ze" "Zu" "Zi" "Za" "ZE" "Z" "Zo" "ZWa" ;; 224 | |
865 "ye" "yu" "yi" "ya" "yE" "y" "yo" "yWa" ;; 232 | |
866 "de" "du" "di" "da" "dE" "d" "do" "dWa" ;; 240 | |
867 "De" "Du" "Di" "Da" "DE" "D" "Do" "DWa" ;; 248 | |
868 "je" "ju" "ji" "ja" "jE" "j" "jo" "jWa" ;; 256 | |
869 "ge" "gu" "gi" "ga" "gE" "g" "go" "" ;; 264 | |
870 "gWe" "" "gWi" "gWa" "gWE" "gW'" "" "" ;; 272 | |
871 "Ge" "Gu" "Gi" "Ga" "GE" "G" "Go" "GWa" ;; 280 | |
872 "Te" "Tu" "Ti" "Ta" "TE" "T" "To" "TWa" ;; 288 | |
873 "Ce" "Cu" "Ci" "Ca" "CE" "C" "Co" "CWa" ;; 296 | |
874 "Pe" "Pu" "Pi" "Pa" "PE" "P" "Po" "PWa" ;; 304 | |
875 "Se" "Su" "Si" "Sa" "SE" "S" "So" "SWa" ;; 312 | |
876 "`Se" "`Su" "`Si" "`Sa" "`SE" "`S" "`So" "" ;; 320 | |
877 "fe" "fu" "fi" "fa" "fE" "f" "fo" "fWa" ;; 328 | |
878 "pe" "pu" "pi" "pa" "pE" "p" "po" "pWa" ;; 336 | |
879 "mYa" "rYa" "fYa" "" "" "" "" "" ;; 344 | |
880 " " " : " "::" "," ";" "-:" ":-" "`?" ;; 352 | |
881 ":|:" "1" "2" "3" "4" "5" "6" "7" ;; 360 | |
882 "8" "9" "10" "20" "30" "40" "50" "60" ;; 368 | |
883 "70" "80" "90" "100" "10000" "" "" "" ;; 376 | |
884 "`qe" "`qu" "`qi" "`qa" "`qE" "`q" "`qo" "" ;; 384 | |
885 "mWe" "bWe" "GWe" "fWe" "pWe" "" "" "" ;; 392 | |
886 "`ke" "`ku" "`ki" "`ka" "`kE" "`k" "`ko" "" ;; 400 | |
887 "mWi" "bWi" "GWi" "fWi" "pWi" "" "" "" ;; 408 | |
888 "Xe" "Xu" "Xi" "Xa" "XE" "X" "Xo" "" ;; 416 | |
889 "mWE" "bWE" "GWE" "fWE" "pWE" "" "" "" ;; 424 | |
890 "`ge" "`gu" "`gi" "`ga" "`gE" "`g" "`go" "" ;; 432 | |
891 "mW'" "bW'" "GW'" "fW'" "pW'" "" "" "" ;; 440 | |
892 "\\~X " "\\~e " "\\~E " "\\~a " "\\~A " "wWe" "wWi" "wWa" ;; 448 | |
893 "wWE" "wW'" "''" "`!" "." "<<" ">>" "?" ]) ;; 456 | |
17052 | 894 |
17299 | 895 (defun ethio-prefer-amharic-p nil |
896 (or (eq ethio-primary-language 'amharic) | |
897 (and (not (eq ethio-primary-language 'tigrigna)) | |
898 (eq ethio-secondary-language 'amharic)))) | |
17052 | 899 |
17299 | 900 (defun ethio-language-to-flag (lang) |
901 (cond | |
902 ((eq lang 'english) "eng") | |
903 ((eq lang 'tigrigna) "tir") | |
904 ((eq lang 'amharic) "amh") | |
905 (t ""))) | |
17052 | 906 |
907 ;;;###autoload | |
17299 | 908 (defun ethio-fidel-to-sera-region (begin end &optional secondary force) |
909 "Replace all the FIDEL characters in the region to the SERA format. | |
910 The variable `ethio-primary-language' specifies the primary | |
911 language and `ethio-secondary-language' specifies the secondary. | |
17052 | 912 |
17299 | 913 If the 3dr parameter SECONDARY is given and non-nil, try to convert |
914 the region so that it begins in the secondary language; otherwise with | |
915 the primary language. | |
17052 | 916 |
17299 | 917 If the 4th parameter FORCE is given and non-nil, convert even if the |
918 buffer is read-only. | |
919 | |
920 See also the descriptions of the variables | |
921 `ethio-use-colen-for-colon', `ethio-use-three-dot-question', | |
922 `ethio-quote-vowel-always' and `ethio-numeric-reduction'." | |
17052 | 923 |
924 (interactive "r\nP") | |
17299 | 925 (save-restriction |
926 (narrow-to-region begin end) | |
927 (ethio-fidel-to-sera-buffer secondary force))) | |
17052 | 928 |
929 ;;;###autoload | |
17299 | 930 (defun ethio-fidel-to-sera-buffer (&optional secondary force) |
931 "Replace all the FIDEL characters in the current buffer to the SERA format. | |
932 The variable `ethio-primary-language' specifies the primary | |
933 language and `ethio-secondary-language' specifies the secondary. | |
17052 | 934 |
17299 | 935 If the 1st optional parameter SECONDARY is non-nil, try to convert the |
936 region so that it begins in the secondary language; otherwise with the | |
937 primary language. | |
17052 | 938 |
17299 | 939 If the 2nd optional parameter FORCE is non-nil, convert even if the |
17052 | 940 buffer is read-only. |
941 | |
17299 | 942 See also the descriptions of the variables |
943 `ethio-use-colen-for-colon', `ethio-use-three-dot-question', | |
944 `ethio-quote-vowel-always' and `ethio-numeric-reduction'." | |
17052 | 945 |
946 (interactive "P") | |
947 (if (and buffer-read-only | |
948 (not force) | |
949 (not (y-or-n-p "Buffer is read-only. Force to convert? "))) | |
950 (error "")) | |
951 | |
17299 | 952 (let ((buffer-read-only nil) |
953 (case-fold-search nil) | |
954 (lonec nil) ;; t means previous char was a lone consonant | |
955 (fidel nil) ;; t means previous char was a FIDEL | |
956 (digit nil) ;; t means previous char was an Ethiopic digit | |
957 (flag (if (ethio-prefer-amharic-p) "\\~amh " "\\~tir ")) | |
958 mode ch) | |
959 | |
960 ;; user's preference in transcription | |
961 (if ethio-use-colon-for-colon | |
962 (progn | |
963 (aset ethio-fidel-to-sera-map 353 "`:") | |
964 (aset ethio-fidel-to-sera-map 357 ":")) | |
965 (aset ethio-fidel-to-sera-map 353 " : ") | |
966 (aset ethio-fidel-to-sera-map 357 "-:")) | |
17052 | 967 |
17299 | 968 (if ethio-use-three-dot-question |
969 (progn | |
970 (aset ethio-fidel-to-sera-map 359 "?") | |
971 (aset ethio-fidel-to-sera-map 463 "`?")) | |
972 (aset ethio-fidel-to-sera-map 359 "`?") | |
973 (aset ethio-fidel-to-sera-map 463 "?")) | |
974 | |
975 (mapcar | |
976 '(lambda (x) | |
977 (aset (aref ethio-fidel-to-sera-map x) | |
978 2 | |
979 (if ethio-W-sixth-always ?' ?u))) | |
980 '(77 93 141 181 197 277 440 441 442 443 444 457)) | |
981 | |
982 (if (ethio-prefer-amharic-p) | |
983 (aset ethio-fidel-to-sera-map 160 "a") | |
984 (aset ethio-fidel-to-sera-map 160 "e")) | |
985 ;; end of user's preference | |
986 | |
987 ;; first, decompose geminated characters | |
988 (decompose-region (point-min) (point-max)) | |
989 | |
990 ;; main conversion routine | |
17052 | 991 (goto-char (point-min)) |
992 (while (not (eobp)) | |
993 (setq ch (following-char)) | |
994 | |
17299 | 995 (cond ; ethiopic, english, neutral |
17052 | 996 |
17299 | 997 ;; ethiopic character. must go to ethiopic mode, if not in it. |
998 ((eq (char-charset ch) 'ethiopic) | |
999 (setq ch (ethio-char-to-ethiocode ch)) | |
1000 (delete-char 1) | |
1001 (if (not (eq mode 'ethiopic)) | |
1002 (progn | |
1003 (insert flag) | |
1004 (setq mode 'ethiopic))) | |
1005 | |
1006 (cond ; fidel, punc, digit | |
17052 | 1007 |
17299 | 1008 ;; fidels |
1009 ((or (<= ch 346) ; he - fYa | |
1010 (and (>= ch 384) (<= ch 444)) ; `qe - pw | |
1011 (and (>= ch 453) (<= ch 457))) ; wWe - wW | |
1012 (if (and (memq ch '(160 161 162 163 164 166 167)) ; (e - ea) | |
1013 (or lonec | |
1014 (and ethio-quote-vowel-always | |
1015 fidel))) | |
1016 (insert "'")) | |
1017 (insert (aref ethio-fidel-to-sera-map ch)) | |
1018 (setq lonec (ethio-lone-consonant-p ch) | |
1019 fidel t | |
1020 digit nil)) | |
1021 | |
1022 ;; punctuations or icons | |
1023 ((or (and (>= ch 353) (<= ch 360)) ; : - :|: | |
1024 (>= ch 458) ; '' - ? | |
1025 (and (>= ch 448) (<= ch 452))) ; \~X \~e \~E \~a \~A | |
1026 (insert (aref ethio-fidel-to-sera-map ch)) | |
1027 (setq lonec nil | |
1028 fidel nil | |
1029 digit nil)) | |
1030 | |
1031 ;; now CH must be an ethiopic digit | |
17052 | 1032 |
17299 | 1033 ;; reduction = 0 or not preceded by Ethiopic number(s) |
1034 ((or (= ethio-numeric-reduction 0) | |
1035 (not digit)) | |
1036 (insert "`" (aref ethio-fidel-to-sera-map ch)) | |
1037 (setq lonec nil | |
1038 fidel nil | |
1039 digit t)) | |
17052 | 1040 |
17299 | 1041 ;; reduction = 2 and following 10s, 100s, 10000s |
1042 ((and (= ethio-numeric-reduction 2) | |
1043 (memq ch '(370 379 380))) | |
1044 (insert (substring (aref ethio-fidel-to-sera-map ch) 1)) | |
1045 (setq lonec nil | |
1046 fidel nil | |
1047 digit t)) | |
1048 | |
1049 ;; ordinary following digits | |
1050 (t | |
1051 (insert (aref ethio-fidel-to-sera-map ch)) | |
1052 (setq lonec nil | |
1053 fidel nil | |
1054 digit t)))) | |
17052 | 1055 |
17299 | 1056 ;; english character. must go to english mode, if not in it. |
1057 ((or (and (>= ch ?a) (<= ch ?z)) | |
1058 (and (>= ch ?A) (<= ch ?Z))) | |
1059 (if (not (eq mode 'english)) | |
1060 (insert "\\~eng ")) | |
1061 (forward-char 1) | |
1062 (setq mode 'english | |
1063 lonec nil | |
1064 fidel nil | |
1065 digit nil)) | |
1066 | |
1067 ;; ch can appear both in ethiopic section and in english section. | |
1068 (t | |
17052 | 1069 |
17299 | 1070 ;; we must decide the mode, if not decided yet |
1071 (if (null mode) | |
1072 (progn | |
1073 (setq mode | |
1074 (if secondary | |
1075 ethio-secondary-language | |
1076 ethio-primary-language)) | |
1077 (if (eq mode 'english) | |
1078 (insert "\\~eng ") | |
1079 (insert flag) | |
1080 (setq mode 'ethiopic)))) ; tigrigna & amharic --> ethiopic | |
17052 | 1081 |
17299 | 1082 (cond ; \ , eng-mode , punc , w3 , other |
17052 | 1083 |
1084 ;; backslash is always quoted | |
1085 ((= ch ?\\ ) | |
17299 | 1086 (insert "\\") |
1087 (forward-char 1)) | |
17052 | 1088 |
17299 | 1089 ;; nothing to do if in english mode |
1090 ((eq mode 'english) | |
1091 (forward-char 1)) | |
1092 | |
1093 ;; now we must be in ethiopic mode and seeing a non-"\" | |
17052 | 1094 |
17299 | 1095 ;; ascii punctuations in ethiopic mode |
1096 ((looking-at "[,.;:'`?]+") | |
1097 (insert "\\") | |
1098 (goto-char (1+ (match-end 0)))) ; because we inserted one byte (\) | |
17052 | 1099 |
17299 | 1100 ;; skip from "<" to ">" (or from "&" to ";") if called from w3 |
1101 ((and (boundp 'sera-being-called-by-w3) | |
1102 sera-being-called-by-w3 | |
1103 (or (= ch ?<) (= ch ?&))) | |
1104 (search-forward (if (= ch ?<) ">" ";") | |
1105 nil 0)) | |
17052 | 1106 |
17299 | 1107 ;; neutral character. no need to quote. just skip it. |
1108 (t | |
1109 (forward-char 1))) | |
1110 | |
17052 | 1111 (setq lonec nil |
1112 fidel nil | |
1113 digit nil))) | |
17299 | 1114 ;; end of main conversion routine |
1115 ))) | |
17052 | 1116 |
17299 | 1117 (defun ethio-lone-consonant-p (ethiocode) |
1118 "If ETHIOCODE is an Ethiopic lone consonant, return t." | |
1119 (or (and (< ethiocode 344) (= (% ethiocode 8) 5)) | |
1120 | |
1121 ;; `q `k X `g mW bW GW fW pW wW | |
1122 (memq ethiocode '(389 405 421 437 440 441 442 443 444 457)))) | |
17052 | 1123 |
1124 ;;;###autoload | |
17299 | 1125 (defun ethio-fidel-to-sera-mail nil |
1126 "Convert FIDEL to SERA to read/write mail and news. | |
17052 | 1127 |
17299 | 1128 If the body contains at least one Ethiopic character, |
1129 1) insert the string \"<sera>\" at the beginning of the body, | |
1130 2) insert \"</sera>\" at the end of the body, and | |
1131 3) convert the body into SERA. | |
1132 | |
1133 The very same procedure applies to the subject field, too." | |
17052 | 1134 |
1135 (interactive) | |
17299 | 1136 (let ((buffer-read-only nil) |
1137 border) | |
1138 (save-excursion | |
17052 | 1139 |
17299 | 1140 ;; look for the header-body separator |
1141 (goto-char (point-min)) | |
1142 (if (search-forward | |
1143 (if (eq major-mode 'rmail-mode) | |
1144 "\n\n" (concat "\n" mail-header-separator "\n")) | |
1145 nil t) | |
1146 (setq border (point)) | |
1147 (error "header separator not found")) | |
1148 | |
1149 ;; process body first not to change the border | |
1150 ;; note that the point is already at the border | |
1151 (if (re-search-forward "\\ce" nil t) | |
1152 (progn | |
1153 (ethio-fidel-to-sera-region border (point-max)) | |
1154 (goto-char border) | |
1155 (insert "<sera>") | |
1156 (goto-char (point-max)) | |
1157 (insert "</sera>"))) | |
17052 | 1158 |
17299 | 1159 ;; process subject |
1160 (goto-char (point-min)) | |
1161 (if (re-search-forward "^Subject: " border t) | |
1162 (let ((beg (point)) | |
1163 (end (line-end-position))) | |
1164 (if (re-search-forward "\\ce" end t) | |
1165 (progn | |
1166 (ethio-fidel-to-sera-region beg end) | |
1167 (goto-char beg) | |
1168 (insert "<sera>") | |
1169 (end-of-line) | |
1170 (insert "</sera>"))))) | |
17052 | 1171 |
17299 | 1172 ;; adjust the rmail marker |
1173 (if (eq major-mode 'rmail-mode) | |
1174 (set-marker | |
1175 (aref rmail-message-vector (1+ rmail-current-message)) | |
1176 (point-max)))))) | |
17052 | 1177 |
1178 ;;;###autoload | |
17299 | 1179 (defun ethio-fidel-to-sera-marker (&optional force) |
1180 "Convert the regions surrounded by \"<sera>\" and \"</sera>\" from FIDEL to SERA. | |
1181 The markers \"<sera>\" and \"</sera>\" themselves are not deleted." | |
17052 | 1182 |
17299 | 1183 (interactive "P") |
17052 | 1184 (if (and buffer-read-only |
17299 | 1185 (not force) |
17052 | 1186 (not (y-or-n-p "Buffer is read-only. Force to convert? "))) |
1187 (error "")) | |
1188 (save-excursion | |
1189 (goto-char (point-min)) | |
17299 | 1190 (while (re-search-forward "<sera>" nil t) |
1191 (ethio-fidel-to-sera-region | |
17052 | 1192 (point) |
17299 | 1193 (if (re-search-forward "</sera>" nil t) |
17052 | 1194 (match-beginning 0) |
1195 (point-max)) | |
1196 nil | |
1197 'force)))) | |
1198 | |
1199 ;; | |
1200 ;; vowel modification | |
1201 ;; | |
1202 | |
1203 ;;;###autoload | |
17299 | 1204 (defun ethio-modify-vowel nil |
17052 | 1205 "Modify the vowel of the FIDEL that is under the cursor." |
1206 (interactive) | |
17299 | 1207 (let ((ch (following-char)) |
1208 (composite nil) ; geminated or not | |
1209 newch base vowel modulo) | |
1210 | |
1211 (cond | |
1212 ;; in case of gemination | |
1213 ((eq (char-charset ch) 'composition) | |
1214 (setq ch (string-to-char (decompose-composite-char ch)) | |
1215 composite t)) | |
1216 ;; neither gemination nor fidel | |
1217 ((not (eq (char-charset ch) 'ethiopic)) | |
1218 (error "Not a valid character."))) | |
1219 | |
1220 ;; set frequently referred character features | |
1221 (setq ch (ethio-char-to-ethiocode ch) | |
1222 base (* (/ ch 8) 8) | |
1223 modulo (% ch 8)) | |
1224 | |
1225 (if (or (and (>= ch 344) (<= ch 380)) ;; mYa - `10000 | |
1226 (and (>= ch 448) (<= ch 452)) ;; \~X - \~A | |
1227 (>= ch 458)) ;; private punctuations | |
17052 | 1228 (error "Not a valid character.")) |
17299 | 1229 |
1230 (setq | |
1231 newch | |
1232 (cond | |
1233 | |
1234 ;; first standalone vowels | |
1235 ((= base 160) | |
1236 (if (ethio-prefer-amharic-p) | |
1237 (message "Modify vowel to: [auiAEIoW\"] ") | |
1238 (message "Modify vowel to: [euiAEIoW\"] ")) | |
1239 (setq vowel (read-char)) | |
1240 (cond | |
1241 ((= vowel ?e) 160) | |
1242 ((= vowel ?u) 161) | |
1243 ((= vowel ?i) 162) | |
1244 ((= vowel ?A) 163) | |
1245 ((= vowel ?E) 164) | |
1246 ((= vowel ?I) 165) | |
1247 ((= vowel ?o) 166) | |
1248 ((= vowel ?W) 167) | |
1249 ((= vowel ?a) (if (ethio-prefer-amharic-p) 160 163)) | |
1250 ((= vowel ?\") (setq composite t) ch) | |
1251 (t nil))) | |
1252 | |
1253 ;; second standalone vowels | |
1254 ((= base 208) | |
1255 (message "Modify vowel to: [euiaEIo\"] ") | |
1256 (setq vowel (read-char)) | |
1257 (cond | |
1258 ((= vowel ?e) 208) | |
1259 ((= vowel ?u) 209) | |
1260 ((= vowel ?i) 210) | |
1261 ((= vowel ?a) 211) | |
1262 ((= vowel ?E) 212) | |
1263 ((= vowel ?I) 213) | |
1264 ((= vowel ?o) 214) | |
1265 ((= vowel ?\") (setq composite t) ch) | |
1266 (t nil))) | |
1267 | |
1268 ;; 12-form consonants, *W* form | |
1269 ((memq base '(72 88 136 176 192 272)) ; qW QW hW kW KW gW | |
1270 (message "Modify vowel to: [euiaE'\"] ") | |
1271 (setq vowel (read-char)) | |
1272 (cond | |
1273 ((= vowel ?e) base) | |
1274 ((= vowel ?u) (+ base 5)) | |
1275 ((= vowel ?i) (+ base 2)) | |
1276 ((= vowel ?a) (+ base 3)) | |
1277 ((= vowel ?E) (+ base 4)) | |
1278 ((= vowel ?') (+ base 5)) | |
1279 ((= vowel ?\") (setq composite t) ch) | |
1280 (t nil))) | |
1281 | |
1282 ;; extended 12-form consonants, mWa bWa GWa fWa pWa | |
1283 ((= ch 31) ; mWa | |
1284 (message "Modify vowel to: [euiaE'\"] ") | |
1285 (setq vowel (read-char)) | |
1286 (cond | |
1287 ((= vowel ?e) 392) | |
1288 ((= vowel ?u) 440) | |
1289 ((= vowel ?i) 408) | |
1290 ((= vowel ?a) ch) | |
1291 ((= vowel ?E) 424) | |
1292 ((= vowel ?') 440) | |
1293 ((= vowel ?\") (setq composite t) ch) | |
1294 (t nil))) | |
1295 ((= ch 103) ; bWa | |
1296 (message "Modify vowel to: [euiaE'\"] ") | |
1297 (setq vowel (read-char)) | |
1298 (cond | |
1299 ((= vowel ?e) 393) | |
1300 ((= vowel ?u) 441) | |
1301 ((= vowel ?i) 409) | |
1302 ((= vowel ?a) ch) | |
1303 ((= vowel ?E) 425) | |
1304 ((= vowel ?') 441) | |
1305 ((= vowel ?\") (setq composite t) ch) | |
1306 (t nil))) | |
1307 ((= ch 287) ; GWa | |
1308 (message "Modify vowel to: [euiaE'\"] ") | |
1309 (setq vowel (read-char)) | |
1310 (cond | |
1311 ((= vowel ?e) 394) | |
1312 ((= vowel ?u) 442) | |
1313 ((= vowel ?i) 410) | |
1314 ((= vowel ?a) ch) | |
1315 ((= vowel ?E) 426) | |
1316 ((= vowel ?') 442) | |
1317 ((= vowel ?\") (setq composite t) ch) | |
1318 (t nil))) | |
1319 ((= ch 335) ; fWa | |
1320 (message "Modify vowel to: [euiaE'\"] ") | |
1321 (setq vowel (read-char)) | |
1322 (cond | |
1323 ((= vowel ?e) 395) | |
1324 ((= vowel ?u) 443) | |
1325 ((= vowel ?i) 411) | |
1326 ((= vowel ?a) ch) | |
1327 ((= vowel ?E) 427) | |
1328 ((= vowel ?') 443) | |
1329 ((= vowel ?\") (setq composite t) ch) | |
1330 (t nil))) | |
1331 ((= ch 343) ; pWa | |
1332 (message "Modify vowel to: [euiaE'\"] ") | |
1333 (setq vowel (read-char)) | |
1334 (cond | |
1335 ((= vowel ?e) 396) | |
1336 ((= vowel ?u) 444) | |
1337 ((= vowel ?i) 412) | |
1338 ((= vowel ?a) ch) | |
1339 ((= vowel ?E) 428) | |
1340 ((= vowel ?') 444) | |
1341 ((= vowel ?\") (setq composite t) ch) | |
1342 (t nil))) | |
1343 | |
1344 ;; extended 12-form consonatns, mW* bW* GW* fW* pW* | |
1345 ((memq base '(392 408 424 440)) ; *We *Wi *WE *W | |
1346 (message "Modify vowel to: [eiEau'\"] ") | |
1347 (setq vowel (read-char)) | |
1348 (cond | |
1349 ((= vowel ?e) (+ 392 modulo)) | |
1350 ((= vowel ?i) (+ 408 modulo)) | |
1351 ((= vowel ?E) (+ 424 modulo)) | |
1352 ((= vowel ?a) (cond | |
1353 ((= modulo 0) 31) ; mWa | |
1354 ((= modulo 1) 103) ; bWa | |
1355 ((= modulo 2) 287) ; GWa | |
1356 ((= modulo 3) 335) ; fWa | |
1357 ((= modulo 4) 343) ; pWa | |
1358 (t nil))) ; never reach here | |
1359 ((= vowel ?') (+ 440 modulo)) | |
1360 ((= vowel ?u) (+ 440 modulo)) | |
1361 ((= vowel ?\") (setq composite t) ch) | |
1362 (t nil))) | |
1363 | |
1364 ((and (>= ch 453) (<= ch 457)) ; wWe wWi wWa wWE wW | |
1365 (message "Modify vowel to: [eiaE'u\"] ") | |
1366 (setq vowel (read-char)) | |
1367 (cond | |
1368 ((= vowel ?e) 453) | |
1369 ((= vowel ?i) 454) | |
1370 ((= vowel ?a) 455) | |
1371 ((= vowel ?E) 456) | |
1372 ((= vowel ?') 457) | |
1373 ((= vowel ?u) 457) | |
1374 ((= vowel ?\") (setq composite t) ch) | |
1375 (t nil))) | |
1376 | |
1377 ;; 7-form consonants, or | |
1378 ;; first 7 of 8-form consonants | |
1379 ((<= modulo 6) | |
1380 (message "Modify vowel to: [euiaE'o\"] ") | |
1381 (setq vowel (read-char)) | |
1382 (cond | |
1383 ((= vowel ?e) base) | |
1384 ((= vowel ?u) (+ base 1)) | |
1385 ((= vowel ?i) (+ base 2)) | |
1386 ((= vowel ?a) (+ base 3)) | |
1387 ((= vowel ?E) (+ base 4)) | |
1388 ((= vowel ?') (+ base 5)) | |
1389 ((= vowel ?o) (+ base 6)) | |
1390 ((= vowel ?\") (setq composite t) ch) | |
1391 (t nil))) | |
1392 | |
1393 ;; otherwise | |
1394 (t | |
1395 nil))) | |
17052 | 1396 |
1397 (cond | |
1398 | |
17299 | 1399 ;; could not get new character |
1400 ((null newch) | |
1401 (error "Invalid vowel")) | |
1402 | |
1403 ;; vowel changed on a composite Fidel | |
1404 (composite | |
1405 (delete-char 1) | |
1406 (insert | |
1407 (compose-string | |
1408 (concat (char-to-string (ethio-ethiocode-to-char newch)) "$(3%s(B")))) | |
17052 | 1409 |
17299 | 1410 ;; simple vowel modification |
1411 (t | |
1412 (delete-char 1) | |
1413 (insert (ethio-ethiocode-to-char newch)))))) | |
17052 | 1414 |
17299 | 1415 (defun ethio-ethiocode-to-char (ethiocode) |
1416 (make-char | |
1417 'ethiopic | |
1418 (+ (/ ethiocode 94) 33) | |
1419 (+ (mod ethiocode 94) 33))) | |
17052 | 1420 |
17299 | 1421 (defun ethio-char-to-ethiocode (ch) |
17052 | 1422 (and (eq (char-charset ch) 'ethiopic) |
1423 (let ((char-components (split-char ch))) | |
17299 | 1424 (+ (* (- (nth 1 char-components) 33) 94) |
1425 (- (nth 2 char-components) 33))))) | |
17052 | 1426 |
1427 ;; | |
1428 ;; space replacement | |
1429 ;; | |
1430 | |
1431 ;;;###autoload | |
1432 (defun ethio-replace-space (ch begin end) | |
17299 | 1433 "Replace ASCII spaces with Ethiopic word separators in the region. |
1434 | |
1435 In the specified region, replace word separators surrounded by two | |
1436 Ethiopic characters, depending on the first parameter CH, which should | |
1437 be 1, 2, or 3. | |
1438 | |
1439 If CH = 1, word separator will be replaced with an ASCII space. | |
1440 If CH = 2, with two ASCII spaces. | |
1441 If CH = 3, with the Ethiopic colon-like word separator. | |
1442 | |
1443 The second and third parameters BEGIN and END specify the region." | |
1444 | |
17052 | 1445 (interactive "*cReplace spaces to: 1 (sg col), 2 (dbl col), 3 (Ethiopic)\nr") |
1446 (if (not (memq ch '(?1 ?2 ?3))) | |
1447 (error "")) | |
1448 (save-excursion | |
1449 (save-restriction | |
1450 (narrow-to-region begin end) | |
1451 | |
1452 (cond | |
1453 ((= ch ?1) | |
17299 | 1454 ;; an Ethiopic word separator --> an ASCII space |
1455 (goto-char (point-min)) | |
1456 (while (search-forward "$(3$h(B" nil t) | |
1457 (replace-match " " nil t)) | |
17052 | 1458 |
17299 | 1459 ;; two ASCII spaces between Ethiopic characters --> an ASCII space |
1460 (goto-char (point-min)) | |
1461 (while (re-search-forward "\\(\\ce\\) \\(\\ce\\)" nil t) | |
1462 (replace-match "\\1 \\2") | |
1463 (goto-char (match-beginning 2)))) | |
17052 | 1464 |
1465 ((= ch ?2) | |
17299 | 1466 ;; An Ethiopic word separator --> two ASCII spaces |
17052 | 1467 (goto-char (point-min)) |
17299 | 1468 (while (search-forward "$(3$h(B" nil t) |
1469 (replace-match " ")) | |
17052 | 1470 |
17299 | 1471 ;; An ASCII space between Ethiopic characters --> two ASCII spaces |
1472 (goto-char (point-min)) | |
1473 (while (re-search-forward "\\(\\ce\\) \\(\\ce\\)" nil t) | |
1474 (replace-match "\\1 \\2") | |
17052 | 1475 (goto-char (match-beginning 2)))) |
1476 | |
17299 | 1477 (t |
1478 ;; One or two ASCII spaces between Ethiopic characters | |
1479 ;; --> An Ethiopic word separator | |
1480 (goto-char (point-min)) | |
1481 (while (re-search-forward "\\(\\ce\\) ?\\(\\ce\\)" nil t) | |
1482 (replace-match "\\1$(3$h(B\\2") | |
1483 (goto-char (match-beginning 2))) | |
17052 | 1484 |
17299 | 1485 ;; Three or more ASCII spaces between Ethiopic characters |
1486 ;; --> An Ethiopic word separator + (N - 2) ASCII spaces | |
1487 (goto-char (point-min)) | |
1488 (while (re-search-forward "\\(\\ce\\) \\( *\\ce\\)" nil t) | |
1489 (replace-match "\\1$(3$h(B\\2") | |
1490 (goto-char (match-beginning 2)))))))) | |
17052 | 1491 |
1492 ;; | |
17299 | 1493 ;; special icons |
17052 | 1494 ;; |
1495 | |
1496 ;;;###autoload | |
1497 (defun ethio-input-special-character (arg) | |
1498 "Allow the user to input special characters." | |
17299 | 1499 (interactive "*cInput number: 1.$(3%j(B 2.$(3%k(B 3.$(3%l(B 4.$(3%m(B 5.$(3%i(B") |
17052 | 1500 (cond |
1501 ((= arg ?1) | |
17299 | 1502 (insert "$(3%j(B")) |
17052 | 1503 ((= arg ?2) |
17299 | 1504 (insert "$(3%k(B")) |
17052 | 1505 ((= arg ?3) |
17299 | 1506 (insert "$(3%l(B")) |
17052 | 1507 ((= arg ?4) |
17299 | 1508 (insert "$(3%m(B")) |
1509 ((= arg ?5) | |
1510 (insert "$(3%i(B")) | |
17052 | 1511 (t |
1512 (error "")))) | |
1513 | |
1514 ;; | |
17299 | 1515 ;; TeX support |
1516 ;; | |
1517 | |
1518 (defconst fidel-to-tex-map | |
1519 [ "heG" "huG" "hiG" "haG" "hEG" "hG" "hoG" "" ;; 0 - 7 | |
1520 "leG" "luG" "liG" "laG" "lEG" "lG" "loG" "lWaG" ;; 8 | |
1521 "HeG" "HuG" "HiG" "HaG" "HEG" "HG" "HoG" "HWaG" ;; 16 | |
1522 "meG" "muG" "miG" "maG" "mEG" "mG" "moG" "mWaG" ;; 24 | |
1523 "sseG" "ssuG" "ssiG" "ssaG" "ssEG" "ssG" "ssoG" "ssWaG" ;; 32 | |
1524 "reG" "ruG" "riG" "raG" "rEG" "rG" "roG" "rWaG" ;; 40 | |
1525 "seG" "suG" "siG" "saG" "sEG" "sG" "soG" "sWaG" ;; 48 | |
1526 "xeG" "xuG" "xiG" "xaG" "xEG" "xG" "xoG" "xWaG" ;; 56 | |
1527 "qeG" "quG" "qiG" "qaG" "qE" "qG" "qoG" "" ;; 64 | |
1528 "qWeG" "" "qWi" "qWaG" "qWEG" "qWG" "" "" ;; 72 | |
1529 "QeG" "QuG" "QiG" "QaG" "QEG" "QG" "QoG" "" ;; 80 | |
1530 "QWeG" "" "QWiG" "QWaG" "QWEG" "QWG" "" "" ;; 88 | |
1531 "beG" "buG" "biG" "baG" "bEG" "bG" "boG" "bWaG" ;; 96 | |
1532 "veG" "vuG" "viG" "vaG" "vEG" "vG" "voG" "vWaG" ;; 104 | |
1533 "teG" "tuG" "tiG" "taG" "tEG" "tG" "toG" "tWaG" ;; 112 | |
1534 "ceG" "cuG" "ciG" "caG" "cEG" "cG" "coG" "cWaG" ;; 120 | |
1535 "hheG" "hhuG" "hhiG" "hhaG" "hhEG" "hhG" "hhoG" "" ;; 128 | |
1536 "hWeG" "" "hWiG" "hWaG" "hWEG" "hWG" "" "" ;; 136 | |
1537 "neG" "nuG" "niG" "naG" "nEG" "nG" "noG" "nWaG" ;; 144 | |
1538 "NeG" "NuG" "NiG" "NaG" "NEG" "NG" "NoG" "NWaG" ;; 152 | |
1539 "eG" "uG" "iG" "AG" "EG" "IG" "oGG" "eaG" ;; 160 | |
1540 "keG" "kuG" "kiG" "kaG" "kEG" "kG" "koG" "" ;; 168 | |
1541 "kWeG" "" "kWiG" "kWa" "kWEG" "kWG" "" "" ;; 176 | |
1542 "KeG" "KuG" "KiG" "KaG" "KEG" "KG" "KoG" "" ;; 184 | |
1543 "KWeG" "" "KWiG" "KWa" "KWEG" "KWG" "" "" ;; 192 | |
1544 "weG" "wuG" "wiG" "waG" "wEG" "wG" "woG" "" ;; 200 | |
1545 "eeG" "uuG" "iiG" "aaG" "EEG" "IIG" "ooG" "" ;; 208 | |
1546 "zeG" "zuG" "ziG" "zaG" "zEG" "zG" "zoG" "zWaG" ;; 216 | |
1547 "ZeG" "ZuG" "ZiG" "ZaG" "ZEG" "ZG" "ZoG" "ZWaG" ;; 224 | |
1548 "yeG" "yuG" "yiG" "yaG" "yEG" "yG" "yoG" "yWaG" ;; 232 | |
1549 "deG" "duG" "diG" "daG" "dEG" "dG" "doG" "dWaG" ;; 240 | |
1550 "DeG" "DuG" "DiG" "DaG" "DEG" "DG" "DoG" "DWaG" ;; 248 | |
1551 "jeG" "juG" "jiG" "jaG" "jEG" "jG" "joG" "jWaG" ;; 256 | |
1552 "geG" "guG" "giG" "gaG" "gEG" "gG" "goG" "" ;; 264 | |
1553 "gWeG" "" "gWiG" "gWaG" "gWEG" "gWG" "" "" ;; 272 | |
1554 "GeG" "GuG" "GiG" "GaG" "GEG" "GG" "GoG" "GWaG" ;; 280 | |
1555 "TeG" "TuG" "TiG" "TaG" "TEG" "TG" "ToG" "TWaG" ;; 288 | |
1556 "CeG" "CuG" "CiG" "CaG" "CEG" "CG" "CoG" "CWaG" ;; 296 | |
1557 "PeG" "PuG" "PiG" "PaG" "PEG" "PG" "PoG" "PWaG" ;; 304 | |
1558 "SeG" "SuG" "SiG" "SaG" "SEG" "SG" "SoG" "SWaG" ;; 312 | |
1559 "SSeG" "SSuG" "SSiG" "SSaG" "SSEG" "SSG" "SSoG" "" ;; 320 | |
1560 "feG" "fuG" "fiG" "faG" "fEG" "fG" "foG" "fWaG" ;; 328 | |
1561 "peG" "puG" "piG" "paG" "pEG" "pG" "poG" "pWaG" ;; 336 | |
1562 "mYaG" "rYaG" "fYaG" "" "" "" "" "" ;; 344 | |
1563 "" "spaceG" "periodG" "commaG" ;; 352 | |
1564 "semicolonG" "colonG" "precolonG" "oldqmarkG" ;; 356 | |
1565 "pbreakG" "andG" "huletG" "sostG" "aratG" "amstG" "sadstG" "sabatG" ;; 360 | |
1566 "smntG" "zeteNG" "asrG" "heyaG" "selasaG" "arbaG" "hemsaG" "slsaG" ;; 368 | |
1567 "sebaG" "semanyaG" "zeTanaG" "metoG" "asrxiG" "" "" "" ;; 376 | |
1568 "qqeG" "qquG" "qqiG" "qqaG" "qqEG" "qqG" "qqoG" "" ;; 384 | |
1569 "mWeG" "bWeG" "GWeG" "fWeG" "pWeG" "" "" "" ;; 392 | |
1570 "kkeG" "kkuG" "kkiG" "kkaG" "kkEG" "kkG" "kkoG" "" ;; 400 | |
1571 "mWiG" "bWiG" "GWiG" "fWiG" "pWiG" "" "" "" ;; 408 | |
1572 "XeG" "XuG" "GXiG" "XaG" "XEG" "XG" "XoG" "" ;; 416 | |
1573 "mWEG" "bWEG" "GWEG" "fWEG" "pWEG" "" "" "" ;; 424 | |
1574 "ggeG" "gguG" "ggiG" "ggaG" "ggEG" "ggG" "ggoG" "" ;; 432 | |
1575 "mWG" "bWG" "GWG" "fWG" "pWG" "" "" "" ;; 440 | |
1576 "ornamentG" "flandG" "iflandG" "africaG" ;; 448 | |
1577 "iafricaG" "wWeG" "wWiG" "wWaG" ;; 452 | |
1578 "wWEG" "wWG" "" "slaqG" "dotG" "lquoteG" "rquoteG" "qmarkG" ]) ;; 456 | |
1579 | |
1580 ;; | |
1581 ;; To make tex-to-fidel mapping. | |
1582 ;; The following code makes | |
1583 ;; (get 'ethio-tex-command-he 'ethio-fidel-char) ==> ?$(3!!(B | |
1584 ;; etc. | |
1585 ;; | |
1586 | |
1587 (let ((i 0) str) | |
1588 (while (< i (length ethio-fidel-to-tex-map)) | |
1589 (setq str (aref ethio-fidel-to-tex-map i)) | |
1590 (if (not (string= str "")) | |
1591 (put | |
1592 (intern (concat "ethio-tex-command-" (aref ethio-fidel-to-tex-map i))) | |
1593 'ethio-fidel-char | |
1594 (ethio-ethiocode-to-char i))) | |
1595 (setq i (1+ i)))) | |
1596 | |
1597 ;;;###autoload | |
1598 (defun ethio-fidel-to-tex-buffer nil | |
1599 "Convert each fidel characters in the current buffer into a fidel-tex command. | |
1600 Each command is always surrounded by braces." | |
1601 (interactive) | |
1602 (let ((buffer-read-only nil)) | |
1603 | |
1604 ;; Isolated gemination marks need special treatement | |
1605 (goto-char (point-min)) | |
1606 (while (search-forward "$(3%s(B" nil t) | |
1607 (replace-match "\\geminateG{}" t t)) | |
1608 | |
1609 ;; First, decompose geminations | |
1610 ;; Here we assume that each composed character consists of | |
1611 ;; one Ethiopic character and the Ethiopic gemination mark. | |
1612 (decompose-region (point-min) (point-max)) | |
1613 | |
1614 ;; Special treatment for geminated characters | |
1615 ;; The geminated character (la'') will be "\geminateG{\la}". | |
1616 (goto-char (point-min)) | |
1617 (while (search-forward "$(3%s(B" nil t) | |
1618 (delete-backward-char 1) | |
1619 (backward-char 1) | |
1620 (insert "\\geminateG") | |
1621 (forward-char 1)) | |
1622 | |
1623 ;; Ethiopic characters to TeX macros | |
1624 (goto-char (point-min)) | |
1625 (while (re-search-forward "\\ce" nil t) | |
1626 (insert | |
1627 "{\\" | |
1628 (aref ethio-fidel-to-tex-map | |
1629 (prog1 (ethio-char-to-ethiocode (preceding-char)) | |
1630 (backward-delete-char 1))) | |
1631 "}")) | |
1632 (goto-char (point-min)) | |
1633 (set-buffer-modified-p nil))) | |
1634 | |
1635 ;;;###autoload | |
1636 (defun ethio-tex-to-fidel-buffer nil | |
1637 "Convert fidel-tex commands in the current buffer into fidel chars." | |
1638 (interactive) | |
1639 (let ((buffer-read-only nil) | |
1640 (p) (ch)) | |
1641 | |
1642 ;; Special treatment for gemination | |
1643 ;; "\geminateG{\la}" or "\geminateG{{\la}}" will be "\la$(3%s(B" | |
1644 ;; "\geminateG{}" remains unchanged. | |
1645 (goto-char (point-min)) | |
1646 (while (re-search-forward "\\\\geminateG{\\(\\\\[a-zA-Z]+\\)}" nil t) | |
1647 (replace-match "\\1$(3%s(B")) | |
1648 | |
1649 ;; TeX macros to Ethiopic characters | |
1650 (goto-char (point-min)) | |
1651 (while (search-forward "\\" nil t) | |
1652 (setq p (point)) | |
1653 (skip-chars-forward "a-zA-Z") | |
1654 (setq ch | |
1655 (get (intern (concat "ethio-tex-command-" | |
1656 (buffer-substring p (point)))) | |
1657 'ethio-fidel-char)) | |
1658 (if ch | |
1659 (progn | |
1660 (delete-region (1- p) (point)) ; don't forget the preceding "\" | |
1661 (if (and (= (preceding-char) ?{) | |
1662 (= (following-char) ?})) | |
1663 (progn | |
1664 (backward-delete-char 1) | |
1665 (delete-char 1))) | |
1666 (insert ch)))) | |
1667 | |
1668 ;; compose geminated characters | |
1669 (goto-char (point-min)) | |
1670 (while (re-search-forward "\\ce$(3%s(B" nil 0) | |
1671 (compose-region | |
1672 (save-excursion (backward-char 2) (point)) | |
1673 (point))) | |
1674 | |
1675 ;; Now it's time to convert isolated gemination marks. | |
1676 (goto-char (point-min)) | |
1677 (while (search-forward "\\geminateG{}" nil t) | |
1678 (replace-match "$(3%s(B")) | |
1679 | |
1680 (goto-char (point-min)) | |
1681 (set-buffer-modified-p nil))) | |
1682 | |
1683 ;; | |
1684 ;; Java support | |
1685 ;; | |
1686 | |
1687 ;;;###autoload | |
1688 (defun ethio-fidel-to-java-buffer nil | |
1689 "Convert Ethiopic characters into the Java escape sequences. | |
1690 | |
1691 Each escape sequence is of the form \uXXXX, where XXXX is the | |
1692 character's codepoint (in hex) in Unicode. | |
1693 | |
1694 If `ethio-java-save-lowercase' is non-nil, use [0-9a-f]. | |
1695 Otherwise, [0-9A-F]." | |
1696 (let ((ucode)) | |
1697 | |
1698 ;; first, decompose geminations | |
1699 (decompose-region (point-min) (point-max)) | |
1700 | |
1701 (goto-char (point-min)) | |
1702 (while (re-search-forward "\\ce" nil t) | |
1703 (setq ucode (+ ?\x1200 (ethio-char-to-ethiocode (preceding-char)))) | |
1704 (if (> ucode ?\x13bc) | |
1705 (setq ucode (+ ucode 59952))) | |
1706 (delete-backward-char 1) | |
1707 (if ethio-java-save-lowercase | |
1708 (insert (format "\\u%4x" ucode)) | |
1709 (insert (upcase (format "\\u%4x" ucode))))))) | |
1710 | |
1711 ;;;###autoload | |
1712 (defun ethio-java-to-fidel-buffer nil | |
1713 "Convert the Java escape sequences into corresponding Ethiopic characters." | |
1714 (let ((ucode)) | |
1715 (goto-char (point-min)) | |
1716 (while (re-search-forward "\\\\u\\([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]\\)" nil t) | |
1717 (setq ucode | |
1718 (read | |
1719 (concat | |
1720 "?\\x" | |
1721 (buffer-substring (match-beginning 1) (match-end 1))))) | |
1722 (cond | |
1723 ((and (>= ucode ?\x1200) (<= ucode ?\x13bc)) | |
1724 (replace-match "") | |
1725 (insert (ethio-ethiocode-to-char (- ucode ?\x1200)))) | |
1726 ((and (>= ucode ?\xfdf1) (<= ucode ?\xfdff)) | |
1727 (replace-match "") | |
1728 (insert (ethio-ethiocode-to-char (- ucode 64560)))) | |
1729 (t | |
1730 nil))) | |
1731 | |
1732 ;; gemination | |
1733 (goto-char (point-min)) | |
1734 (while (re-search-forward "\\ce$(3%s(B" nil 0) | |
1735 (compose-region | |
1736 (save-excursion (backward-char 2) (point)) | |
1737 (point))) | |
1738 )) | |
1739 | |
1740 ;; | |
1741 ;; file I/O hooks | |
1742 ;; | |
1743 | |
1744 ;;;###autoload | |
1745 (defun ethio-find-file nil | |
1746 "Transcribe file content into Ethiopic dependig on filename suffix." | |
1747 (cond | |
1748 | |
1749 ((string-match "\\.sera$" (buffer-file-name)) | |
1750 (save-excursion | |
1751 (ethio-sera-to-fidel-buffer nil 'force) | |
1752 (set-buffer-modified-p nil))) | |
1753 | |
1754 ((string-match "\\.html$" (buffer-file-name)) | |
1755 (let ((sera-being-called-by-w3 t)) | |
1756 (save-excursion | |
1757 (ethio-sera-to-fidel-marker 'force) | |
1758 (goto-char (point-min)) | |
1759 (while (re-search-forward "&[lr]aquote;" nil t) | |
1760 (if (= (char-after (1+ (match-beginning 0))) ?l) | |
1761 (replace-match "$(3%v(B") | |
1762 (replace-match "$(3%w(B"))) | |
1763 (set-buffer-modified-p nil)))) | |
1764 | |
1765 ((string-match "\\.tex$" (buffer-file-name)) | |
1766 (save-excursion | |
1767 (ethio-tex-to-fidel-buffer) | |
1768 (set-buffer-modified-p nil))) | |
1769 | |
1770 ((string-match "\\.java$" (buffer-file-name)) | |
1771 (save-excursion | |
1772 (ethio-java-to-fidel-buffer) | |
1773 (set-buffer-modified-p nil))) | |
1774 | |
1775 (t | |
1776 nil))) | |
1777 | |
1778 ;;;###autoload | |
1779 (defun ethio-write-file nil | |
1780 "Transcribe Ethiopic characters in ASCII depending on the file extension." | |
1781 (cond | |
1782 | |
1783 ((string-match "\\.sera$" (buffer-file-name)) | |
1784 (save-excursion | |
1785 (ethio-fidel-to-sera-buffer nil 'force) | |
1786 (goto-char (point-min)) | |
1787 (ethio-record-user-preference) | |
1788 (set-buffer-modified-p nil))) | |
1789 | |
1790 ((string-match "\\.html$" (buffer-file-name)) | |
1791 (save-excursion | |
1792 (let ((sera-being-called-by-w3 t) | |
1793 (lq (aref ethio-fidel-to-sera-map 461)) | |
1794 (rq (aref ethio-fidel-to-sera-map 462))) | |
1795 (aset ethio-fidel-to-sera-map 461 "«te;") | |
1796 (aset ethio-fidel-to-sera-map 462 "»te;") | |
1797 (ethio-fidel-to-sera-marker 'force) | |
1798 (goto-char (point-min)) | |
1799 (if (search-forward "<sera>" nil t) | |
1800 (ethio-record-user-preference)) | |
1801 (aset ethio-fidel-to-sera-map 461 lq) | |
1802 (aset ethio-fidel-to-sera-map 462 rq) | |
1803 (set-buffer-modified-p nil)))) | |
1804 | |
1805 ((string-match "\\.tex$" (buffer-file-name)) | |
1806 (save-excursion | |
1807 (ethio-fidel-to-tex-buffer) | |
1808 (set-buffer-modified-p nil))) | |
1809 | |
1810 ((string-match "\\.java$" (buffer-file-name)) | |
1811 (save-excursion | |
1812 (ethio-fidel-to-java-buffer) | |
1813 (set-buffer-modified-p nil))) | |
1814 | |
1815 (t | |
1816 nil))) | |
1817 | |
1818 (defun ethio-record-user-preference nil | |
1819 (if (looking-at "\\\\~\\(tir?\\|amh?\\) ") | |
1820 (goto-char (match-end 0)) | |
1821 (insert (if (ethio-prefer-amharic-p) "\\~amh " "\\~tir "))) | |
1822 (insert (if ethio-use-colon-for-colon "\\~-: " "\\~`: ") | |
1823 (if ethio-use-three-dot-question "\\~`| " "\\~`? "))) | |
1824 | |
1825 (add-hook 'find-file-hooks 'ethio-find-file) | |
1826 (add-hook 'write-file-hooks 'ethio-write-file) | |
1827 (add-hook 'after-save-hook 'ethio-find-file) | |
1828 | |
1829 ;; | |
17052 | 1830 (provide 'language/ethio-util) |
1831 | |
1832 ;;; Local Variables: | |
1833 ;;; generated-autoload-file: "../loaddefs.el" | |
1834 ;;; End: | |
1835 ;;; ethio-util.el ends here |