]> code.delx.au - gnu-emacs/blobdiff - lisp/language/thai-util.el
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-25
[gnu-emacs] / lisp / language / thai-util.el
index 1a8802a3460bc9e5fd727b275b0bb5b7f3b7b352..259a102c61ea0a012228789f85af77285cf040e0 100644 (file)
@@ -1,9 +1,12 @@
 ;;; thai-util.el --- utilities for Thai -*- coding: iso-2022-7bit; -*-
 
 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
-;; Licensed to the Free Software Foundation.
+;;   Licensed to the Free Software Foundation.
+;; Copyright (C) 2003
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H13PRO009
 
-;; Keywords: mule, multilingual, thai
+;; Keywords: mule, multilingual, Thai, i18n
 
 ;; This file is part of GNU Emacs.
 
@@ -22,6 +25,8 @@
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
+;;; Commentary:
+
 ;;; Code:
 
 ;; Setting information of Thai characters.
@@ -174,7 +179,7 @@ positions (integers or markers) specifying the region."
        (compose-string string idx (match-end 0))
        (setq idx (match-end 0)))))
   string)
-      
+
 ;;;###autoload
 (defun thai-compose-buffer ()
   "Compose Thai characters in the current buffer."
@@ -182,26 +187,23 @@ positions (integers or markers) specifying the region."
   (thai-compose-region (point-min) (point-max)))
 
 ;;;###autoload
-(defun thai-post-read-conversion (len)
-  (thai-compose-region (point) (+ (point) len))
-  len)
-
-;;;###autoload
-(defun thai-composition-function (from to pattern &optional string)
-  "Compose Thai text in the region FROM and TO.
-The text matches the regular expression PATTERN.
-Optional 4th argument STRING, if non-nil, is a string containing text
-to compose.
-
-The return value is number of composed characters."
-  (if (< (1+ from) to)
-      (prog1 (- to from)
-       (if string
-           (compose-string string from to)
-         (compose-region from to))
-       (- to from))))
+(defun thai-composition-function (pos &optional string)
+  (setq pos (1- pos))
+  (let ((pattern "[\e,T!\e(B-\e,TCEG\e(B-\e,TN!\e(B-\e,TCEG\e(B-\e,TN\e(B][\e,TQT\e(B-\e,TWgnX\e(B-\e,TZQT\e(B-\e,TWgnX\e(B-\e,TZ\e(B]?[\e,Th\e(B-\e,Tmh\e(B-\e,Tm\e(B]?"))
+    (if string
+       (if (and (>= pos 0)
+                (eq (string-match pattern string pos) pos))
+           (prog1 (match-end 0)
+             (compose-string string pos (match-end 0))))
+      (if (>= pos (point-min))
+         (progn
+           (goto-char pos)
+           (if (looking-at pattern)
+               (prog1 (match-end 0)
+                 (compose-region pos (match-end 0)))))))))
 
 ;;
 (provide 'thai-util)
 
+;;; arch-tag: 59425d6a-8cf9-4e06-a6ab-8ab7dc7a7a97
 ;;; thai-util.el ends here