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