Mercurial > emacs
annotate lisp/language/mlm-util.el @ 90661:486295710f09
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 16 Nov 2006 08:08:28 +0000 |
parents | 7beb78bc1f8e |
children | 6588c6259dfb |
rev | line source |
---|---|
49702 | 1 ;;; mlm-util.el --- support for composing malayalam characters -*-coding: iso-2022-7bit;-*- |
2 | |
3 ;; Copyright (C) 2003 Free Software Foundation, Inc. | |
4 | |
5 ;; Maintainer: KAWABATA, Taichi <kawabata@m17n.org> | |
6 ;; Keywords: multilingual, Malayalam | |
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 | |
64085 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
49702 | 24 |
25 ;; Created: Feb. 11. 2003 | |
26 | |
27 ;;; Commentary: | |
28 | |
29 ;; This file provides character(Unicode) to glyph(CDAC) conversion and | |
30 ;; composition of Malayalam script characters. | |
31 | |
32 ;;; Code: | |
33 | |
34 ;; Malayalam Composable Pattern | |
35 ;; C .. Consonants | |
36 ;; V .. Vowel | |
37 ;; H .. Halant | |
38 ;; M .. Matra | |
39 ;; V .. Vowel | |
40 ;; A .. Anuswar | |
41 ;; D .. Chandrabindu | |
42 ;; (N .. Zerowidth Non Joiner) | |
43 ;; (J .. Zerowidth Joiner. ) | |
44 ;; 1. vowel | |
45 ;; V(A|visargam)? | |
46 ;; 2. syllable : maximum of 5 consecutive consonants. (e.g. kartsnya) | |
47 ;; ((CH)?(CH)?(CH)?CH)?C(H|M?(A|D)?)? | |
48 | |
49 (defconst malayalam-consonant | |
50 "[$,1@5(B-$,1@Y(B]") | |
51 | |
52 (defconst malayalam-composable-pattern | |
53 (concat | |
54 "\\([$,1@%(B-$,1@4(B][$,1@"(B]?\\)\\|$,1@#(B" | |
55 "\\|\\(" | |
56 "\\(?:\\(?:[$,1@5(B-$,1@Y(B]$,1@m(B\\)?\\(?:[$,1@5(B-$,1@Y(B]$,1@m(B\\)?\\(?:[$,1@5(B-$,1@Y(B]$,1@m(B\\)?[$,1@5(B-$,1@Y(B]$,1@m(B\\)?" | |
57 "[$,1@5(B-$,1@Y(B]\\(?:$,1@m(B\\|[$,1@^(B-$,1@c@f@g@h@j@j@k@l(B]?[$,1@"@m(B]?\\)?" | |
58 "\\)") | |
59 "Regexp matching a composable sequence of Malayalam characters.") | |
60 | |
61 ;;;###autoload | |
62 (defun malayalam-compose-region (from to) | |
63 (interactive "r") | |
64 (save-excursion | |
65 (save-restriction | |
66 (narrow-to-region from to) | |
67 (goto-char (point-min)) | |
68 (while (re-search-forward malayalam-composable-pattern nil t) | |
69 (malayalam-compose-syllable-region (match-beginning 0) | |
70 (match-end 0)))))) | |
71 (defun malayalam-compose-string (string) | |
72 (with-temp-buffer | |
73 (insert (decompose-string string)) | |
74 (malayalam-compose-region (point-min) (point-max)) | |
75 (buffer-string))) | |
76 | |
52518
88807cd5407c
(malayalam-post-read-conversion): Add autoload cookie.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
77 ;;;###autoload |
49702 | 78 (defun malayalam-post-read-conversion (len) |
79 (save-excursion | |
80 (save-restriction | |
81 (let ((buffer-modified-p (buffer-modified-p))) | |
82 (narrow-to-region (point) (+ (point) len)) | |
83 (malayalam-compose-region (point-min) (point-max)) | |
84 (set-buffer-modified-p buffer-modified-p) | |
85 (- (point-max) (point-min)))))) | |
86 | |
87 (defun malayalam-range (from to) | |
88 "Make the list of the integers of range FROM to TO." | |
89 (let (result) | |
90 (while (<= from to) (setq result (cons to result) to (1- to))) result)) | |
91 | |
92 (defun malayalam-regexp-of-hashtbl-keys (hashtbl) | |
93 "Return a regular expression that matches all keys in hashtable HASHTBL." | |
94 (let ((max-specpdl-size 1000)) | |
95 (regexp-opt | |
96 (sort | |
97 (let (dummy) | |
98 (maphash (function (lambda (key val) (setq dummy (cons key dummy)))) hashtbl) | |
99 dummy) | |
100 (function (lambda (x y) (> (length x) (length y)))))))) | |
101 | |
102 | |
103 ;;;###autoload | |
89483 | 104 (defun malayalam-composition-function (pos &optional string) |
105 "Compose Malayalam characters after the position POS. | |
106 If STRING is not nil, it is a string, and POS is an index to the string. | |
107 In this case, compose characters after POS of the string." | |
108 (if string | |
109 ;; Not yet implemented. | |
110 nil | |
111 (goto-char pos) | |
112 (if (looking-at malayalam-composable-pattern) | |
113 (prog1 (match-end 0) | |
114 (malayalam-compose-syllable-region pos (match-end 0)))))) | |
49702 | 115 |
116 ;; Notes on conversion steps. | |
117 | |
118 ;; 1. chars to glyphs | |
119 ;; | |
120 ;; Simple replacement of characters to glyphs is done. | |
121 | |
122 ;; 2. glyphs reordering. | |
123 ;; | |
124 ;; Two special reordering rule takes place. | |
125 ;; a. following "$,46[(B" goes to the front. | |
126 ;; b. following "$,46S6S(B", "$,46S(B" or "$,46T(B" goes to the front. | |
127 ;; This reordering occurs only to the last cluster of consonants. | |
128 ;; Preceding consonants with halant characters are not affected. | |
129 | |
130 ;; 3. Composition. | |
131 ;; | |
132 ;; left modifiers will be attached at the left. | |
133 ;; others will be attached right. | |
134 | |
135 (defvar mlm-char-glyph | |
136 '(;; various signs | |
137 ("$,1@"(B" . "$,46W(B") | |
138 ("$,1@#(B" . "$,46X(B") | |
139 ;; Independent Vowels | |
140 ("$,1@%(B" . "$,46!(B") | |
141 ("$,1@&(B" . "$,46"(B") | |
142 ("$,1@'(B" . "$,46#(B") | |
143 ("$,1@((B" . "$,46#6U(B") | |
144 ("$,1@)(B" . "$,46$(B") | |
145 ("$,1@*(B" . "$,46$6U(B") | |
146 ("$,1@+(B" . "$,46%(B") | |
147 ("$,1@,(B" . "nil") ;; not in present use, not supported. | |
148 ("$,1@.(B" . "$,46&(B") | |
149 ("$,1@/(B" . "$,46'(B") | |
150 ("$,1@0(B" . "$,46S6&(B") | |
151 ("$,1@2(B" . "$,46((B") | |
152 ("$,1@3(B" . "$,46(6M(B") | |
153 ("$,1@4(B" . "$,46(6U(B") | |
154 ;; Consonants | |
155 ("$,1@5(B" . "$,46)(B") | |
156 ("$,1@5@m@5(B" . "$,47!(B") | |
49955
15e3ed34db0a
(mlm-char-glyph): Fix several composing rules.
Kenichi Handa <handa@m17n.org>
parents:
49943
diff
changeset
|
157 ("$,1@5@m@S(B" . "$,47"(B") |
49702 | 158 ("$,1@5@m@W(B" . "$,47#(B") |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
159 ("$,1@5@m@?(B" . "$,47N(B") |
49702 | 160 ("$,1@5@m@D(B" . "$,47`(B") |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
161 ("$,1@5@a(B" . "$,47f(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
162 ("$,1@5@m@5@a(B" . "$,47g(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
163 ("$,1@5@a(B" . "$,47f(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
164 ("$,1@5@m@5@a(B" . "$,47g(B") |
49702 | 165 |
166 ("$,1@6(B" . "$,46*(B") | |
167 | |
168 ("$,1@7(B" . "$,46+(B") | |
169 ("$,1@7@m@7(B" . "$,47$(B") | |
170 ("$,1@7@m@R(B" . "$,47%(B") | |
171 ("$,1@7@m@N(B" . "$,47\(B") | |
172 ("$,1@7@m@H(B" . "$,47a(B") | |
173 | |
174 ("$,1@8(B" . "$,46,(B") | |
175 | |
176 ("$,1@9(B" . "$,46-(B") | |
177 ("$,1@9@m@5(B" . "$,47&(B") | |
178 ("$,1@9@m@9(B" . "$,47'(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
179 ("$,1@9@m@5@a(B" . "$,47h(B") |
49702 | 180 |
181 ("$,1@:(B" . "$,46.(B") | |
182 ("$,1@:@m@:(B" . "$,47((B") ;; duplicate | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
183 ("$,1@:@m@;(B" . "$,47Q(B") |
49702 | 184 |
185 ("$,1@;(B" . "$,46/(B") | |
186 | |
187 ("$,1@<(B" . "$,460(B") | |
188 ("$,1@<@m@<(B" . "$,47V(B") | |
189 ("$,1@<@m@>(B" . "$,47Z(B") | |
190 | |
191 ("$,1@=(B" . "$,461(B") | |
192 | |
193 ("$,1@>(B" . "$,462(B") | |
194 ("$,1@>@m@:(B" . "$,47)(B") | |
195 ("$,1@>@m@>(B" . "$,47*(B") | |
196 | |
197 ("$,1@?(B" . "$,463(B") | |
198 ("$,1@?@m@?(B" . "$,47+(B") | |
199 | |
200 ("$,1@@(B" . "$,464(B") | |
201 ("$,1@A(B" . "$,465(B") | |
202 ("$,1@A@m@A(B" . "$,47M(B") | |
203 ("$,1@B(B" . "$,466(B") | |
204 | |
205 ("$,1@C(B" . "$,467(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
206 ("$,1@C@a@m(B" . "$,47,(B") ;; half consonant |
49702 | 207 ("$,1@C@m@?(B" . "$,47-(B") |
208 ("$,1@C@m@C(B" . "$,47.(B") | |
209 ("$,1@C@m@N(B" . "$,47W(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
210 ("$,1@C@m@A(B" . "$,47^(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
211 ("$,1@C@a(B" . "$,47i(B") |
49702 | 212 |
213 ("$,1@D(B" . "$,468(B") | |
214 ("$,1@D@m@D(B" . "$,47/(B") | |
215 ("$,1@D@m@E(B" . "$,470(B") | |
216 ("$,1@D@m@X(B" . "$,47U(B") | |
217 ("$,1@D@m@M(B" . "$,47[(B") | |
218 ("$,1@D@m@N(B" . "$,47_(B") | |
219 | |
220 ("$,1@E(B" . "$,469(B") | |
221 | |
222 ("$,1@F(B" . "$,46:(B") | |
223 ("$,1@F@m@F(B" . "$,471(B") | |
224 ("$,1@F@m@G(B" . "$,472(B") | |
225 | |
226 ("$,1@G(B" . "$,46;(B") | |
227 | |
228 ("$,1@H(B" . "$,46<(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
229 ("$,1@H@a@m(B" . "$,473(B") ;; half consonant |
49702 | 230 ("$,1@H@m@D(B" . "$,474(B") |
231 ("$,1@H@m@F(B" . "$,475(B") | |
232 ("$,1@H@m@H(B" . "$,476(B") | |
233 ("$,1@H@m@N(B" . "$,477(B") | |
234 ("$,1@H@m@G(B" . "$,47T(B") | |
235 ("$,1@H@m@E(B" . "$,47Y(B") | |
236 ("$,1@H@m@Q(B" . "$,47b(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
237 ("$,1@H@a(B" . "$,47k(B") |
68019
b9546af7814e
Delete spurious trailing whitespaces.
Kenichi Handa <handa@m17n.org>
parents:
64085
diff
changeset
|
238 ("$,1@H@m@H@a(B" . "$,47l(B") |
49702 | 239 |
240 ("$,1@J(B" . "$,46=(B") | |
241 ("$,1@J@m@J(B" . "$,478(B") ;; duplicate | |
242 ("$,1@J@m@R(B" . "$,479(B") ;; lakar | |
243 | |
244 ("$,1@K(B" . "$,46>(B") | |
245 | |
246 ("$,1@L(B" . "$,46?(B") | |
247 ("$,1@L@m@L(B" . "$,47:(B") ;; duplicate | |
248 ("$,1@L@m@R(B" . "$,47;(B") ;; lakar | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
249 ("$,1@L@m@G(B" . "$,47O(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
250 ("$,1@L@m@F(B" . "$,47P(B") |
49702 | 251 |
252 ("$,1@M(B" . "$,46@(B") | |
253 | |
254 ("$,1@N(B" . "$,46A(B") | |
255 ("$,1@N@m@J(B" . "$,47<(B") | |
256 ("$,1@N@m@N(B" . "$,47=(B") | |
257 ("$,1@N@m@R(B" . "$,47>(B") ;; lakar | |
258 | |
259 ("$,1@O(B" . "$,46B(B") | |
260 ("$,1@O@m@O(B" . "$,47?(B") ;; duplicate | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
261 ("$,1@O@m@5@m@5(B" . "$,47m(B") |
49702 | 262 |
263 ("$,1@P(B" . "$,46C(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
264 ("$,1@P@a@m(B" . "$,47@(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
265 ("$,1@P@a(B" . "$,47j(B") |
49702 | 266 |
267 ("$,1@Q(B" . "$,46D(B") | |
268 ("$,1@Q@m(B" . "$,47@(B") ;; same glyph as "$,1@P@m(B" | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
269 ("$,1@Q@a@m(B" . "$,47@(B") ;; same glyph as "$,1@P@m(B" |
49702 | 270 ;;("$,1@Q@m@Q(B" . "$,47A(B") |
271 ("$,1@Q@m@Q(B" . "$,47d(B") | |
272 | |
273 ("$,1@R(B" . "$,46E(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
274 ("$,1@R@a@m(B" . "$,47B(B") |
49702 | 275 ("$,1@R@m@R(B" . "$,47C(B") ;; lakar |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
276 ("$,1@R@m@J(B" . "$,47e(B") |
49702 | 277 |
278 ("$,1@S(B" . "$,46F(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
279 ("$,1@S@a@m(B" . "$,47D(B") |
49702 | 280 ("$,1@S@m@S(B" . "$,47E(B") |
281 | |
282 ("$,1@T(B" . "$,46G(B") | |
283 | |
284 ("$,1@U(B" . "$,46H(B") | |
285 ("$,1@U@m@U(B" . "$,47F(B") | |
286 | |
287 ("$,1@V(B" . "$,46I(B") | |
288 ("$,1@V@m@R(B" . "$,47G(B") | |
289 ("$,1@V@m@V(B" . "$,47H(B") | |
290 ("$,1@V@m@:(B" . "$,47](B") | |
291 | |
292 ("$,1@W(B" . "$,46J(B") | |
293 ("$,1@W@m@?(B" . "$,47c(B") | |
294 | |
295 ("$,1@X(B" . "$,46K(B") | |
296 ("$,1@X@m@R(B" . "$,47I(B") | |
297 ("$,1@X@m@X(B" . "$,47J(B") | |
298 ("$,1@X@m@Q@m@Q(B" . "$,47L(B") | |
299 ("$,1@X@m@E(B" . "$,47X(B") | |
300 | |
301 ("$,1@Y(B" . "$,46L(B") | |
302 ("$,1@Y@m@R(B" . "$,47K(B") | |
303 ("$,1@Y@m@N(B" . "$,47R(B") | |
304 ("$,1@Y@m@H(B" . "$,47S(B") | |
305 | |
306 ;; Dependent vowel signs | |
307 ("$,1@^(B" . "$,46M(B") | |
308 ("$,1@_(B" . "$,46N(B") | |
309 ("$,1@`(B" . "$,46O(B") | |
310 ("$,1@a(B" . "$,46P(B") | |
311 ("$,1@b(B" . "$,46Q(B") | |
312 ("$,1@c(B" . "$,46R(B") | |
313 ("$,1@f(B" . "$,46S(B") | |
314 ("$,1@g(B" . "$,46T(B") | |
315 ("$,1@h(B" . "$,46S6S(B") | |
316 ("$,1@j(B" . "$,46S6M(B") | |
317 ("$,1@k(B" . "$,46T6M(B") | |
318 ("$,1@l(B" . "$,46U(B") | |
319 ;; Various signs | |
320 ("$,1@m(B" . "$,46V(B") | |
321 ("$,1@m@O(B" . "$,46Y(B") ;; yakar | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
322 ("$,1@m@O@a(B" . "$,46\(B") ;; yakar + u |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
323 ("$,1@m@O@b(B" . "$,46](B") ;; yakar + uu |
49702 | 324 ("$,1@m@U(B" . "$,46Z(B") ;; vakar modifier |
325 ("$,1@m@P(B" . "$,46[(B") ;; rakar modifier is the same to rra modifier. | |
49943
f70ce138a267
(mlm-char-glyph): Add entries for "halant +
Kenichi Handa <handa@m17n.org>
parents:
49702
diff
changeset
|
326 ("$,1@m@P@m(B" . "$,46R(B") ;; halant + rakar + halant |
49702 | 327 ("$,1@m@Q(B" . "$,46[(B") ;; rrakar modifier |
49943
f70ce138a267
(mlm-char-glyph): Add entries for "halant +
Kenichi Handa <handa@m17n.org>
parents:
49702
diff
changeset
|
328 ("$,1@m@Q@m(B" . "$,46R(B") ;; halant + rrakar + halant |
49702 | 329 ("$,1@m@m(B" . "$,46V(B") ;; double omission sign to stop forming half consonant. |
330 ("$,1@w(B" . "$,46U(B") ;; not in present use, already at 0D4C. | |
331 )) | |
332 | |
333 (defvar mlm-char-glyph-hash | |
334 (let* ((hash (make-hash-table :test 'equal))) | |
335 (mapc (function (lambda (x) (puthash (car x) (cdr x) hash))) | |
336 mlm-char-glyph) | |
337 hash)) | |
338 | |
339 (defvar mlm-char-glyph-regexp | |
340 (malayalam-regexp-of-hashtbl-keys mlm-char-glyph-hash)) | |
341 | |
342 ;; Malayalam languages needed to be reordered in a complex mannar. | |
343 | |
344 (defvar mlm-consonants | |
345 (concat | |
346 "$,46)6*6+6,6-6.6/606162636465666768696:6;6<6=6>6?6@6A6B6C6D6E6F6G6H6I6J6K6L(B" | |
347 "$,47!7"7#7$7%7&7'7(7)7*7+7,7-7.7/707172737475767778797:7;7<7=7>7?7@7A7B7C7D7E7F7G7H7I7J7K7L7M7N7O7P7Q7R7S7T7U7V7W7X7Y7Z7[7\7]7^7_7`7a7b7c7d7e(B" | |
348 )) | |
349 | |
350 (defvar mlm-consonants-regexp | |
351 (concat "\\($,46[(B?[" mlm-consonants "][$,46Y6Z(B]?\\)")) | |
352 | |
353 (defvar mlm-glyph-reorder-key-glyphs "[$,46[6S6T(B]") | |
354 | |
355 (defvar mlm-glyph-reordering-regexp-list | |
356 `((,(concat "\\([" mlm-consonants "][$,46Y6Z(B]?\\)$,46[(B") . "$,46[(B\\1") | |
357 (,(concat mlm-consonants-regexp "$,46S6S(B") . "$,46S6S(B\\1") | |
358 (,(concat mlm-consonants-regexp "$,46S(B") . "$,46S(B\\1") | |
359 (,(concat mlm-consonants-regexp "$,46T(B") . "$,46T(B\\1"))) | |
360 | |
361 (defun malayalam-compose-syllable-string (string) | |
362 (with-temp-buffer | |
363 (insert (decompose-string string)) | |
364 (malayalam-compose-syllable-region (point-min) (point-max)) | |
365 (buffer-string))) | |
366 | |
367 (defun malayalam-compose-syllable-region (from to) | |
368 "Compose malayalam syllable in region FROM to TO." | |
369 (let (glyph-str | |
370 match-str | |
371 glyph-reorder-regexps | |
372 glyph-reorder-replace | |
373 glyph-reorder-regexp) | |
374 (save-excursion | |
375 (save-restriction | |
376 (narrow-to-region from to) | |
377 (goto-char (point-min)) | |
378 ;; char-glyph-conversion | |
89483 | 379 (while (not (eobp)) |
380 (if (looking-at mlm-char-glyph-regexp) | |
381 (progn | |
382 (setq match-str (match-string 0) | |
383 glyph-str | |
384 (concat glyph-str | |
385 (gethash match-str mlm-char-glyph-hash))) | |
386 (goto-char (match-end 0))) | |
387 (setq glyph-str (concat glyph-str (string (following-char)))) | |
388 (forward-char 1))) | |
49702 | 389 (when (string-match mlm-glyph-reorder-key-glyphs glyph-str) |
390 ;; glyph reordering | |
391 (setq glyph-reorder-regexps mlm-glyph-reordering-regexp-list) | |
392 (while glyph-reorder-regexps | |
393 (setq glyph-reorder-regexp (caar glyph-reorder-regexps)) | |
394 (setq glyph-reorder-replace (cdar glyph-reorder-regexps)) | |
395 (setq glyph-reorder-regexps (cdr glyph-reorder-regexps)) | |
396 (if (string-match glyph-reorder-regexp glyph-str) | |
397 (setq glyph-str | |
398 (replace-match glyph-reorder-replace nil nil | |
399 glyph-str))))) | |
400 ;; concatenate and attach reference-points. | |
401 (setq glyph-str | |
402 (cdr | |
403 (apply | |
404 'nconc | |
405 (mapcar | |
68019
b9546af7814e
Delete spurious trailing whitespaces.
Kenichi Handa <handa@m17n.org>
parents:
64085
diff
changeset
|
406 (function |
49702 | 407 (lambda (x) (list '(5 . 3) x))) ;; default ref. point. |
408 glyph-str)))) | |
409 (compose-region from to glyph-str))))) | |
410 | |
411 (provide 'mlm-util) | |
412 | |
52401 | 413 ;;; arch-tag: 7f25ee67-8f9d-49f2-837b-35c412c00eba |
49702 | 414 ;;; devan-util.el ends here |