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