summaryrefslogtreecommitdiff
path: root/lisp/language/thai-util.el
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>1998-10-26 08:00:11 +0000
committerKenichi Handa <handa@m17n.org>1998-10-26 08:00:11 +0000
commit3de546452ed0a7c2167dfe7fef210880b65a98de (patch)
tree55a8025376ed91ab09d8bea49a16b5d37546b5a0 /lisp/language/thai-util.el
parent76d124158579b595ec6c355635aea749c169fc08 (diff)
downloademacs-3de546452ed0a7c2167dfe7fef210880b65a98de.tar.gz
(thai-pre-write-conversion): Cancel previous
change, use generate-new-buffer instead of get-buffer-create.
Diffstat (limited to 'lisp/language/thai-util.el')
-rw-r--r--lisp/language/thai-util.el33
1 files changed, 24 insertions, 9 deletions
diff --git a/lisp/language/thai-util.el b/lisp/language/thai-util.el
index 1bb9beb3c2b..fd48ff4c022 100644
--- a/lisp/language/thai-util.el
+++ b/lisp/language/thai-util.el
@@ -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 @@ positions (integers or markers) specifying the region."
(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 @@ positions (integers or markers) specifying the region."
;;;###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))