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