Mercurial > emacs
annotate lisp/language/lao-util.el @ 40207:7c57640154a5
(x_draw_glyphs): Remove parameters READ_START and
REAL_END. Notice if cursor gets overwritten.
(notice_overwritten_cursor): Take X positions as parameters.
(x_draw_phys_cursor_glyph): Save state of w->phys_cursor_on_p
around call to x_draw_glyphs.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 23 Oct 2001 12:03:47 +0000 |
parents | 67b464da13ec |
children | fc0965c8ee87 |
rev | line source |
---|---|
36683
b82a6fbaae16
Add coding: iso-2022-7bit tag.
Kenichi Handa <handa@m17n.org>
parents:
29361
diff
changeset
|
1 ;;; lao-util.el --- utilities for Lao -*- coding: iso-2022-7bit; -*- |
17083 | 2 |
3 ;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN. | |
18377
8b4a66c66dd6
Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
18309
diff
changeset
|
4 ;; Licensed to the Free Software Foundation. |
17083 | 5 |
6 ;; Keywords: multilingual, Lao | |
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 | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36683
diff
changeset
|
25 ;;; Commentary: |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36683
diff
changeset
|
26 |
17083 | 27 ;;; Code: |
28 | |
26894 | 29 ;; Setting information of Thai characters. |
30 | |
31 (defconst lao-category-table (make-category-table)) | |
32 (define-category ?c "Lao consonant" lao-category-table) | |
33 (define-category ?s "Lao semi-vowel" lao-category-table) | |
34 (define-category ?v "Lao upper/lower vowel" lao-category-table) | |
35 (define-category ?t "Lao tone" lao-category-table) | |
36 | |
17083 | 37 (let ((l '((?(1!(B consonant "LETTER KOR KAI'" "CHICKEN") |
38 (?(1"(B consonant "LETTER KHOR KHAI'" "EGG") | |
39 (?(1#(B invalid nil) | |
40 (?(1$(B consonant "LETTER QHOR QHWARGN" "BUFFALO") | |
41 (?(1%(B invalid nil) | |
42 (? invalid nil) | |
43 (?(1'(B consonant "LETTER NGOR NGUU" "SNAKE") | |
44 (?(1((B consonant "LETTER JOR JUA" "BUDDHIST NOVICE") | |
45 (?(1)(B invalid nil) | |
46 (?(1*(B consonant "LETTER XOR X\"ARNG" "ELEPHANT") | |
47 (?(1+(B invalid nil) | |
48 (?(1,(B invalid nil) | |
49 (?(1-(B consonant "LETTER YOR YUNG" "MOSQUITO") | |
50 (?(1.(B invalid nil) | |
51 (?(1.(B invalid nil) | |
52 (?(1.(B invalid nil) | |
53 (?(1.(B invalid nil) | |
54 (?(1.(B invalid nil) | |
55 (?(1.(B invalid nil) | |
56 (?(14(B consonant "LETTER DOR DANG" "NOSE") | |
57 (?(15(B consonant "LETTER TOR TAR" "EYE") | |
19271
0caaca9020bc
Set t for Rao-SEMIVOWEL-SIGN-LO in
Kenichi Handa <handa@m17n.org>
parents:
18550
diff
changeset
|
58 (?(16(B consonant "LETTER THOR THUNG" "TO ASK,QUESTION") |
0caaca9020bc
Set t for Rao-SEMIVOWEL-SIGN-LO in
Kenichi Handa <handa@m17n.org>
parents:
18550
diff
changeset
|
59 (?(17(B consonant "LETTER DHOR DHARM" "FLAG") |
17083 | 60 (?(18(B invalid nil) |
61 (?(19(B consonant "LETTER NOR NOK" "BIRD") | |
62 (?(1:(B consonant "LETTER BOR BED" "FISHHOOK") | |
63 (?(1;(B consonant "LETTER POR PAR" "FISH") | |
64 (?(1<(B consonant "LETTER HPOR HPER\"" "BEE") | |
65 (?(1=(B consonant "LETTER FHOR FHAR" "WALL") | |
66 (?(1>(B consonant "LETTER PHOR PHUU" "MOUNTAIN") | |
67 (?(1?(B consonant "LETTER FOR FAI" "FIRE") | |
68 (?(1@(B invalid nil) | |
69 (?(1A(B consonant "LETTER MOR MAR\"" "HORSE") | |
70 (?(1B(B consonant "LETTER GNOR GNAR" "MEDICINE") | |
71 (?(1C(B consonant "LETTER ROR ROD" "CAR") | |
72 (?(1D(B invalid nil) | |
73 (?(1E(B consonant "LETTER LOR LIING" "MONKEY") | |
74 (?(1F(B invalid nil) | |
75 (?(1G(B consonant "LETTER WOR WII" "HAND FAN") | |
76 (?(1H(B invalid nil) | |
77 (?(1I(B invalid nil) | |
78 (?(1J(B consonant "LETTER SOR SEA" "TIGER") | |
79 (?(1K(B consonant "LETTER HHOR HHAI" "JAR") | |
80 (?(1L(B invalid nil) | |
81 (?(1M(B consonant "LETTER OR OOW" "TAKE") | |
82 (?(1N(B consonant "LETTER HOR HEA" "BOAT") | |
83 (?(1O(B special "ELLIPSIS") | |
84 (?(1P(B vowel-base "VOWEL SIGN SARA A") | |
85 (?(1Q(B vowel-upper "VOWEL SIGN MAI KAN") | |
86 (?(1R(B vowel-base "VOWEL SIGN SARA AR") | |
87 (?(1S(B vowel-base "VOWEL SIGN SARA AM") | |
88 (?(1T(B vowel-upper "VOWEL SIGN SARA I") | |
89 (?(1U(B vowel-upper "VOWEL SIGN SARA II") | |
90 (?(1V(B vowel-upper "VOWEL SIGN SARA EU") | |
91 (?(1W(B vowel-upper "VOWEL SIGN SARA UR") | |
92 (?(1X(B vowel-lower "VOWEL SIGN SARA U") | |
93 (?(1Y(B vowel-lower "VOWEL SIGN SARA UU") | |
94 (?(1Z(B invalid nil) | |
95 (?(1[(B vowel-upper "VOWEL SIGN MAI KONG") | |
96 (?(1\(B semivowel-lower "SEMIVOWEL SIGN LO") | |
97 (?(1](B vowel-base "SEMIVOWEL SIGN SARA IA") | |
98 (?(1^(B invalid nil) | |
99 (?(1_(B invalid nil) | |
100 (?(1`(B vowel-base "VOWEL SIGN SARA EE") | |
101 (?(1a(B vowel-base "VOWEL SIGN SARA AA") | |
102 (?(1b(B vowel-base "VOWEL SIGN SARA OO") | |
103 (?(1c(B vowel-base "VOWEL SIGN SARA EI MAI MUAN\"") | |
104 (?(1d(B vowel-base "VOWEL SIGN SARA AI MAI MAY") | |
105 (?(1e(B invalid nil) | |
106 (?(1f(B special "KO LA (REPETITION)") | |
107 (?(1g(B invalid nil) | |
108 (?(1h(B tone "TONE MAI EK") | |
109 (?(1i(B tone "TONE MAI THO") | |
110 (?(1j(B tone "TONE MAI TI") | |
111 (?(1k(B tone "TONE MAI JADTAWAR") | |
112 (?(1l(B tone "CANCELLATION MARK") | |
113 (?(1m(B vowel-upper "VOWEL SIGN SARA OR") | |
114 (?(1n(B invalid nil) | |
115 (?(1o(B invalid nil) | |
116 (?(1p(B special "DIGIT ZERO") | |
117 (?(1q(B special "DIGIT ONE") | |
118 (?(1r(B special "DIGIT TWO") | |
119 (?(1s(B special "DIGIT THREE") | |
120 (?(1t(B special "DIGIT FOUR") | |
121 (?(1u(B special "DIGIT FIVE") | |
122 (?(1v(B special "DIGIT SIX") | |
123 (?(1w(B special "DIGIT SEVEN") | |
124 (?(1x(B special "DIGIT EIGHT") | |
125 (?(1y(B special "DIGIT NINE") | |
126 (?(1z(B invalid nil) | |
127 (?(1{(B invalid nil) | |
128 (?(1|(B consonant "LETTER NHOR NHUU" "MOUSE") | |
129 (?(1}(B consonant "LETTER MHOR MHAR" "DOG") | |
130 (?(1~(B invalid nil) | |
131 )) | |
132 elm) | |
133 (while l | |
26894 | 134 (setq elm (car l) l (cdr l)) |
135 (let ((char (car elm)) | |
136 (ptype (nth 1 elm))) | |
137 (cond ((eq ptype 'consonant) | |
138 (modify-category-entry char ?c lao-category-table)) | |
139 ((memq ptype '(vowel-upper vowel-lower)) | |
140 (modify-category-entry char ?v lao-category-table)) | |
141 ((eq ptype 'semivowel-lower) | |
142 (modify-category-entry char ?s lao-category-table)) | |
143 ((eq ptype 'tone) | |
144 (modify-category-entry char ?t lao-category-table))) | |
145 (put-char-code-property char 'phonetic-type ptype) | |
146 (put-char-code-property char 'name (nth 2 elm)) | |
147 (put-char-code-property char 'meaning (nth 3 elm))))) | |
148 | |
149 ;; The general composing rules are as follows: | |
150 ;; | |
151 ;; T | |
152 ;; V T V T | |
153 ;; CV -> C, CT -> C, CVT -> C, Cv -> C, CvT -> C | |
154 ;; v v | |
155 ;; T | |
156 ;; V T V T | |
157 ;; CsV -> C, CsT -> C, CsVT -> C, Csv -> C, CvT -> C | |
158 ;; s s s s s | |
159 ;; v v | |
160 | |
161 | |
162 ;; where C: consonant, V: vowel upper, v: vowel lower, | |
163 ;; T: tone mark, s: semivowel lower | |
164 | |
165 (defvar lao-composition-pattern | |
166 "\\cc\\(\\ct\\|\\cv\\ct?\\|\\cs\\(\\ct\\|\\cv\\ct?\\)?\\)" | |
167 "Regular expression matching a Lao composite sequence.") | |
168 | |
169 ;;;###autoload | |
170 (defun lao-compose-string (str) | |
171 (with-category-table lao-category-table | |
172 (let ((idx 0)) | |
173 (while (setq idx (string-match lao-composition-pattern str idx)) | |
174 (compose-string str idx (match-end 0)) | |
175 (setq idx (match-end 0)))) | |
176 str)) | |
177 | |
178 ;;; LRT: Lao <-> Roman Transcription | |
179 | |
180 ;; Upper vowels and tone-marks are put on the letter. | |
181 ;; Semi-vowel-sign-lo and lower vowels are put under the letter. | |
182 | |
183 (defconst lao-transcription-consonant-alist | |
184 (sort '(;; single consonants | |
185 ("k" . "(1!(B") | |
186 ("kh" . "(1"(B") | |
187 ("qh" . "(1$(B") | |
188 ("ng" . "(1'(B") | |
189 ("j" . "(1((B") | |
190 ("s" . "(1J(B") | |
191 ("x" . "(1*(B") | |
192 ("y" . "(1-(B") | |
193 ("d" . "(14(B") | |
194 ("t" . "(15(B") | |
195 ("th" . "(16(B") | |
196 ("dh" . "(17(B") | |
197 ("n" . "(19(B") | |
198 ("b" . "(1:(B") | |
199 ("p" . "(1;(B") | |
200 ("hp" . "(1<(B") | |
201 ("fh" . "(1=(B") | |
202 ("ph" . "(1>(B") | |
203 ("f" . "(1?(B") | |
204 ("m" . "(1A(B") | |
205 ("gn" . "(1B(B") | |
206 ("l" . "(1E(B") | |
207 ("r" . "(1C(B") | |
208 ("v" . "(1G(B") | |
209 ("w" . "(1G(B") | |
210 ("hh" . "(1K(B") | |
211 ("O" . "(1M(B") | |
212 ("h" . "(1N(B") | |
213 ("nh" . "(1|(B") | |
214 ("mh" . "(1}(B") | |
215 ("lh" . ["(1K\(B"]) | |
216 ;; double consonants | |
217 ("ngh" . ["(1K'(B"]) | |
218 ("yh" . ["(1K](B"]) | |
219 ("wh" . ["(1KG(B"]) | |
220 ("hl" . ["(1KE(B"]) | |
221 ("hy" . ["(1K-(B"]) | |
222 ("hn" . ["(1K9(B"]) | |
223 ("hm" . ["(1KA(B"]) | |
224 ) | |
225 (function (lambda (x y) (> (length (car x)) (length (car y))))))) | |
226 | |
227 (defconst lao-transcription-semi-vowel-alist | |
228 '(("r" . "(1\(B"))) | |
229 | |
230 (defconst lao-transcription-vowel-alist | |
231 (sort '(("a" . "(1P(B") | |
232 ("ar" . "(1R(B") | |
233 ("i" . "(1T(B") | |
234 ("ii" . "(1U(B") | |
235 ("eu" . "(1V(B") | |
236 ("ur" . "(1W(B") | |
237 ("u" . "(1X(B") | |
238 ("uu" . "(1Y(B") | |
239 ("e" . ["(1`P(B"]) | |
240 ("ee" . "(1`(B") | |
241 ("ae" . ["(1aP(B"]) | |
242 ("aa" . "(1a(B") | |
243 ("o" . ["(1bP(B"]) | |
244 ("oo" . "(1b(B") | |
245 ("oe" . ["(1`RP(B"]) | |
246 ("or" . "(1m(B") | |
247 ("er" . ["(1`T(B"]) | |
248 ("ir" . ["(1`U(B"]) | |
249 ("ua" . ["(1[GP(B"]) | |
250 ("uaa" . ["(1[G(B"]) | |
251 ("ie" . ["(1`Q]P(B"]) | |
252 ("ia" . ["(1`Q](B"]) | |
253 ("ea" . ["(1`VM(B"]) | |
254 ("eaa" . ["(1`WM(B"]) | |
255 ("ai" . "(1d(B") | |
256 ("ei" . "(1c(B") | |
257 ("ao" . ["(1`[R(B"]) | |
258 ("aM" . "(1S(B")) | |
259 (function (lambda (x y) (> (length (car x)) (length (car y))))))) | |
260 | |
261 ;; Maa-sakod is put at the tail. | |
262 (defconst lao-transcription-maa-sakod-alist | |
263 '(("k" . "(1!(B") | |
264 ("g" . "(1'(B") | |
265 ("y" . "(1-(B") | |
266 ("d" . "(14(B") | |
267 ("n" . "(19(B") | |
268 ("b" . "(1:(B") | |
269 ("m" . "(1A(B") | |
270 ("v" . "(1G(B") | |
271 ("w" . "(1G(B") | |
272 )) | |
273 | |
274 (defconst lao-transcription-tone-alist | |
275 '(("'" . "(1h(B") | |
276 ("\"" . "(1i(B") | |
277 ("^" . "(1j(B") | |
278 ("+" . "(1k(B") | |
279 ("~" . "(1l(B"))) | |
280 | |
281 (defconst lao-transcription-punctuation-alist | |
282 '(("\\0" . "(1p(B") | |
283 ("\\1" . "(1q(B") | |
284 ("\\2" . "(1r(B") | |
285 ("\\3" . "(1s(B") | |
286 ("\\4" . "(1t(B") | |
287 ("\\5" . "(1u(B") | |
288 ("\\6" . "(1v(B") | |
289 ("\\7" . "(1w(B") | |
290 ("\\8" . "(1x(B") | |
291 ("\\9" . "(1y(B") | |
292 ("\\\\" . "(1f(B") | |
293 ("\\$" . "(1O(B"))) | |
294 | |
295 (defconst lao-transcription-pattern | |
296 (concat | |
297 "\\(" | |
298 (mapconcat 'car lao-transcription-consonant-alist "\\|") | |
299 "\\)\\(" | |
300 (mapconcat 'car lao-transcription-semi-vowel-alist "\\|") | |
301 "\\)?\\(\\(" | |
302 (mapconcat 'car lao-transcription-vowel-alist "\\|") | |
303 "\\)\\(" | |
304 (mapconcat 'car lao-transcription-maa-sakod-alist "\\|") | |
305 "\\)?\\(" | |
306 (mapconcat (lambda (x) (regexp-quote (car x))) | |
307 lao-transcription-tone-alist "\\|") | |
308 "\\)?\\)?\\|" | |
309 (mapconcat (lambda (x) (regexp-quote (car x))) | |
310 lao-transcription-punctuation-alist "\\|") | |
311 ) | |
312 "Regexp of Roman transcription pattern for one Lao syllable.") | |
313 | |
314 (defconst lao-transcription-pattern | |
315 (concat | |
316 "\\(" | |
317 (regexp-opt (mapcar 'car lao-transcription-consonant-alist)) | |
318 "\\)\\(" | |
319 (regexp-opt (mapcar 'car lao-transcription-semi-vowel-alist)) | |
320 "\\)?\\(\\(" | |
321 (regexp-opt (mapcar 'car lao-transcription-vowel-alist)) | |
322 "\\)\\(" | |
323 (regexp-opt (mapcar 'car lao-transcription-maa-sakod-alist)) | |
324 "\\)?\\(" | |
325 (regexp-opt (mapcar 'car lao-transcription-tone-alist)) | |
326 "\\)?\\)?\\|" | |
327 (regexp-opt (mapcar 'car lao-transcription-punctuation-alist)) | |
328 ) | |
329 "Regexp of Roman transcription pattern for one Lao syllable.") | |
330 | |
331 (defconst lao-vowel-reordering-rule | |
332 '(("(1P(B" (0 ?(1P(B) (0 ?(1Q(B)) | |
333 ("(1R(B" (0 ?(1R(B)) | |
334 ("(1T(B" (0 ?(1U(B)) | |
335 ("(1U(B" (0 ?(1U(B)) | |
336 ("(1V(B" (0 ?(1V(B)) | |
337 ("(1W(B" (0 ?(1W(B)) | |
338 ("(1X(B" (0 ?(1X(B)) | |
339 ("(1Y(B" (0 ?(1Y(B)) | |
340 ("(1`P(B" (?(1`(B 0 ?(1P(B) (?(1`(B 0 ?(1Q(B)) | |
341 ("(1`(B" (?(1`(B 0)) | |
342 ("(1aP(B" (?(1a(B 0 ?(1P(B) (?(1a(B 0 ?(1Q(B)) | |
343 ("(1a(B" (?(1a(B 0)) | |
344 ("(1bP(B" (?(1b(B 0 ?(1P(B) (0 ?(1[(B) (?(1-(B ?(1b(B 0 ?(1Q(B) (?(1G(B ?(1b(B 0 ?(1Q(B)) | |
345 ("(1b(B" (?(1b(B 0)) | |
346 ("(1`RP(B" (?(1`(B 0 ?(1R(B ?(1P(B) (0 ?(1Q(B ?(1M(B)) | |
347 ("(1m(B" (0 ?(1m(B) (0 ?(1M(B)) | |
348 ("(1`T(B" (?(1`(B 0 ?(1T(B)) | |
349 ("(1`U(B" (?(1`(B 0 ?(1U(B)) | |
350 ("(1[GP(B" (0 ?(1[(B ?(1G(B ?(1P(B) (0 ?(1Q(B ?(1G(B)) | |
351 ("(1[G(B" (0 ?(1[(B ?(1G(B) (0 ?(1G(B)) | |
352 ("(1`Q]P(B" (?(1`(B 0 ?(1Q(B ?(1](B ?(1P(B) (0 ?(1Q(B ?(1](B)) | |
353 ("(1`Q](B" (?(1`(B 0 ?(1Q(B ?(1](B) (0 ?(1](B)) | |
354 ("(1`VM(B" (?(1`(B 0 ?(1V(B ?(1M(B)) | |
355 ("(1`WM(B" (?(1`(B 0 ?(1W(B ?(1M(B)) | |
356 ("(1d(B" (?(1d(B 0)) | |
357 ("(1c(B" (?(1c(B 0)) | |
358 ("(1`[R(B" (?(1`(B 0 ?(1[(B ?(1R(B)) | |
359 ("(1S(B" (0 ?(1S(B))) | |
360 "Alist of Lao vowel string vs the corresponding re-ordering rule. | |
361 Each element has this form: | |
362 (VOWEL NO-MAA-SAKOD-RULE WITH-MAA-SAKOD-RULE (MAA-SAKOD-0 RULE-0) ...) | |
363 | |
364 VOWEL is a vowel string (e.g. \"(1`Q]P(B\"). | |
365 | |
366 NO-MAA-SAKOD-RULE is a rule to re-order and modify VOWEL following a | |
367 consonant. It is a list vowel characters or 0. The element 0 | |
368 indicate the place to embed a consonant. | |
369 | |
370 Optional WITH-MAA-SAKOD-RULE is a rule to re-order and modify VOWEL | |
371 follwoing a consonant and preceding a maa-sakod character. If it is | |
372 nil, NO-MAA-SAKOD-RULE is used. The maa-sakod character is alwasy | |
373 appended at the tail. | |
374 | |
375 For instance, rule `(\"(1`WM(B\" (?(1`(B t ?(1W(B ?(1M(B))' tells that this vowel | |
376 string following a consonant `(1!(B' should be re-ordered as \"(1`!WM(B\". | |
377 | |
378 Optional (MAA-SAKOD-n RULE-n) are rules specially applied to maa-sakod | |
379 character MAA-SAKOD-n.") | |
380 | |
381 ;;;###autoload | |
382 (defun lao-transcribe-single-roman-syllable-to-lao (from to &optional str) | |
383 "Transcribe a Romanized Lao syllable in the region FROM and TO to Lao string. | |
384 Only the first syllable is transcribed. | |
385 The value has the form: (START END LAO-STRING), where | |
386 START and END are the beggining and end positions of the Roman Lao syllable, | |
387 LAO-STRING is the Lao character transcription of it. | |
388 | |
389 Optional 3rd arg STR, if non-nil, is a string to search for Roman Lao | |
390 syllable. In that case, FROM and TO are indexes to STR." | |
391 (if str | |
392 (if (setq from (string-match lao-transcription-pattern str from)) | |
393 (progn | |
394 (if (>= from to) | |
395 (setq from nil) | |
396 (setq to (match-end 0))))) | |
397 (save-excursion | |
398 (goto-char from) | |
399 (if (setq to (re-search-forward lao-transcription-pattern to t)) | |
400 (setq from (match-beginning 0)) | |
401 (setq from nil)))) | |
402 (if from | |
403 (let* ((consonant (match-string 1 str)) | |
404 (semivowel (match-string 3 str)) | |
405 (vowel (match-string 5 str)) | |
406 (maa-sakod (match-string 8 str)) | |
407 (tone (match-string 9 str)) | |
408 lao-consonant lao-semivowel lao-vowel lao-maa-sakod lao-tone | |
409 clen cidx) | |
410 (setq to (match-end 0)) | |
411 (if (not consonant) | |
412 (setq str (cdr (assoc (match-string 0 str) | |
413 lao-transcription-punctuation-alist))) | |
414 (setq lao-consonant | |
415 (cdr (assoc consonant lao-transcription-consonant-alist))) | |
416 (if (vectorp lao-consonant) | |
417 (setq lao-consonant (aref lao-consonant 0))) | |
418 (setq clen (length lao-consonant)) | |
419 (if semivowel | |
420 ;; Include semivowel in STR. | |
421 (setq lao-semivowel | |
422 (cdr (assoc semivowel lao-transcription-semi-vowel-alist)) | |
423 str (if (= clen 1) | |
424 (concat lao-consonant lao-semivowel) | |
425 (concat (substring lao-consonant 0 1) lao-semivowel | |
426 (substring lao-consonant 1)))) | |
427 (setq str lao-consonant)) | |
428 (if vowel | |
429 (let (rule) | |
430 (setq lao-vowel | |
431 (cdr (assoc vowel lao-transcription-vowel-alist))) | |
432 (if (vectorp lao-vowel) | |
433 (setq lao-vowel (aref lao-vowel 0))) | |
434 (setq rule (assoc lao-vowel lao-vowel-reordering-rule)) | |
435 (if (null maa-sakod) | |
436 (setq rule (nth 1 rule)) | |
437 (setq lao-maa-sakod | |
438 (cdr (assoc maa-sakod lao-transcription-maa-sakod-alist)) | |
439 rule | |
440 (or (cdr (assq (aref lao-maa-sakod 0) (nthcdr 2 rule))) | |
441 (nth 2 rule) | |
442 (nth 1 rule)))) | |
443 (or rule | |
444 (error "Lao vowel %S has no re-ordering rule" lao-vowel)) | |
445 (setq lao-consonant str str "") | |
446 (while rule | |
447 (if (= (car rule) 0) | |
448 (setq str (concat str lao-consonant) | |
449 cidx (length str)) | |
450 (setq str (concat str (list (car rule))))) | |
451 (setq rule (cdr rule))) | |
452 (or cidx | |
453 (error "Lao vowel %S has malformed re-ordering rule" vowel)) | |
454 ;; Set CIDX to after upper or lower vowel if any. | |
455 (let ((len (length str))) | |
456 (while (and (< cidx len) | |
457 (memq (get-char-code-property (aref str cidx) | |
458 'phonetic-type) | |
459 '(vowel-lower vowel-upper))) | |
460 (setq cidx (1+ cidx)))) | |
461 (if lao-maa-sakod | |
462 (setq str (concat str lao-maa-sakod))) | |
463 (if tone | |
464 (setq lao-tone | |
465 (cdr (assoc tone lao-transcription-tone-alist)) | |
466 str (concat (substring str 0 cidx) lao-tone | |
467 (substring str cidx))))))) | |
468 (list from to (lao-compose-string str))))) | |
469 | |
470 ;;;###autoload | |
471 (defun lao-transcribe-roman-to-lao-string (str) | |
472 "Transcribe Romanized Lao string STR to Lao character string." | |
473 (let ((from 0) | |
474 (to (length str)) | |
475 (lao-str "") | |
476 val) | |
477 (while (setq val (lao-transcribe-single-roman-syllable-to-lao from to str)) | |
478 (let ((start (car val)) | |
479 (end (nth 1 val)) | |
480 (lao (nth 2 val))) | |
481 (if (> start from) | |
482 (setq lao-str (concat lao-str (substring str from start) lao)) | |
483 (setq lao-str (concat lao-str lao))) | |
484 (setq from end))) | |
485 (if (< from to) | |
486 (concat lao-str (substring str from to)) | |
487 lao-str))) | |
488 | |
489 ;;;###autoload | |
490 (defun lao-composition-function (from to pattern &optional string) | |
491 "Compose Lao text in the region FROM and TO. | |
492 The text matches the regular expression PATTERN. | |
493 Optional 4th argument STRING, if non-nil, is a string containing text | |
494 to compose. | |
495 | |
496 The return value is number of composed characters." | |
497 (if (< (1+ from) to) | |
498 (prog1 (- to from) | |
499 (if string | |
29361
a459df8781d0
(lao-composition-function): Fix args to compose-string.
Kenichi Handa <handa@m17n.org>
parents:
28906
diff
changeset
|
500 (compose-string string from to) |
26894 | 501 (compose-region from to)) |
502 (- to from)))) | |
17083 | 503 |
28791
bdf7581eb093
(lao-compose-region): New function.
Kenichi Handa <handa@m17n.org>
parents:
26894
diff
changeset
|
504 ;;;###autoload |
bdf7581eb093
(lao-compose-region): New function.
Kenichi Handa <handa@m17n.org>
parents:
26894
diff
changeset
|
505 (defun lao-compose-region (from to) |
bdf7581eb093
(lao-compose-region): New function.
Kenichi Handa <handa@m17n.org>
parents:
26894
diff
changeset
|
506 (interactive "r") |
bdf7581eb093
(lao-compose-region): New function.
Kenichi Handa <handa@m17n.org>
parents:
26894
diff
changeset
|
507 (save-restriction |
bdf7581eb093
(lao-compose-region): New function.
Kenichi Handa <handa@m17n.org>
parents:
26894
diff
changeset
|
508 (narrow-to-region from to) |
bdf7581eb093
(lao-compose-region): New function.
Kenichi Handa <handa@m17n.org>
parents:
26894
diff
changeset
|
509 (goto-char (point-min)) |
bdf7581eb093
(lao-compose-region): New function.
Kenichi Handa <handa@m17n.org>
parents:
26894
diff
changeset
|
510 (with-category-table lao-category-table |
bdf7581eb093
(lao-compose-region): New function.
Kenichi Handa <handa@m17n.org>
parents:
26894
diff
changeset
|
511 (while (re-search-forward lao-composition-pattern nil t) |
bdf7581eb093
(lao-compose-region): New function.
Kenichi Handa <handa@m17n.org>
parents:
26894
diff
changeset
|
512 (compose-region (match-beginning 0) (point)))))) |
bdf7581eb093
(lao-compose-region): New function.
Kenichi Handa <handa@m17n.org>
parents:
26894
diff
changeset
|
513 |
17083 | 514 ;; |
18309
bd8b521f5218
Provide XXX-util instead of
Kenichi Handa <handa@m17n.org>
parents:
18203
diff
changeset
|
515 (provide 'lao-util) |
17083 | 516 |
517 ;;; lao-util.el ends here |