Mercurial > hg > xemacs-beta
annotate lisp/mule/indian.el @ 5474:4dee0387b9de
Merged with trunk.
author | Mats Lidell <matsl@xemacs.org> |
---|---|
date | Tue, 29 Mar 2011 00:02:47 +0200 |
parents | 308d34e9f07d 3889ef128488 |
children |
rev | line source |
---|---|
778 | 1 ;;; indian.el --- support for Indian Languages -*- coding: iso-2022-7bit; -*- |
771 | 2 |
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: KAWABATA, Taichi <kawabata@is.s.u-tokyo.ac.jp> | |
6 | |
7 ;; Keywords: multilingual, Indian | |
8 | |
9 ;; This file is part of XEmacs. | |
10 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3659
diff
changeset
|
11 ;; XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3659
diff
changeset
|
12 ;; under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3659
diff
changeset
|
13 ;; Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3659
diff
changeset
|
14 ;; option) any later version. |
771 | 15 |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3659
diff
changeset
|
16 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3659
diff
changeset
|
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3659
diff
changeset
|
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3659
diff
changeset
|
19 ;; for more details. |
771 | 20 |
21 ;; You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
3659
diff
changeset
|
22 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
771 | 23 |
778 | 24 ;;; Synched up with: Emacs 21.1 (language/indian.el). |
771 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; History: | |
29 ;; 1996.10.18 written by KAWABATA, Taichi <kawabata@is.s.u-tokyo.ac.jp> | |
30 | |
31 ;; For Indian, the character set IS 13194 is supported. | |
32 ;; | |
33 ;; IS 13194 does not specifically assign glyphs for each characters. | |
34 ;; Following code is not specific to each Indian language. | |
35 ;; | |
36 ;; Eventually, this code will support generic information about | |
37 ;; following scripts. | |
38 ;; | |
39 ;; Devanagari | |
40 ;; Bengali | |
41 ;; Gurmukhi | |
42 ;; Gujarati | |
43 ;; Oriya | |
44 ;; Tamil | |
45 ;; Telgu | |
46 ;; Kannada | |
47 ;; Malayalam | |
48 ;; | |
49 ;; In this file, charsets other than charset-ascii and charset-indian-is13194 | |
50 ;; should not be used except in the comment. | |
51 | |
52 ;;; Code: | |
53 | |
5384
3889ef128488
Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents:
3659
diff
changeset
|
54 ;; Following are what you see when you refer to the Emacs |
771 | 55 ;; representations of IS 13194 charcters. However, this is merely |
5384
3889ef128488
Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents:
3659
diff
changeset
|
56 ;; tentative appearance, and you must convert them with the |
771 | 57 ;; indian-to-xxxxxx(specific script) function to use them. |
58 ;; Devanagari is not an exception of this rule. | |
59 | |
60 ;; 0xa0 //(5!"#$%&'()*+,-./(B | |
61 ;; 0xb0 (50123456789:;<=>?(B | |
62 ;; 0xc0 (5@ABCDEFGHIJKLMNO(B | |
63 ;; 0xd0 (5PQRSTUVWXYZ[\]^_(B | |
64 ;; 0xe0 (5`abcdefghijklmno(B | |
65 ;; 0xf0 (5pqrstuvwxyz{|}~(B// | |
66 | |
67 ;; Note - In IS 13194, several symbols are obtained by special | |
68 ;; combination of several characters and Nukta sign. | |
69 ;; | |
70 ;; Sanskrit Vowel R -> (5*(B + (5i(B | |
71 ;; Sanskrit Vowel L -> (5&(B + (5i(B | |
72 ;; Sanskrit Vowel LL -> (5'(B + (5i(B | |
73 ;; Sanskrit Avagrah -> (5j(B + (5i(B | |
74 ;; OM -> (5!(B + (5i(B | |
75 ;; | |
76 ;; Note - IS 13194 defines ATR(0xEF) and EXT(0xF0), but they are | |
77 ;; not used in Emacs. | |
78 ;; | |
79 ;; Note - the above characters DO NOT represent any script. For | |
80 ;; example, if you want to obtain Devanagari character, you must do | |
81 ;; something like the following. | |
82 ;; | |
83 ;; (char-to-string (indian-to-devanagari ?(5$(B)) | |
84 ;; "$(5!$(B" | |
85 | |
86 ;;; ITRANS | |
87 ;; | |
88 ;; ITRANS is one of the most popular method to exchange indian scripts | |
89 ;; electronically. Here is the table to convert between ITRANS code and | |
90 ;; IS 13194 code. | |
91 | |
778 | 92 ;; Indian scripts. Symbolic charset for data exchange. Glyphs are |
93 ;; not assigned. They are automatically converted to each Indian | |
94 ;; script which IS-13194 supports. | |
95 | |
96 (make-charset 'indian-is13194 | |
97 "Generic Indian charset for data exchange with IS 13194" | |
98 '(dimension | |
99 1 | |
3659 | 100 registries ["IS13194-Devanagari"] |
778 | 101 chars 94 |
102 columns 2 | |
103 direction l2r | |
104 final ?5 | |
105 graphic 1 | |
106 short-name "IS 13194" | |
107 long-name "Indian IS 13194" | |
108 )) | |
109 | |
110 ;; Actual Glyph for 1-column width. | |
111 (make-charset 'indian-1-column | |
112 "Indian charset for 2-column width glyphs" | |
113 '(dimension | |
114 2 | |
3659 | 115 registries ["MuleIndian-1"] |
778 | 116 chars 94 |
117 columns 1 | |
118 direction l2r | |
119 final ?6 | |
120 graphic 0 | |
121 short-name "Indian 1-col" | |
122 long-name "Indian 1 Column" | |
123 )) | |
124 | |
125 ;; Actual Glyph for 2-column width. | |
126 (make-charset 'indian-2-column | |
127 "Indian charset for 2-column width glyphs" | |
128 '(dimension | |
129 2 | |
3659 | 130 registries ["MuleIndian-2"] |
778 | 131 chars 94 |
132 columns 2 | |
133 direction l2r | |
134 final ?5 | |
135 graphic 0 | |
136 short-name "Indian 2-col" | |
137 long-name "Indian 2 Column" | |
138 )) | |
139 | |
771 | 140 (defvar indian-itrans-consonant-alist |
141 '( | |
142 ("k" . "(53(B") | |
143 ("kh" . "(54(B") | |
144 ("g" . "(55(B") | |
145 ("gh" . "(56(B") | |
146 ("N^" . "(57(B") | |
147 ("ch" . "(58(B") | |
148 ("chh" . "(59(B") | |
149 ("j" . "(5:(B") | |
150 ("jh" . "(5;(B") | |
151 ("JN" . "(5<(B") | |
152 ("T" . "(5=(B") | |
153 ("Th" . "(5>(B") | |
154 ("D" . "(5?(B") | |
155 ("Dh" . "(5@(B") | |
156 ("N" . "(5A(B") | |
157 ("t" . "(5B(B") | |
158 ("th" . "(5C(B") | |
159 ("d" . "(5D(B") | |
160 ("dh" . "(5E(B") | |
161 ("n" . "(5F(B") | |
162 ("nh" . "(5G(B") ; For transcription of non-Devanagari Languages. | |
163 ("p" . "(5H(B") | |
164 ("ph" . "(5I(B") | |
165 ("b" . "(5J(B") | |
166 ("bh" . "(5K(B") | |
167 ("m" . "(5L(B") | |
168 ("y" . "(5M(B") | |
169 ("yh" . "(5N(B") ; For transcription of non-Devanagari Languages. | |
170 ("r" . "(5O(B") | |
171 ("rh" . "(5P(B") ; For transcription of non-Devanagari Languages. | |
172 ("l" . "(5Q(B") | |
173 ("v" . "(5T(B") | |
174 ("sh" . "(5U(B") | |
175 ("shh" . "(5V(B") | |
176 ("s" . "(5W(B") | |
177 ("h" . "(5X(B") | |
178 ("ld" . "(5R(B") | |
179 ("L" . "(5R(B") | |
180 ("ksh" . "$(5!3!h!V(B") | |
181 ("GY" . "***GY***") ; Must check out later. | |
182 ;; special consonants | |
183 ("q" . "(53i(B") | |
184 ("K" . "(54i(B") | |
185 ("G" . "(55i(B") | |
186 ("z" . "(5:i(B") | |
187 ("f" . "(5Ii(B") | |
188 (".D" . "(5?i(B") | |
189 (".Dh" . "(5@i(B") | |
190 )) | |
191 | |
192 (defvar indian-itrans-vowel-sign-alist | |
193 '( | |
194 ;; Special treatment unique to IS 13194 Transliteration | |
195 ("" . "(5h(B") | |
196 ("a" . "") | |
197 ;; Matra (Vowel Sign) | |
198 ("aa" . "(5Z(B") | |
199 ("A" . "(5Z(B") | |
200 ("i" . "(5[(B") | |
201 ("ii" . "(5\(B") | |
202 ("I" . "(5\(B") | |
203 ("u" . "(5](B") | |
204 ("uu" . "(5^(B") | |
205 ("U" . "(5^(B") | |
206 ("R^i" . "(5_(B") ; These must be checked out later. | |
207 ("R^I" . "(5_i(B") | |
208 ("L^i" . "(5[i(B") | |
209 ("L^I" . "(5\i(B") | |
210 ("E" . "(5`(B") ; For transcription of non-Devanangri Languages. | |
211 ("e" . "(5a(B") | |
212 ("ai" . "(5b(B") | |
213 ;; ("e.c" . "(5c(B") ; Tentatively suppressed. | |
214 ("O" . "(5d(B") ; For transcription of non-Devanagari Languages. | |
215 ("o" . "(5e(B") | |
216 ("au" . "(5f(B") | |
217 ;; ("o.c" . "(5g(B") ; Tentatively suppressed. | |
218 )) | |
219 | |
220 ;; | |
221 ;; Independent vowels and other signs. | |
222 ;; | |
223 | |
224 (defvar indian-itrans-other-letters-alist | |
225 '( | |
226 ("a" . "(5$(B") | |
227 ("aa" . "(5%(B") | |
228 ("A" . "(5%(B") | |
229 ("i" . "(5&(B") | |
230 ("ii" . "(5'(B") | |
231 ("I" . "(5'(B") | |
232 ("u" . "(5((B") | |
233 ("uu" . "(5)(B") | |
234 ("U" . "(5)(B") | |
235 ("R^i" . "(5*(B") | |
236 ("R^I" . "(5*i(B") | |
237 ("L^i" . "(5&i(B") | |
238 ("L^I" . "(5'i(B") | |
239 ("E" . "(5+(B") ; For transcription of non-Devanagari Languages. | |
240 ("e" . "(5,(B") | |
241 ("ai" . "(5-(B") | |
242 ;; ("e.c" . "(5.(B") ; Candra E | |
243 ("O" . "(5/(B") ; For transcription of non-Devanagari Languages. | |
244 ("o" . "(50(B") | |
245 ("au" . "(51(B") | |
246 ;; ("o.c" . "(52(B") ; Candra O | |
247 ("M" . "(5$(B") | |
248 ("H" . "(5#(B") | |
249 ("AUM" . "(5!i(B") | |
250 ("OM" . "(5!i(B") | |
251 (".r" . "(5Oh(B") | |
252 (".n" . "(5"(B") | |
253 (".N" . "(5!(B") | |
254 (".h" . "(5h(B") ; Halant | |
255 (".." . "(5j(B") | |
256 (".a" . "(5ji(B") ; Avagrah | |
257 ("0" . "(5q(B") | |
258 ("1" . "(5r(B") | |
259 ("2" . "(5s(B") | |
260 ("3" . "(5t(B") | |
261 ("4" . "(5u(B") | |
262 ("5" . "(5v(B") | |
263 ("6" . "(5w(B") | |
264 ("7" . "(5x(B") | |
265 ("8" . "(5y(B") | |
266 ("9" . "(5z(B") | |
267 )) | |
268 | |
269 ;; Regular expression matching single Indian character represented | |
270 ;; by ITRANS. | |
271 | |
272 (defvar indian-itrans-regexp | |
273 (let ((consonant "\\([cs]hh?\\)\\|[kgjTDnpbyr]h?\\|\\(N\\^?\\)\\|\\(jN\\)\\|[mvqKGzfs]\\|\\(ld?\\)\\|\\(ksh\\)\\|\\(GY\\)\\|\\(\\.Dh?\\)") | |
274 (vowel "\\(a[aiu]\\)\\|\\(ii\\)\\|\\(uu\\)\\|\\([RL]\\^[iI]\\)\\|[AIEOeoaiu]") | |
275 (misc "[MH0-9]\\|\\(AUM\\)\\|\\(OM\\)\\|\\(\\.[rnNh\\.a]\\)") | |
276 (lpre "\\(") (rpre "\\)") (orre "\\|")) | |
277 (concat lpre misc rpre orre | |
278 lpre lpre consonant rpre "?" lpre vowel rpre rpre orre | |
279 lpre consonant rpre ))) | |
280 | |
281 ;; | |
282 ;; Regular expression matching single ITRANS unit for IS 13194 characters. | |
283 ;; | |
284 | |
285 (defvar itrans-indian-regexp | |
286 (let ((vowel "[(5$(B-(52(B]") | |
287 (consonant "[(53(B-(5X(B]") | |
288 (matra "[(5Z(B-(5g(B]") | |
289 (misc "[(5q(B-(5z(B]") | |
290 (lpre "\\(") (rpre "\\)") (orre "\\|")) | |
291 (concat misc orre | |
292 lpre consonant matra "?" rpre orre | |
293 vowel))) | |
294 | |
295 ;; | |
296 ;; IS13194 - ITRANS conversion table for string matching above regexp. | |
297 ;; | |
298 | |
299 (defvar indian-itrans-alist | |
300 (let ((cl indian-itrans-consonant-alist) | |
301 (ml indian-itrans-other-letters-alist) rules) | |
302 (while cl | |
303 (let ((vl indian-itrans-vowel-sign-alist)) | |
304 (while vl | |
305 (setq rules | |
306 (cons (cons (concat (car (car cl)) (car (car vl))) | |
307 (concat (cdr (car cl)) (cdr (car vl)))) | |
308 rules)) | |
309 (setq vl (cdr vl)))) | |
310 (setq cl (cdr cl))) | |
311 (while ml | |
312 (setq rules (cons (cons (car (car ml)) | |
313 (cdr (car ml))) | |
314 rules)) | |
315 (setq ml (cdr ml))) | |
316 rules)) | |
317 | |
318 ;; | |
319 ;; Utility program to convert from ITRANS to IS 13194 in specified region. | |
320 ;; | |
321 | |
322 (defun indian-decode-itrans-region (from to) | |
323 "Convert `ITRANS' mnemonics of the current region to Indian characters. | |
324 When called from a program, expects two arguments, | |
325 positions (integers or markers) specifying the stretch of the region." | |
326 (interactive "r") | |
327 (save-restriction | |
328 (narrow-to-region from to) | |
329 (goto-char (point-min)) | |
330 (while (re-search-forward indian-itrans-regexp nil t) | |
331 (let* ((itrans (buffer-substring (match-beginning 0) (match-end 0))) | |
332 (ch (cdr (assoc itrans indian-itrans-alist)))) | |
333 (if ch | |
334 (progn | |
335 (delete-region (match-beginning 0) (match-end 0)) | |
336 (insert ch))))) | |
337 (goto-char (point-min)) | |
338 (while (re-search-forward "\\((5h(B\\)[^\\c0]" nil t) | |
339 (delete-region (match-beginning 1) (match-end 1))))) | |
340 | |
341 ;; | |
342 ;; Utility program to convert from IS 13194 to ITRANS in specified region. | |
343 ;; | |
344 | |
345 (defun indian-encode-itrans-region (from to) | |
346 "Convert indian region to ITRANS mnemonics." | |
347 (interactive "r") | |
348 (save-restriction | |
349 (narrow-to-region from to) | |
350 (goto-char (point-min)) | |
351 (while (re-search-forward itrans-indian-regexp nil t) | |
352 (let* ((indian (buffer-substring (match-beginning 0) (match-end 0))) | |
353 (ch (car (rassoc indian indian-itrans-alist)))) | |
354 (if ch | |
355 (progn | |
356 (delete-region (match-beginning 0) (match-end 0)) | |
357 (insert ch))))) | |
358 (goto-char (point-min)))) | |
359 | |
360 (provide 'indian) | |
361 | |
362 ;;; indian.el ends here |