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