Mercurial > emacs
annotate lisp/language/tibet-util.el @ 19151:a51718eb64d1
(RUSSIAN): Add quail/cyril-jis.el.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 05 Aug 1997 01:16:44 +0000 |
parents | 358f6a7b1bbb |
children | ba3f986d3965 |
rev | line source |
---|---|
17315
a3ca5e15c82a
Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents:
17301
diff
changeset
|
1 ;;; tibet-util.el --- Support for inputting Tibetan characters |
17301 | 2 |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
18377
8b4a66c66dd6
Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
18309
diff
changeset
|
4 ;; Licensed to the Free Software Foundation. |
17301 | 5 |
6 ;; Keywords: multilingual, Tibetan | |
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 | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;; Author: Toru TOMABECHI, <Toru.Tomabechi@orient.unil.ch> | |
26 | |
27 ;; Created: Feb. 17. 1997 | |
28 | |
29 ;; History: | |
30 ;; 1997.03.13 Modification in treatment of text properties; | |
31 ;; Support for some special signs and punctuations. | |
32 | |
33 ;;; Code: | |
34 | |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17776
diff
changeset
|
35 ;;;###autoload |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17776
diff
changeset
|
36 (defun setup-tibetan-environment () |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17776
diff
changeset
|
37 (interactive) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17776
diff
changeset
|
38 (setup-english-environment) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17776
diff
changeset
|
39 (setq coding-category-iso-8-2 'tibetan) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17776
diff
changeset
|
40 |
18971
831d4fb63852
(setup-tibetan-environment): Correct
Kenichi Handa <handa@m17n.org>
parents:
18788
diff
changeset
|
41 (setq-default buffer-file-coding-system 'iso-2022-7bit) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17776
diff
changeset
|
42 |
18971
831d4fb63852
(setup-tibetan-environment): Correct
Kenichi Handa <handa@m17n.org>
parents:
18788
diff
changeset
|
43 (setq default-input-method "tibetan-wylie") |
19086
358f6a7b1bbb
(setup-tibetan-environment): Set default value of default-input-method.
Kenichi Handa <handa@m17n.org>
parents:
18971
diff
changeset
|
44 (setq-default default-input-method "tibetan-wylie") |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17776
diff
changeset
|
45 |
18971
831d4fb63852
(setup-tibetan-environment): Correct
Kenichi Handa <handa@m17n.org>
parents:
18788
diff
changeset
|
46 (setq sendmail-coding-system 'iso-2022-7bit |
831d4fb63852
(setup-tibetan-environment): Correct
Kenichi Handa <handa@m17n.org>
parents:
18788
diff
changeset
|
47 rmail-file-coding-system 'iso-2022-7bit)) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17776
diff
changeset
|
48 |
17301 | 49 ;;; This function makes a transcription string for |
50 ;;; re-composing a character. | |
51 | |
52 ;;;###autoload | |
53 (defun tibetan-tibetan-to-transcription (ch) | |
54 "Return a transcription string of Tibetan character CH" | |
55 (let ((char ch) | |
56 (l (append tibetan-consonant-transcription-alist | |
57 tibetan-vowel-transcription-alist | |
58 tibetan-precomposed-transcription-alist | |
59 tibetan-subjoined-transcription-alist)) | |
60 decomp-l t-char trans str result) | |
61 (if (eq (char-charset char) 'composition) | |
62 (setq decomp-l (decompose-composite-char char 'list nil)) | |
63 (setq decomp-l (cons char nil))) | |
64 (setq str "") | |
65 (while decomp-l | |
66 (setq t-char (char-to-string (car decomp-l))) | |
67 (setq trans (car (rassoc t-char l))) | |
68 (setq str (concat str trans)) | |
69 (setq decomp-l (cdr decomp-l))) | |
70 (setq result str))) | |
71 | |
72 ;;; This function translates transcription string into a string of | |
73 ;;; Tibetan characters. | |
74 | |
75 ;;;###autoload | |
76 (defun tibetan-transcription-to-tibetan (transcription) | |
77 "Translate Roman transcription into a sequence of Tibetan components." | |
78 (let ((trans transcription) | |
79 (lp tibetan-precomposed-transcription-alist) | |
80 (l (append tibetan-consonant-transcription-alist | |
81 tibetan-vowel-transcription-alist | |
82 tibetan-subjoined-transcription-alist)) | |
83 (case-fold-search nil) | |
84 substr t-char p-str t-str result) | |
85 (setq substr "") | |
86 (setq p-str "") | |
87 (setq t-str "") | |
88 (cond ((string-match tibetan-precomposed-regexp trans) | |
89 (setq substr (substring trans (match-beginning 0) (match-end 0))) | |
90 (setq trans (substring trans (match-end 0))) | |
91 (setq t-char (cdr (assoc substr lp))) | |
92 (setq p-str t-char))) | |
93 (while (string-match tibetan-regexp trans) | |
94 (setq substr (substring trans (match-beginning 0) (match-end 0))) | |
95 (setq trans (substring trans 0 (match-beginning 0))) | |
96 (setq t-char | |
97 (cdr (assoc substr l))) | |
98 (setq t-str (concat t-char t-str))) | |
99 (setq result (concat p-str t-str)))) | |
100 | |
101 | |
102 ;;; | |
103 ;;; Functions for composing Tibetan character. | |
104 ;;; | |
105 ;;; A Tibetan syllable is typically structured as follows: | |
106 ;;; | |
107 ;;; [Prefix] C [C+] V [M] [Suffix [Post suffix]] | |
108 ;;; | |
109 ;;; where C's are all vertically stacked, V appears below or above | |
110 ;;; consonant cluster and M is always put above the C[C+]V combination. | |
111 ;;; (Sanskrit visarga, though it is a vowel modifier, is considered | |
112 ;;; to be a punctuation.) | |
113 ;;; | |
114 ;;; Here are examples of the words "bsgrubs" and "h'uM" | |
115 ;;; | |
116 ;;; $(7"72%q`"U1"7"G(B 2$(7"H`#A`"U0"_1(B | |
117 ;;; | |
118 ;;; M | |
119 ;;; b s b s h | |
120 ;;; g ' | |
121 ;;; r u | |
122 ;;; u | |
123 ;;; | |
124 ;;; Consonants ''', 'w', 'y', 'r' take special forms when they are used | |
125 ;;; as subjoined consonant. Consonant 'r' takes another special form | |
126 ;;; when used as superjoined as in "rka", and so on, while it does not | |
127 ;;; change its form when conjoined with subjoined ''', 'w' or 'y' | |
128 ;;; as in "rwa", "rya". | |
129 ;;; | |
130 ;;; | |
131 ;;; As a Tibetan input method should avoid using conversion key, | |
132 ;;; we use a "Tibetan glyph -> transcription -> Tibetan glyph" | |
133 ;;; translation at each key input. | |
134 ;;; | |
135 ;;; 1st stage - Check the preceding char. | |
136 ;;; If the preceding char is Tibetan and composable, then | |
137 ;;; | |
138 ;;; 2nd stage - Translate the preceding char into transcription | |
139 ;;; | |
140 ;;; 3rd stage - Concatenate the transcription of preceding char | |
141 ;;; and the current input key. | |
142 ;;; | |
143 ;;; 4th stage - Re-translate the concatenated transcription into | |
144 ;;; a sequence of Tibetan letters. | |
145 ;;; | |
146 ;;; 5th stage - Convert leading consonants into one single precomposed char | |
147 ;;; if possible. | |
148 ;;; | |
149 ;;; 6th stage - Compose the consonants into one composite glyph. | |
150 ;;; | |
151 ;;; (If the current input is a vowel sign or a vowel modifier, | |
152 ;;; then it is composed with preceding char without checking | |
153 ;;; except when the preceding char is a punctuation or a digit.) | |
154 ;;; | |
155 ;;; | |
156 | |
157 ;;; This function is used to avoid composition | |
158 ;;; between Tibetan and non-Tibetan chars. | |
159 | |
160 ;;;###autoload | |
161 (defun tibetan-char-examin (ch) | |
162 "Check if char CH is Tibetan character. | |
163 Returns non-nil if CH is Tibetan. Otherwise, returns nil." | |
164 (let ((chr ch)) | |
165 (if (eq (char-charset chr) 'composition) | |
166 (string-match "\\cq+" (decompose-composite-char chr)) | |
167 (string-match "\\cq" (char-to-string chr))))) | |
168 | |
169 ;;; This is used to avoid composition between digits, signs, punctuations | |
170 ;;; and word constituents. | |
171 | |
172 ;;;###autoload | |
173 (defun tibetan-composable-examin (ch) | |
174 "Check if Tibetan char CH is composable. | |
175 Returns t if CH is a composable char \(i.e. neither punctuation nor digit)." | |
176 (let ((chr ch) | |
177 chstr) | |
178 (if (eq (char-charset chr) 'composition) | |
179 (setq chstr (decompose-composite-char chr)) | |
180 (setq chstr (char-to-string chr))) | |
181 (not (string-match "[$(7!1(B-$(7!o"f$(8!;!=!?!@!A!D"`(B]" chstr)))) | |
182 | |
183 | |
184 ;;; This checks if a character to be composed contains already | |
185 ;;; one or more vowels / vowel modifiers. If the character contains | |
186 ;;; them, then no more consonant should be added. | |
187 | |
188 ;;;###autoload | |
189 (defun tibetan-complete-char-examin (ch) | |
190 "Check if composite char CH contains one or more vowel/vowel modifiers. | |
191 Returns non-nil, if CH contains vowel/vowel modifiers." | |
192 (let ((chr ch) | |
193 chstr) | |
194 (if (eq (char-charset chr) 'composition) | |
195 (setq chstr (decompose-composite-char chr)) | |
196 (setq chstr (char-to-string chr))) | |
197 (string-match "[$(7!g!e"Q(B-$(7"^"_(B-$(7"l(B]" chstr))) | |
198 | |
199 ;;; This function makes a composite character consisting of two characters | |
200 ;;; vertically stacked. | |
201 | |
202 ;;;###autoload | |
203 (defun tibetan-vertical-stacking (first second upward) | |
204 "Return a vertically stacked composite char consisting of FIRST and SECOND. | |
205 If UPWARD is non-nil, then SECOND is put above FIRST." | |
206 (if upward | |
207 (compose-chars first '(tc . bc) second) | |
208 (compose-chars first '(bc . tc) second))) | |
209 | |
210 ;;; This function makes a composite char from a string. | |
211 ;;; Note that this function returns a string, not a char. | |
212 | |
213 ;;;###autoload | |
214 (defun tibetan-compose-string (str) | |
215 "Compose a sequence of Tibetan character components into a composite character. | |
216 Returns a string containing a composite character." | |
217 (let ((t-str str) | |
218 f-str s-str f-ch s-ch rest composed result) | |
219 ;;Make sure no redundant vowel sign is present. | |
220 (if (string-match | |
221 "^\\(.+\\)\\($(7"Q(B\\)\\([$(7!I!g!e"Q(B-$(7"^"_(B-$(7"l(B]\\)" t-str) | |
222 (setq t-str (concat | |
223 (match-string 1 t-str) | |
224 (match-string 3 t-str)))) | |
225 (if (string-match | |
226 "^\\(.+\\)\\([$(7!I!g!e"Q(B-$(7"^"_(B-$(7"l(B]\\)\\($(7"Q(B\\)" t-str) | |
227 (setq t-str (concat | |
228 (match-string 1 t-str) | |
229 (match-string 2 t-str)))) | |
230 ;;Start conversion. | |
231 (setq result "") | |
232 ;; Consecutive base/precomposed consonants are reduced to the last one. | |
233 (while (string-match "^\\([$(7"!(B-$(7"J$!(B-$(7%u(B]\\)\\([$(7"!(B-$(7"@"B(B-$(7"J$!(B-$(7%u(B].*\\)" t-str) | |
234 (setq result (concat result (match-string 1 t-str))) | |
235 (setq t-str (match-string 2 t-str))) | |
236 ;; Vowel/vowel modifier, subjoined consonants are added one by one | |
237 ;; to the preceding element. | |
238 (while | |
239 (string-match "^\\(.\\)\\([$(7"A#!(B-$(7#J!I!g!e"Q(B-$(7"^"_(B-$(7"l(B]\\)\\(.*\\)" t-str) | |
240 (setq f-str (match-string 1 t-str)) | |
241 (setq f-ch (string-to-char f-str)) | |
242 (setq s-str (match-string 2 t-str)) | |
243 ;;Special treatment for 'a chung. | |
244 ;;If 'a follows a consonant, then turned into its subjoined form. | |
245 (if (and (string-match "$(7"A(B" s-str) | |
246 (not (tibetan-complete-char-examin f-ch))) | |
247 (setq s-str "$(7#A(B")) | |
248 (setq s-ch (string-to-char s-str)) | |
249 (setq rest (match-string 3 t-str)) | |
250 (cond ((string-match "\\c2" s-str);; upper vowel sign | |
251 (setq composed | |
252 (tibetan-vertical-stacking f-ch s-ch t))) | |
253 ((string-match "\\c3" s-str);; lower vowel sign | |
254 (setq composed | |
255 (tibetan-vertical-stacking f-ch s-ch nil))) | |
256 ;;Automatic conversion of ra-mgo (superscribed r). | |
257 ;;'r' is converted if followed by a subjoined consonant | |
258 ;;other than w, ', y, r. | |
259 ((and (string-match "$(7"C(B" f-str) | |
260 (not (string-match "[$(7#>#A#B#C(B]" s-str))) | |
261 (setq f-ch ?$(7#P(B) | |
262 (setq composed | |
263 (tibetan-vertical-stacking f-ch s-ch nil))) | |
264 ((not (tibetan-complete-char-examin f-ch)) | |
265 ;;Initial base consonant is tranformed, if followed by | |
266 ;;a subjoined consonant, except when it is followed | |
267 ;;by a subscribed 'a. | |
268 (if (and (string-match "[$(7"!(B-$(7"="?"@"D(B-$(7"J(B]" f-str) | |
269 (not (string-match "$(7#A(B" s-str))) | |
270 (setq f-ch | |
271 (string-to-char | |
272 (cdr (assoc f-str tibetan-base-to-subjoined-alist))))) | |
273 (setq composed | |
274 (tibetan-vertical-stacking f-ch s-ch nil))) | |
275 (t | |
276 (setq composed s-str) | |
277 (setq result (concat result f-str)))) | |
278 (setq t-str (concat composed rest))) | |
279 (setq result (concat result t-str)))) | |
280 | |
281 ;;; quail <-> conversion interface. | |
282 | |
283 (defun tibetan-composition (pc key) | |
284 "Interface to quail input method. | |
285 Takes two arguments: char PC and string KEY, where PC is the preceding | |
286 character to be composed with current input KEY. | |
287 Returns a string which is the result of composition." | |
288 (let (trans cur-ch t-str result) | |
289 ;; Make a tibetan character corresponding to current input key. | |
290 (setq cur-ch (tibetan-transcription-to-tibetan key)) | |
291 ;; Check if the preceding character is Tibetan and composable. | |
292 (cond ((and (tibetan-char-examin pc) | |
293 (tibetan-composable-examin pc)) | |
294 ;;If Tibetan char corresponding to the current input key exists, | |
295 (cond (cur-ch | |
296 ;; Then, | |
297 ;; Convert the preceding character into transcription, | |
298 ;; and concatenate it with the current input key, | |
299 (setq trans (tibetan-tibetan-to-transcription pc)) | |
300 (setq trans (concat trans key)) | |
301 ;; Concatenated transcription is converted to | |
302 ;; a sequence of Tibetan characters, | |
303 (setq t-str (tibetan-transcription-to-tibetan trans)) | |
304 ;; And it is composed into a composite character. | |
305 (setq result (tibetan-compose-string t-str))) | |
306 ;; Else, | |
307 (t | |
308 ;; Simply concatenate the preceding character and | |
309 ;; the current input key. | |
310 (setq result (char-to-string pc)) | |
311 (setq result (concat result key))))) | |
312 ;; If the preceding char is not Tibetan or not composable, | |
313 (t | |
314 ;; pc = 0 means the point is at the beginning of buffer. | |
315 (if (not (eq pc 0)) | |
316 (setq result (char-to-string pc))) | |
317 (if cur-ch | |
318 (setq result (concat result cur-ch)) | |
319 (setq result (concat result key)))) | |
320 ))) | |
321 | |
322 | |
323 ;;;###autoload | |
324 (defun tibetan-decompose-region (beg end) | |
325 "Decompose Tibetan characters in the region BEG END into their components. | |
326 Components are: base and subjoined consonants, vowel signs, vowel modifiers. | |
327 One column punctuations are converted to their 2 column equivalents." | |
328 (interactive "r") | |
329 (let (ch-str ch-beg ch-end) | |
330 (save-excursion | |
331 (save-restriction | |
332 (narrow-to-region beg end) | |
333 (goto-char (point-min)) | |
334 ;; \\cq = Tibetan character | |
335 (while (re-search-forward "\\cq" nil t) | |
336 (setq ch-str (buffer-substring-no-properties | |
337 (match-beginning 0) (match-end 0))) | |
338 ;; Save the points. Maybe, using save-match-data is preferable. | |
339 ;; But in order not to lose the trace(because the body is too long), | |
340 ;; we save the points in variables. | |
341 (setq ch-beg (match-beginning 0)) | |
342 (setq ch-end (match-end 0)) | |
343 ;; Here starts the decomposition. | |
344 (cond | |
345 ;; 1 column punctuations -> 2 column equivalent | |
346 ((string-match "[$(8!D!;!=!?!@!A"`(B]" ch-str) | |
347 (setq ch-str | |
348 (car (rassoc ch-str tibetan-precomposition-rule-alist)))) | |
349 ;; Decomposition of composite character. | |
350 ((eq (char-charset (string-to-char ch-str)) 'composition) | |
351 ;; Make a string which consists of a sequence of | |
352 ;; components. | |
353 (setq ch-str (decompose-composite-char (string-to-char ch-str))) | |
354 ;; Converts nyi zla into base elements. | |
355 (cond ((string= ch-str "$(7#R#S#S#S(B") | |
356 (setq ch-str "$(7!4!5!5(B")) | |
357 ((string= ch-str "$(7#R#S#S(B") | |
358 (setq ch-str "$(7!4!5(B")) | |
359 ((string= ch-str "$(7#R#S!I(B") | |
360 (setq ch-str "$(7!6(B")) | |
361 ((string= ch-str "$(7#R#S(B") | |
362 (setq ch-str "$(7!4(B"))))) | |
363 ;; If the sequence of components starts with a subjoined consonants, | |
364 (if (string-match "^\\([$(7#!(B-$(7#J(B]\\)\\(.*\\)$" ch-str) | |
365 ;; then the first components is converted to its base form. | |
366 (setq ch-str | |
367 (concat (car (rassoc (match-string 1 ch-str) | |
368 tibetan-base-to-subjoined-alist)) | |
369 (match-string 2 ch-str)))) | |
370 ;; If the sequence of components starts with a precomposed character, | |
371 (if (string-match "^\\([$(7$!(B-$(7%u(B]\\)\\(.*\\)$" ch-str) | |
372 ;; then it is converted into a sequence of components. | |
373 (setq ch-str | |
374 (concat (car (rassoc (match-string 1 ch-str) | |
375 tibetan-precomposition-rule-alist)) | |
376 (match-string 2 ch-str)))) | |
377 ;; Special treatment for superscribed r. | |
378 (if (string-match "^$(7#P(B\\(.*\\)$" ch-str) | |
379 (setq ch-str (concat "$(7"C(B" (match-string 1 ch-str)))) | |
380 ;; Finally, the result of decomposition is inserted, and | |
381 ;; the composite character is deleted. | |
382 (insert-and-inherit ch-str) | |
383 (delete-region ch-beg ch-end)))))) | |
384 | |
385 ;;;###autoload | |
386 (defun tibetan-compose-region (beg end) | |
387 "Make composite chars from Tibetan character components in the region BEG END. | |
388 Two column punctuations are converted to their 1 column equivalents." | |
389 (interactive "r") | |
390 (let (str result) | |
391 (save-excursion | |
392 (save-restriction | |
393 (narrow-to-region beg end) | |
394 (goto-char (point-min)) | |
395 ;; First, sequence of components which has a precomposed equivalent | |
396 ;; is converted. | |
397 (while (re-search-forward | |
398 tibetan-precomposition-rule-regexp nil t) | |
399 (setq str (buffer-substring-no-properties | |
400 (match-beginning 0) (match-end 0))) | |
401 (save-match-data | |
402 (insert-and-inherit | |
403 (cdr (assoc str tibetan-precomposition-rule-alist)))) | |
404 (delete-region (match-beginning 0) (match-end 0))) | |
405 (goto-char (point-min)) | |
406 ;; Then, composable elements are put into a composite character. | |
407 (while (re-search-forward | |
408 "[$(7"!(B-$(7"J$!(B-$(7%u(B]+[$(7#!(B-$(7#J!I!g!e"Q(B-$(7"^"_(B-$(7"l(B]+" | |
409 nil t) | |
410 (setq str (buffer-substring-no-properties | |
411 (match-beginning 0) (match-end 0))) | |
412 (save-match-data | |
413 (setq result (tibetan-compose-string str)) | |
414 (insert-and-inherit result)) | |
415 (delete-region (match-beginning 0) (match-end 0))))))) | |
416 | |
417 ;;; | |
418 ;;; This variable is used to avoid repeated decomposition. | |
419 ;;; | |
420 (setq-default tibetan-decomposed nil) | |
421 | |
422 ;;;###autoload | |
423 (defun tibetan-decompose-buffer () | |
424 "Decomposes Tibetan characters in the buffer into their components. | |
425 See also docstring of the function tibetan-decompose-region." | |
426 (interactive) | |
427 (make-local-variable 'tibetan-decomposed) | |
428 (cond ((not tibetan-decomposed) | |
429 (tibetan-decompose-region (point-min) (point-max)) | |
430 (setq tibetan-decomposed t)))) | |
431 | |
432 ;;;###autoload | |
433 (defun tibetan-compose-buffer () | |
434 "Composes Tibetan character components in the buffer. | |
435 See also docstring of the function tibetan-compose-region." | |
436 (interactive) | |
437 (make-local-variable 'tibetan-decomposed) | |
438 (tibetan-compose-region (point-min) (point-max)) | |
439 (setq tibetan-decomposed nil)) | |
440 | |
441 ;;;###autoload | |
442 (defun tibetan-post-read-conversion (len) | |
443 (save-excursion | |
444 (save-restriction | |
445 (let ((buffer-modified-p (buffer-modified-p))) | |
446 (narrow-to-region (point) (+ (point) len)) | |
447 (tibetan-compose-region (point-min) (point-max)) | |
448 (set-buffer-modified-p buffer-modified-p) | |
449 (point-max)))) | |
450 (make-local-variable 'tibetan-decomposed) | |
451 (setq tibetan-decomposed nil)) | |
452 | |
453 | |
454 ;;;###autoload | |
455 (defun tibetan-pre-write-conversion (from to) | |
456 (setq tibetan-decomposed-temp tibetan-decomposed) | |
457 (let ((old-buf (current-buffer)) | |
458 (work-buf (get-buffer-create " *tibetan-work*"))) | |
459 (set-buffer work-buf) | |
460 (erase-buffer) | |
17776
ece62fdeeebb
(tibetan-pre-write-conversion): Make it work
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
461 (if (stringp from) |
ece62fdeeebb
(tibetan-pre-write-conversion): Make it work
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
462 (insert from) |
ece62fdeeebb
(tibetan-pre-write-conversion): Make it work
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
463 (insert-buffer-substring old-buf from to)) |
17301 | 464 (if (not tibetan-decomposed-temp) |
17776
ece62fdeeebb
(tibetan-pre-write-conversion): Make it work
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
465 (tibetan-decompose-region (point-min) (point-max))) |
ece62fdeeebb
(tibetan-pre-write-conversion): Make it work
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
466 ;; Should return nil as annotations. |
ece62fdeeebb
(tibetan-pre-write-conversion): Make it work
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
467 nil)) |
17301 | 468 |
18309
bd8b521f5218
Provide XXX-util instead of
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
469 (provide 'tibet-util) |
17301 | 470 |
471 ;;; language/tibet-util.el ends here. |