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