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