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