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