Mercurial > emacs
annotate lisp/language/indian.el @ 20211:f722b33c682d
automatically generated from GPLed version
author | Ulrich Drepper <drepper@redhat.com> |
---|---|
date | Tue, 04 Nov 1997 03:28:47 +0000 |
parents | 9503ed5384c5 |
children | 7918e0f37c7c |
rev | line source |
---|---|
17052 | 1 ;;; indian.el --- Support for Indian Languages |
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 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 | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
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 | |
17314
f438ebf1c679
Fix FSF address in comment.
Kenichi Handa <handa@m17n.org>
parents:
17300
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
f438ebf1c679
Fix FSF address in comment.
Kenichi Handa <handa@m17n.org>
parents:
17300
diff
changeset
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
f438ebf1c679
Fix FSF address in comment.
Kenichi Handa <handa@m17n.org>
parents:
17300
diff
changeset
|
24 ;; Boston, MA 02111-1307, USA. |
17052 | 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 | |
18153
c68a9d56c2c2
(describe-indian-environment-map):
Richard M. Stallman <rms@gnu.org>
parents:
17993
diff
changeset
|
54 (define-prefix-command 'describe-indian-environment-map) |
c68a9d56c2c2
(describe-indian-environment-map):
Richard M. Stallman <rms@gnu.org>
parents:
17993
diff
changeset
|
55 (define-key-after describe-language-environment-map [Indian] |
c68a9d56c2c2
(describe-indian-environment-map):
Richard M. Stallman <rms@gnu.org>
parents:
17993
diff
changeset
|
56 '("Indian" . describe-indian-environment-map) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17841
diff
changeset
|
57 t) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17841
diff
changeset
|
58 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17841
diff
changeset
|
59 (define-prefix-command 'setup-indian-environment-map) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17841
diff
changeset
|
60 (define-key-after setup-language-environment-map [Indian] |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17841
diff
changeset
|
61 '("Indian" . setup-indian-environment-map) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17841
diff
changeset
|
62 t) |
17772
550afdbb31d8
Make functions setup-LANGUAGE-environment
Kenichi Handa <handa@m17n.org>
parents:
17314
diff
changeset
|
63 |
17052 | 64 ;; Followings are what you see when you refer to the Emacs |
65 ;; representations of IS 13194 charcters. However, this is merely | |
66 ;; tentative apperance, and you must convert them by | |
67 ;; indian-to-xxxxxx(specific script) function to use them. | |
68 ;; Devanagari is not an exception of this rule. | |
69 | |
70 ;; 0xa0 //(5!"#$%&'()*+,-./(B | |
71 ;; 0xb0 (50123456789:;<=>?(B | |
72 ;; 0xc0 (5@ABCDEFGHIJKLMNO(B | |
73 ;; 0xd0 (5PQRSTUVWXYZ[\]^_(B | |
74 ;; 0xe0 (5`abcdefghijklmno(B | |
75 ;; 0xf0 (5pqrstuvwxyz{|}~(B// | |
76 | |
77 ;; Note - In IS 13194, several symbols are obtained by special | |
78 ;; combination of several characters and Nukta sign. | |
79 ;; | |
80 ;; Sanskrit Vowel R -> (5*(B + (5i(B | |
81 ;; Sanskrit Vowel L -> (5&(B + (5i(B | |
82 ;; Sanskrit Vowel LL -> (5'(B + (5i(B | |
83 ;; Sanskrit Avagrah -> (5j(B + (5i(B | |
84 ;; OM -> (5!(B + (5i(B | |
85 ;; | |
86 ;; Note - IS 13194 defines ATR(0xEF) and EXT(0xF0), but they are | |
87 ;; not used in Emacs. | |
88 ;; | |
89 ;; Note - the above characters DO NOT represent any script. For | |
90 ;; example, if you want to obtain Devanagari character, you must do | |
91 ;; something like the following. | |
92 ;; | |
93 ;; (char-to-string (indian-to-devanagari ?(5$(B)) | |
94 ;; "$(5!$(B" | |
95 | |
96 (let ((deflist | |
97 '(;; chars syntax category | |
98 ("(5!"#(B" "w" ?7) ; vowel-modifying diacritical mark | |
99 ; chandrabindu, anuswar, visarga | |
18542 | 100 ("(5$(B-(52(B" "w" ?1) ; base (independent) vowel |
17052 | 101 ("(53(B-(5X(B" "w" ?0) ; consonant |
102 ("(5Z(B-(5g(B" "w" ?8) ; matra | |
103 ("(5q(B-(5z(B" "w" ?6) ; digit | |
104 )) | |
105 elm chars len syntax category to ch i) | |
106 (while deflist | |
107 (setq elm (car deflist)) | |
108 (setq chars (car elm) | |
109 len (length chars) | |
110 syntax (nth 1 elm) | |
111 category (nth 2 elm) | |
112 i 0) | |
113 (while (< i len) | |
114 (if (= (aref chars i) ?-) | |
115 (setq i (1+ i) | |
116 to (sref chars i)) | |
117 (setq ch (sref chars i) | |
118 to ch)) | |
119 (while (<= ch to) | |
120 (modify-syntax-entry ch syntax) | |
121 (modify-category-entry ch category) | |
122 (setq ch (1+ ch))) | |
123 (setq i (+ i (char-bytes to)))) | |
124 (setq deflist (cdr deflist)))) | |
125 | |
126 | |
127 ;;; ITRANS | |
128 ;; | |
129 ;; ITRANS is one of the most popular method to exchange indian scripts | |
130 ;; electronically. Here is the table to convert between ITRANS code and | |
131 ;; IS 13194 code. | |
132 | |
133 (defvar indian-itrans-consonant-alist | |
134 '( | |
135 ("k" . "(53(B") | |
136 ("kh" . "(54(B") | |
137 ("g" . "(55(B") | |
138 ("gh" . "(56(B") | |
139 ("N^" . "(57(B") | |
140 ("ch" . "(58(B") | |
141 ("chh" . "(59(B") | |
142 ("j" . "(5:(B") | |
143 ("jh" . "(5;(B") | |
144 ("JN" . "(5<(B") | |
145 ("T" . "(5=(B") | |
146 ("Th" . "(5>(B") | |
147 ("D" . "(5?(B") | |
148 ("Dh" . "(5@(B") | |
149 ("N" . "(5A(B") | |
150 ("t" . "(5B(B") | |
151 ("th" . "(5C(B") | |
152 ("d" . "(5D(B") | |
153 ("dh" . "(5E(B") | |
154 ("n" . "(5F(B") | |
155 ("nh" . "(5G(B") ; For transcription of non-Devanagari Languages. | |
156 ("p" . "(5H(B") | |
157 ("ph" . "(5I(B") | |
158 ("b" . "(5J(B") | |
159 ("bh" . "(5K(B") | |
160 ("m" . "(5L(B") | |
161 ("y" . "(5M(B") | |
162 ("yh" . "(5N(B") ; For transcription of non-Devanagari Languages. | |
163 ("r" . "(5O(B") | |
164 ("rh" . "(5P(B") ; For transcription of non-Devanagari Languages. | |
165 ("l" . "(5Q(B") | |
166 ("v" . "(5T(B") | |
167 ("sh" . "(5U(B") | |
168 ("shh" . "(5V(B") | |
169 ("s" . "(5W(B") | |
170 ("h" . "(5X(B") | |
171 ("ld" . "(5R(B") | |
172 ("L" . "(5R(B") | |
173 ("ksh" . "$(5!3!h!V(B") | |
174 ("GY" . "***GY***") ; Must check out later. | |
175 ;; special consonants | |
176 ("q" . "(53i(B") | |
177 ("K" . "(54i(B") | |
178 ("G" . "(55i(B") | |
179 ("z" . "(5:i(B") | |
180 ("f" . "(5Ii(B") | |
181 (".D" . "(5?i(B") | |
182 (".Dh" . "(5@i(B") | |
183 )) | |
184 | |
185 (defvar indian-itrans-vowel-sign-alist | |
186 '( | |
187 ;; Special treatment unique to IS 13194 Transliteration | |
188 ("" . "(5h(B") | |
189 ("a" . "") | |
190 ;; Matra (Vowel Sign) | |
191 ("aa" . "(5Z(B") | |
192 ("A" . "(5Z(B") | |
193 ("i" . "(5[(B") | |
194 ("ii" . "(5\(B") | |
195 ("I" . "(5\(B") | |
196 ("u" . "(5](B") | |
197 ("uu" . "(5^(B") | |
198 ("U" . "(5^(B") | |
199 ("R^i" . "(5_(B") ; These must be checked out later. | |
200 ("R^I" . "(5_i(B") | |
201 ("L^i" . "(5[i(B") | |
202 ("L^I" . "(5\i(B") | |
203 ("E" . "(5`(B") ; For transcription of non-Devanangri Languages. | |
204 ("e" . "(5a(B") | |
205 ("ai" . "(5b(B") | |
206 ;; ("e.c" . "(5c(B") ; Tentatively suppressed. | |
207 ("O" . "(5d(B") ; For transcription of non-Devanagari Languages. | |
208 ("o" . "(5e(B") | |
209 ("au" . "(5f(B") | |
210 ;; ("o.c" . "(5g(B") ; Tentatively suppressed. | |
211 )) | |
212 | |
213 ;; | |
214 ;; Independent vowels and other signs. | |
215 ;; | |
216 | |
217 (defvar indian-itrans-other-letters-alist | |
218 '( | |
219 ("a" . "(5$(B") | |
220 ("aa" . "(5%(B") | |
221 ("A" . "(5%(B") | |
222 ("i" . "(5&(B") | |
223 ("ii" . "(5'(B") | |
224 ("I" . "(5'(B") | |
225 ("u" . "(5((B") | |
226 ("uu" . "(5)(B") | |
227 ("U" . "(5)(B") | |
228 ("R^i" . "(5*(B") | |
229 ("R^I" . "(5*i(B") | |
230 ("L^i" . "(5&i(B") | |
231 ("L^I" . "(5'i(B") | |
232 ("E" . "(5+(B") ; For transcription of non-Devanagari Languages. | |
233 ("e" . "(5,(B") | |
234 ("ai" . "(5-(B") | |
235 ;; ("e.c" . "(5.(B") ; Candra E | |
236 ("O" . "(5/(B") ; For transcription of non-Devanagari Languages. | |
237 ("o" . "(50(B") | |
238 ("au" . "(51(B") | |
239 ;; ("o.c" . "(52(B") ; Candra O | |
240 ("M" . "(5$(B") | |
241 ("H" . "(5#(B") | |
242 ("AUM" . "(5!i(B") | |
243 ("OM" . "(5!i(B") | |
244 (".r" . "(5Oh(B") | |
245 (".n" . "(5"(B") | |
246 (".N" . "(5!(B") | |
247 (".h" . "(5h(B") ; Halant | |
248 (".." . "(5j(B") | |
249 (".a" . "(5ji(B") ; Avagrah | |
250 ("0" . "(5q(B") | |
251 ("1" . "(5r(B") | |
252 ("2" . "(5s(B") | |
253 ("3" . "(5t(B") | |
254 ("4" . "(5u(B") | |
255 ("5" . "(5v(B") | |
256 ("6" . "(5w(B") | |
257 ("7" . "(5x(B") | |
258 ("8" . "(5y(B") | |
259 ("9" . "(5z(B") | |
260 )) | |
261 | |
262 ;; Regular expression matching single Indian character represented | |
263 ;; by ITRANS. | |
264 | |
265 (defvar indian-itrans-regexp | |
266 (let ((consonant "\\([cs]hh?\\)\\|[kgjTDnpbyr]h?\\|\\(N\\^?\\)\\|\\(jN\\)\\|[mvqKGzfs]\\|\\(ld?\\)\\|\\(ksh\\)\\|\\(GY\\)\\|\\(\\.Dh?\\)") | |
267 (vowel "\\(a[aiu]\\)\\|\\(ii\\)\\|\\(uu\\)\\|\\([RL]\\^[iI]\\)\\|[AIEOeoaiu]") | |
268 (misc "[MH0-9]\\|\\(AUM\\)\\|\\(OM\\)\\|\\(\\.[rnNh\\.a]\\)") | |
269 (lpre "\\(") (rpre "\\)") (orre "\\|")) | |
270 (concat lpre misc rpre orre | |
271 lpre lpre consonant rpre "?" lpre vowel rpre rpre orre | |
272 lpre consonant rpre ))) | |
273 | |
274 ;; | |
275 ;; Regular expression matching single ITRANS unit for IS 13194 characters. | |
276 ;; | |
277 | |
278 (defvar itrans-indian-regexp | |
279 (let ((vowel "[(5$(B-(52(B]") | |
280 (consonant "[(53(B-(5X(B]") | |
17300
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
281 (matra "[(5Z(B-(5g(B]") |
17052 | 282 (misc "[(5q(B-(5z(B]") |
283 (lpre "\\(") (rpre "\\)") (orre "\\|")) | |
17300
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
284 (concat misc orre |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
285 lpre consonant matra "?" rpre orre |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
286 vowel))) |
17052 | 287 |
288 ;; | |
289 ;; IS13194 - ITRANS conversion table for string matching above regexp. | |
290 ;; | |
291 | |
292 (defvar indian-itrans-alist | |
293 (let ((cl indian-itrans-consonant-alist) | |
294 (ml indian-itrans-other-letters-alist) rules) | |
295 (while cl | |
296 (let ((vl indian-itrans-vowel-sign-alist)) | |
297 (while vl | |
298 (setq rules | |
299 (cons (cons (concat (car (car cl)) (car (car vl))) | |
300 (concat (cdr (car cl)) (cdr (car vl)))) | |
301 rules)) | |
302 (setq vl (cdr vl)))) | |
303 (setq cl (cdr cl))) | |
304 (while ml | |
305 (setq rules (cons (cons (car (car ml)) | |
306 (cdr (car ml))) | |
307 rules)) | |
308 (setq ml (cdr ml))) | |
309 rules)) | |
310 | |
311 ;; | |
312 ;; Utility program to convert from ITRANS to IS 13194 in specified region. | |
313 ;; | |
314 | |
315 (defun indian-decode-itrans-region (from to) | |
316 "Convert `ITRANS' mnemonics of the current region to Indian characters. | |
317 When called from a program, expects two arguments, | |
318 positions (integers or markers) specifying the stretch of the region." | |
319 (interactive "r") | |
320 (save-restriction | |
321 (narrow-to-region from to) | |
322 (goto-char (point-min)) | |
323 (while (re-search-forward indian-itrans-regexp nil t) | |
324 (let* ((itrans (buffer-substring (match-beginning 0) (match-end 0))) | |
325 (ch (cdr (assoc itrans indian-itrans-alist)))) | |
326 (if ch | |
327 (progn | |
328 (delete-region (match-beginning 0) (match-end 0)) | |
329 (insert ch))))) | |
330 (goto-char (point-min)) | |
331 (while (re-search-forward "\\((5h(B\\)[^\\c0]" nil t) | |
332 (delete-region (match-beginning 1) (match-end 1))))) | |
333 | |
334 ;; | |
335 ;; Utility program to convert from IS 13194 to ITRANS in specified region. | |
336 ;; | |
337 | |
17300
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
338 (defun indian-encode-itrans-region (from to) |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
339 "Convert indian region to ITRANS mnemonics." |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
340 (interactive "r") |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
341 (save-restriction |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
342 (narrow-to-region from to) |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
343 (goto-char (point-min)) |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
344 (while (re-search-forward itrans-indian-regexp nil t) |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
345 (let* ((indian (buffer-substring (match-beginning 0) (match-end 0))) |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
346 (ch (car (rassoc indian indian-itrans-alist)))) |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
347 (if ch |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
348 (progn |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
349 (delete-region (match-beginning 0) (match-end 0)) |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
350 (insert ch))))) |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
351 (goto-char (point-min)))) |
01d528c5dd18
Handle more Devanagari characters correctly.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
352 |
17052 | 353 ;;; indian.el ends here |