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