changeset 23546:d180b9c69e4a

(thai-pre-write-conversion): Cancel previous change, use generate-new-buffer instead of get-buffer-create.
author Kenichi Handa <handa@m17n.org>
date Mon, 26 Oct 1998 08:00:11 +0000
parents 0d25c6f765ab
children 77c967512714
files lisp/language/thai-util.el
diffstat 1 files changed, 24 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/language/thai-util.el	Mon Oct 26 08:00:11 1998 +0000
+++ b/lisp/language/thai-util.el	Mon Oct 26 08:00:11 1998 +0000
@@ -32,6 +32,12 @@
 
 ;; Setting information of Thai characters.
 
+(defvar thai-category-table (copy-category-table))
+(or (category-docstring ?+ thai-category-table)
+    (define-category ?+ "Thai consonant" thai-category-table))
+(or (category-docstring ?- thai-category-table)
+    (define-category ?- "Thai diacritical mark" thai-category-table))
+
 (let ((l '((?,T!(B consonant "LETTER KO KAI")				; 0xA1
 	   (?,T"(B consonant "LETTER KHO KHAI")				; 0xA2
 	   (?,T#(B consonant "LETTER KHO KHUAT")				; 0xA3
@@ -130,10 +136,16 @@
       elm)
   (while l
     (setq elm (car l))
-    (put-char-code-property (car elm) 'phonetic-type (car (cdr elm)))
+    (let ((ptype (nth 1 elm)))
+      (put-char-code-property (car elm) 'phonetic-type ptype)
+      (if (eq ptype 'consonant)
+	  (modify-category-entry (car elm) ?+ thai-category-table)
+	(if (memq ptype '(vowel-upper vowel-lower tone))
+	  (modify-category-entry (car elm) ?- thai-category-table))))
     (put-char-code-property (car elm) 'name (nth 2 elm))
     (setq l (cdr l))))
 
+
 ;;;###autoload
 (defun thai-compose-region (beg end)
   "Compose Thai characters in the region.
@@ -144,9 +156,12 @@
     (narrow-to-region beg end)
     (decompose-region (point-min) (point-max))
     (goto-char (point-min))
-    (while (re-search-forward "\\c0\\(\\c2\\|\\c3\\|\\c4\\)+" nil t)
-      (if (aref (char-category-set (char-after (match-beginning 0))) ?t)
-	  (compose-region (match-beginning 0) (match-end 0))))))
+    (let ((current-ctbl (category-table)))
+      (set-category-table thai-category-table)
+      (unwind-protect
+	  (while (re-search-forward "\\c+\\c-+" nil t)
+	    (compose-region (match-beginning 0) (match-end 0)))
+	(set-category-table current-ctbl)))))
 
 ;;;###autoload
 (defun thai-compose-buffer ()
@@ -167,11 +182,11 @@
 ;;;###autoload
 (defun thai-pre-write-conversion (from to)
   (let ((old-buf (current-buffer)))
-    (with-temp-buffer
-      (if (stringp from)
-	  (insert from)
-	(insert-buffer-substring old-buf from to))
-      (decompose-region (point-min) (point-max)))
+    (set-buffer (generate-new-buffer " *temp*"))
+    (if (stringp from)
+	(insert from)
+      (insert-buffer-substring old-buf from to))
+    (decompose-region (point-min) (point-max))
     ;; Should return nil as annotations.
     nil))