]> code.delx.au - gnu-emacs/commitdiff
New file.
authorKenichi Handa <handa@m17n.org>
Tue, 11 Feb 2003 01:38:31 +0000 (01:38 +0000)
committerKenichi Handa <handa@m17n.org>
Tue, 11 Feb 2003 01:38:31 +0000 (01:38 +0000)
lisp/language/malayalam.el [new file with mode: 0644]
lisp/language/mlm-util.el [new file with mode: 0644]
lisp/language/tamil.el [new file with mode: 0644]
lisp/language/tml-util.el [new file with mode: 0644]

diff --git a/lisp/language/malayalam.el b/lisp/language/malayalam.el
new file mode 100644 (file)
index 0000000..3a7c198
--- /dev/null
@@ -0,0 +1,46 @@
+;;; malayalam.el --- Support for Malayalam -*- coding: iso-2022-7bit; no-byte-compile: t -*-
+
+;; Copyright (C) 2003 Free Software Foundation, Inc.
+
+;; Maintainer:  KAWABATA, Taichi <kawabata@m17n.org>
+;; Keywords: multilingual, Indian, Malayalam
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; This file defines language-info of Malayalam script.
+
+;;; Code:
+
+(set-language-info-alist
+ "Malayalam" '((charset mule-unicode-0100-24ff indian-glyph )
+               ;;          indian-2-column 
+               ;; comment out later
+               ;;          )
+               (coding-system utf-8)
+               (coding-priority utf-8)
+               (input-method . "malayalam-itrans")
+               (features mlm-util)
+               (documentation . "\
+South Indian language Malayalam is supported in this language environment."))
+ '("Indian"))
+
+(provide 'malayalam)
+
+;;; malayalam.el ends here
diff --git a/lisp/language/mlm-util.el b/lisp/language/mlm-util.el
new file mode 100644 (file)
index 0000000..86afaca
--- /dev/null
@@ -0,0 +1,406 @@
+;;; mlm-util.el --- support for composing malayalam characters  -*-coding: iso-2022-7bit;-*-
+
+;; Copyright (C) 2003 Free Software Foundation, Inc.
+
+;; Maintainer:  KAWABATA, Taichi <kawabata@m17n.org>
+;; Keywords: multilingual, Malayalam
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; Created: Feb. 11. 2003
+
+;;; Commentary:
+
+;; This file provides character(Unicode) to glyph(CDAC) conversion and
+;; composition of Malayalam script characters.
+
+;;; Code:
+
+;; Malayalam Composable Pattern
+;;    C .. Consonants
+;;    V .. Vowel
+;;    H .. Halant
+;;    M .. Matra
+;;    V .. Vowel
+;;    A .. Anuswar
+;;    D .. Chandrabindu
+;;    (N .. Zerowidth Non Joiner)
+;;    (J .. Zerowidth Joiner.  )
+;; 1. vowel
+;;  V(A|visargam)?
+;; 2. syllable : maximum of 5 consecutive consonants.  (e.g. kartsnya)
+;;  ((CH)?(CH)?(CH)?CH)?C(H|M?(A|D)?)?
+
+(defconst malayalam-consonant
+  "[\e$,1@5\e(B-\e$,1@Y\e(B]")
+
+(defconst malayalam-composable-pattern
+  (concat
+   "\\([\e$,1@%\e(B-\e$,1@4\e(B][\e$,1@"\e(B]?\\)\\|\e$,1@#\e(B"
+   "\\|\\("
+   "\\(?:\\(?:[\e$,1@5\e(B-\e$,1@Y\e(B]\e$,1@m\e(B\\)?\\(?:[\e$,1@5\e(B-\e$,1@Y\e(B]\e$,1@m\e(B\\)?\\(?:[\e$,1@5\e(B-\e$,1@Y\e(B]\e$,1@m\e(B\\)?[\e$,1@5\e(B-\e$,1@Y\e(B]\e$,1@m\e(B\\)?"
+   "[\e$,1@5\e(B-\e$,1@Y\e(B]\\(?:\e$,1@m\e(B\\|[\e$,1@^\e(B-\e$,1@c@f@g@h@j@j@k@l\e(B]?[\e$,1@"@m\e(B]?\\)?"
+   "\\)")
+  "Regexp matching a composable sequence of Malayalam characters.")
+
+;;;###autoload
+(defun malayalam-compose-region (from to)
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region from to)
+      (goto-char (point-min))
+      (while (re-search-forward malayalam-composable-pattern nil t)
+       (malayalam-compose-syllable-region (match-beginning 0)
+                                           (match-end 0))))))
+(defun malayalam-compose-string (string)
+  (with-temp-buffer
+    (insert (decompose-string string))
+    (malayalam-compose-region (point-min) (point-max))
+    (buffer-string)))
+
+(defun malayalam-post-read-conversion (len)
+  (save-excursion
+    (save-restriction
+      (let ((buffer-modified-p (buffer-modified-p)))
+       (narrow-to-region (point) (+ (point) len))
+       (malayalam-compose-region (point-min) (point-max))
+       (set-buffer-modified-p buffer-modified-p)
+       (- (point-max) (point-min))))))
+
+(defun malayalam-range (from to)
+  "Make the list of the integers of range FROM to TO."
+  (let (result)
+    (while (<= from to) (setq result (cons to result) to (1- to))) result))
+
+(defun malayalam-regexp-of-hashtbl-keys (hashtbl)
+  "Return a regular expression that matches all keys in hashtable HASHTBL."
+  (let ((max-specpdl-size 1000))
+    (regexp-opt
+     (sort
+      (let (dummy)
+       (maphash (function (lambda (key val) (setq dummy (cons key dummy)))) hashtbl)
+       dummy)
+      (function (lambda (x y) (> (length x) (length y))))))))
+
+
+;;;###autoload
+(defun malayalam-composition-function (from to pattern  &optional string)
+  "Compose Malayalam characters in REGION, or STRING if specified.
+Assume that the REGION or STRING must fully match the composable 
+PATTERN regexp."
+  (if string (malayalam-compose-syllable-string string)
+    (malayalam-compose-syllable-region from to))
+  (- to from))
+
+;; Register a function to compose Malayalam characters.
+(mapc
+ (function (lambda (ucs)
+   (aset composition-function-table (decode-char 'ucs ucs)
+        (list (cons malayalam-composable-pattern
+                     'malayalam-composition-function)))))
+ (nconc '(#x0d02 #x0d03) (malayalam-range #x0d05 #x0d39)))
+
+;; Notes on conversion steps.
+
+;; 1. chars to glyphs
+;;
+;; Simple replacement of characters to glyphs is done.
+
+;; 2. glyphs reordering.
+;;
+;; Two special reordering rule takes place.
+;; a. following "\e$,46[\e(B" goes to the front.
+;; b. following "\e$,46S6S\e(B", "\e$,46S\e(B" or "\e$,46T\e(B" goes to the front.
+;; This reordering occurs only to the last cluster of consonants.
+;; Preceding consonants with halant characters are not affected.
+
+;; 3. Composition.
+;;
+;; left modifiers will be attached at the left.
+;; others will be attached right.
+
+(defvar mlm-char-glyph
+  '(;; various signs
+    ("\e$,1@"\e(B" . "\e$,46W\e(B")
+    ("\e$,1@#\e(B" . "\e$,46X\e(B")
+    ;; Independent Vowels
+    ("\e$,1@%\e(B" . "\e$,46!\e(B")
+    ("\e$,1@&\e(B" . "\e$,46"\e(B")
+    ("\e$,1@'\e(B" . "\e$,46#\e(B")
+    ("\e$,1@(\e(B" . "\e$,46#6U\e(B")
+    ("\e$,1@)\e(B" . "\e$,46$\e(B")
+    ("\e$,1@*\e(B" . "\e$,46$6U\e(B")
+    ("\e$,1@+\e(B" . "\e$,46%\e(B")
+    ("\e$,1@,\e(B" . "nil") ;; not in present use, not supported.
+    ("\e$,1@.\e(B" . "\e$,46&\e(B")
+    ("\e$,1@/\e(B" . "\e$,46'\e(B")
+    ("\e$,1@0\e(B" . "\e$,46S6&\e(B")
+    ("\e$,1@2\e(B" . "\e$,46(\e(B")
+    ("\e$,1@3\e(B" . "\e$,46(6M\e(B")
+    ("\e$,1@4\e(B" . "\e$,46(6U\e(B")
+    ;; Consonants
+    ("\e$,1@5\e(B" . "\e$,46)\e(B")
+    ("\e$,1@5@m@5\e(B" . "\e$,47!\e(B")
+    ("\e$,1@5@m@7\e(B" . "\e$,47"\e(B")
+    ("\e$,1@5@m@W\e(B" . "\e$,47#\e(B")
+    ("\e$,1@5@m@?\e(B" . "\e$,47N\e(B") ;; ?
+    ("\e$,1@5@m@D\e(B" . "\e$,47`\e(B")
+    ("\e$,1@5@m@F\e(B" . "\e$,47f\e(B") ;; ? ;; vowel u?
+    ("\e$,1@5@m@5@m@F\e(B" . "\e$,47g\e(B") ;; ? ;; vowel u?
+
+    ("\e$,1@6\e(B" . "\e$,46*\e(B")
+
+    ("\e$,1@7\e(B" . "\e$,46+\e(B")
+    ("\e$,1@7@m@7\e(B" . "\e$,47$\e(B")
+    ("\e$,1@7@m@R\e(B" . "\e$,47%\e(B")
+    ("\e$,1@7@m@N\e(B" . "\e$,47\\e(B")
+    ("\e$,1@7@m@H\e(B" . "\e$,47a\e(B")
+
+    ("\e$,1@8\e(B" . "\e$,46,\e(B")
+
+    ("\e$,1@9\e(B" . "\e$,46-\e(B")
+    ("\e$,1@9@m@5\e(B" . "\e$,47&\e(B")
+    ("\e$,1@9@m@9\e(B" . "\e$,47'\e(B")
+    ("\e$,1@9@m@5@m@F\e(B" . "\e$,47h\e(B") ;; ? ;; vowel u?
+
+    ("\e$,1@:\e(B" . "\e$,46.\e(B")
+    ("\e$,1@:@m@:\e(B" . "\e$,47(\e(B") ;; duplicate
+    ("\e$,1@:@m@;\e(B" . "\e$,47Q\e(B") ;; ?
+
+    ("\e$,1@;\e(B" . "\e$,46/\e(B")
+
+    ("\e$,1@<\e(B" . "\e$,460\e(B")
+    ("\e$,1@<@m@<\e(B" . "\e$,47V\e(B")
+    ("\e$,1@<@m@>\e(B" . "\e$,47Z\e(B")
+
+    ("\e$,1@=\e(B" . "\e$,461\e(B")
+
+    ("\e$,1@>\e(B" . "\e$,462\e(B")
+    ("\e$,1@>@m@:\e(B" . "\e$,47)\e(B")
+    ("\e$,1@>@m@>\e(B" . "\e$,47*\e(B")
+
+    ("\e$,1@?\e(B" . "\e$,463\e(B")
+    ("\e$,1@?@m@?\e(B" . "\e$,47+\e(B")
+
+    ("\e$,1@@\e(B" . "\e$,464\e(B")
+    ("\e$,1@A\e(B" . "\e$,465\e(B")
+    ("\e$,1@A@m@A\e(B" . "\e$,47M\e(B")
+    ("\e$,1@B\e(B" . "\e$,466\e(B")
+
+    ("\e$,1@C\e(B" . "\e$,467\e(B")
+    ("\e$,1@C@m\e(B" . "\e$,47,\e(B") ;; half consonant
+    ("\e$,1@C@m@?\e(B" . "\e$,47-\e(B")
+    ("\e$,1@C@m@C\e(B" . "\e$,47.\e(B")
+    ("\e$,1@C@m@N\e(B" . "\e$,47W\e(B")
+    ("\e$,1@C@m@G\e(B" . "\e$,47^\e(B") ;; ?
+    ("\e$,1@C@m@V\e(B" . "\e$,47i\e(B") ;; ?
+
+    ("\e$,1@D\e(B" . "\e$,468\e(B")
+    ("\e$,1@D@m@D\e(B" . "\e$,47/\e(B")
+    ("\e$,1@D@m@E\e(B" . "\e$,470\e(B")
+    ("\e$,1@D@m@X\e(B" . "\e$,47U\e(B")
+    ("\e$,1@D@m@M\e(B" . "\e$,47[\e(B")
+    ("\e$,1@D@m@N\e(B" . "\e$,47_\e(B")
+    ("\e$,1@D@m@F\e(B" . "\e$,47j\e(B") ;; ? ;; vowel u ?
+
+    ("\e$,1@E\e(B" . "\e$,469\e(B")
+
+    ("\e$,1@F\e(B" . "\e$,46:\e(B")
+    ("\e$,1@F@m@F\e(B" . "\e$,471\e(B")
+    ("\e$,1@F@m@G\e(B" . "\e$,472\e(B")
+
+    ("\e$,1@G\e(B" . "\e$,46;\e(B")
+
+    ("\e$,1@H\e(B" . "\e$,46<\e(B")
+    ("\e$,1@H@m\e(B" . "\e$,473\e(B") ;; half consonant
+    ("\e$,1@H@m@D\e(B" . "\e$,474\e(B")
+    ("\e$,1@H@m@F\e(B" . "\e$,475\e(B")
+    ("\e$,1@H@m@H\e(B" . "\e$,476\e(B")
+    ("\e$,1@H@m@N\e(B" . "\e$,477\e(B")
+    ("\e$,1@H@m@G\e(B" . "\e$,47T\e(B")
+    ("\e$,1@H@m@E\e(B" . "\e$,47Y\e(B")
+    ("\e$,1@H@m@Q\e(B" . "\e$,47b\e(B")
+    ("\e$,1@H@m@V\e(B" . "\e$,47k\e(B") ;; ?
+    ("\e$,1@H@m@H@m@V\e(B" . "\e$,47l\e(B") ;; ?
+
+    ("\e$,1@J\e(B" . "\e$,46=\e(B")
+    ("\e$,1@J@m@J\e(B" . "\e$,478\e(B") ;; duplicate
+    ("\e$,1@J@m@R\e(B" . "\e$,479\e(B") ;; lakar
+
+    ("\e$,1@K\e(B" . "\e$,46>\e(B")
+
+    ("\e$,1@L\e(B" . "\e$,46?\e(B")
+    ("\e$,1@L@m@L\e(B" . "\e$,47:\e(B") ;; duplicate
+    ("\e$,1@L@m@R\e(B" . "\e$,47;\e(B") ;; lakar
+    ("\e$,1@L@m@G\e(B" . "\e$,47O\e(B") ;; ?
+    ("\e$,1@L@m@F\e(B" . "\e$,47P\e(B") ;; ?
+
+    ("\e$,1@M\e(B" . "\e$,46@\e(B")
+
+    ("\e$,1@N\e(B" . "\e$,46A\e(B")
+    ("\e$,1@N@m@J\e(B" . "\e$,47<\e(B")
+    ("\e$,1@N@m@N\e(B" . "\e$,47=\e(B")
+    ("\e$,1@N@m@R\e(B" . "\e$,47>\e(B") ;; lakar
+
+    ("\e$,1@O\e(B" . "\e$,46B\e(B")
+    ("\e$,1@O@m@O\e(B" . "\e$,47?\e(B") ;; duplicate
+    ("\e$,1@O@m@5@m@5\e(B" . "\e$,47m\e(B") ;; ?
+
+    ("\e$,1@P\e(B" . "\e$,46C\e(B")
+    ("\e$,1@P@m\e(B" . "\e$,47@\e(B")
+
+    ("\e$,1@Q\e(B" . "\e$,46D\e(B")
+    ("\e$,1@Q@m\e(B" . "\e$,47@\e(B") ;; same glyph as "\e$,1@P@m\e(B"
+    ;;("\e$,1@Q@m@Q\e(B" . "\e$,47A\e(B")
+    ("\e$,1@Q@m@Q\e(B" . "\e$,47d\e(B")
+
+    ("\e$,1@R\e(B" . "\e$,46E\e(B")
+    ("\e$,1@R@m\e(B" . "\e$,47B\e(B")
+    ("\e$,1@R@m@R\e(B" . "\e$,47C\e(B") ;; lakar
+    ("\e$,1@R@m@J\e(B" . "\e$,47e\e(B") ;; ?
+
+    ("\e$,1@S\e(B" . "\e$,46F\e(B")
+    ("\e$,1@S@m\e(B" . "\e$,47D\e(B")
+    ("\e$,1@S@m@S\e(B" . "\e$,47E\e(B")
+
+    ("\e$,1@T\e(B" . "\e$,46G\e(B")
+    ("\e$,1@T@m\e(B" . "\e$,47D\e(B")
+
+    ("\e$,1@U\e(B" . "\e$,46H\e(B")
+    ("\e$,1@U@m@U\e(B" . "\e$,47F\e(B")
+
+    ("\e$,1@V\e(B" . "\e$,46I\e(B")
+    ("\e$,1@V@m@R\e(B" . "\e$,47G\e(B")
+    ("\e$,1@V@m@V\e(B" . "\e$,47H\e(B")
+    ("\e$,1@V@m@:\e(B" . "\e$,47]\e(B")
+
+    ("\e$,1@W\e(B" . "\e$,46J\e(B")
+    ("\e$,1@W@m@?\e(B" . "\e$,47c\e(B")
+
+    ("\e$,1@X\e(B" . "\e$,46K\e(B")
+    ("\e$,1@X@m@R\e(B" . "\e$,47I\e(B")
+    ("\e$,1@X@m@X\e(B" . "\e$,47J\e(B")
+    ("\e$,1@X@m@Q@m@Q\e(B" . "\e$,47L\e(B")
+    ("\e$,1@X@m@E\e(B" . "\e$,47X\e(B")
+
+    ("\e$,1@Y\e(B" . "\e$,46L\e(B")
+    ("\e$,1@Y@m@R\e(B" . "\e$,47K\e(B")
+    ("\e$,1@Y@m@N\e(B" . "\e$,47R\e(B")
+    ("\e$,1@Y@m@H\e(B" . "\e$,47S\e(B")
+
+    ;; Dependent vowel signs
+    ("\e$,1@^\e(B" . "\e$,46M\e(B")
+    ("\e$,1@_\e(B" . "\e$,46N\e(B")
+    ("\e$,1@`\e(B" . "\e$,46O\e(B")
+    ("\e$,1@a\e(B" . "\e$,46P\e(B")
+    ("\e$,1@b\e(B" . "\e$,46Q\e(B")
+    ("\e$,1@c\e(B" . "\e$,46R\e(B")
+    ("\e$,1@f\e(B" . "\e$,46S\e(B")
+    ("\e$,1@g\e(B" . "\e$,46T\e(B")
+    ("\e$,1@h\e(B" . "\e$,46S6S\e(B")
+    ("\e$,1@j\e(B" . "\e$,46S6M\e(B")
+    ("\e$,1@k\e(B" . "\e$,46T6M\e(B")
+    ("\e$,1@l\e(B" . "\e$,46U\e(B")
+    ;; Various signs
+    ("\e$,1@m\e(B" . "\e$,46V\e(B")
+    ("\e$,1@m@O\e(B" . "\e$,46Y\e(B") ;; yakar
+    ("\e$,1@m@O@a\e(B" . "\e$,46\\e(B") ;; yakar + u ;; ?
+    ("\e$,1@m@O@b\e(B" . "\e$,46]\e(B") ;; yakar + uu ;; ?
+    ("\e$,1@m@U\e(B" . "\e$,46Z\e(B") ;; vakar modifier
+    ("\e$,1@m@P\e(B" . "\e$,46[\e(B") ;; rakar modifier is the same to rra modifier.
+    ("\e$,1@m@Q\e(B" . "\e$,46[\e(B") ;; rrakar modifier
+    ("\e$,1@m@m\e(B" . "\e$,46V\e(B") ;; double omission sign to stop forming half consonant.
+    ("\e$,1@w\e(B" . "\e$,46U\e(B") ;; not in present use, already at 0D4C.
+    ))
+
+(defvar mlm-char-glyph-hash
+  (let* ((hash (make-hash-table :test 'equal)))
+    (mapc (function (lambda (x) (puthash (car x) (cdr x) hash)))
+         mlm-char-glyph)
+    hash))
+
+(defvar mlm-char-glyph-regexp
+  (malayalam-regexp-of-hashtbl-keys mlm-char-glyph-hash))
+
+;; Malayalam languages needed to be reordered in a complex mannar.
+
+(defvar mlm-consonants
+  (concat
+  "\e$,46)6*6+6,6-6.6/606162636465666768696:6;6<6=6>6?6@6A6B6C6D6E6F6G6H6I6J6K6L\e(B"
+  "\e$,47!7"7#7$7%7&7'7(7)7*7+7,7-7.7/707172737475767778797:7;7<7=7>7?7@7A7B7C7D7E7F7G7H7I7J7K7L7M7N7O7P7Q7R7S7T7U7V7W7X7Y7Z7[7\7]7^7_7`7a7b7c7d7e\e(B"
+  ))
+
+(defvar mlm-consonants-regexp
+  (concat "\\(\e$,46[\e(B?[" mlm-consonants "][\e$,46Y6Z\e(B]?\\)"))
+
+(defvar mlm-glyph-reorder-key-glyphs "[\e$,46[6S6T\e(B]")
+
+(defvar mlm-glyph-reordering-regexp-list
+  `((,(concat "\\([" mlm-consonants "][\e$,46Y6Z\e(B]?\\)\e$,46[\e(B") . "\e$,46[\e(B\\1")
+    (,(concat mlm-consonants-regexp "\e$,46S6S\e(B") . "\e$,46S6S\e(B\\1")
+    (,(concat mlm-consonants-regexp "\e$,46S\e(B") . "\e$,46S\e(B\\1")
+    (,(concat mlm-consonants-regexp "\e$,46T\e(B") . "\e$,46T\e(B\\1")))
+
+(defun malayalam-compose-syllable-string (string)
+  (with-temp-buffer
+    (insert (decompose-string string))
+    (malayalam-compose-syllable-region (point-min) (point-max))
+    (buffer-string)))
+
+(defun malayalam-compose-syllable-region (from to)
+  "Compose malayalam syllable in region FROM to TO."
+  (let (glyph-str
+       match-str
+       glyph-reorder-regexps
+       glyph-reorder-replace
+       glyph-reorder-regexp)
+    (save-excursion
+      (save-restriction
+        (narrow-to-region from to)
+        (goto-char (point-min))
+        ;; char-glyph-conversion
+        (while (re-search-forward mlm-char-glyph-regexp nil t)
+          (setq match-str (match-string 0))
+          (setq glyph-str
+                (concat glyph-str (gethash match-str mlm-char-glyph-hash))))
+        (when (string-match mlm-glyph-reorder-key-glyphs glyph-str)
+          ;; glyph reordering
+          (setq glyph-reorder-regexps mlm-glyph-reordering-regexp-list)
+          (while glyph-reorder-regexps
+            (setq glyph-reorder-regexp (caar glyph-reorder-regexps))
+            (setq glyph-reorder-replace (cdar glyph-reorder-regexps))
+            (setq glyph-reorder-regexps (cdr glyph-reorder-regexps))
+            (if (string-match glyph-reorder-regexp glyph-str)
+                (setq glyph-str
+                      (replace-match glyph-reorder-replace nil nil
+                                     glyph-str)))))
+        ;; concatenate and attach reference-points.
+        (setq glyph-str
+              (cdr
+               (apply
+                'nconc
+                (mapcar
+                 (function 
+                  (lambda (x) (list '(5 . 3) x))) ;; default ref. point.
+                 glyph-str))))
+        (compose-region from to glyph-str)))))
+
+(provide 'mlm-util)
+
+;;; devan-util.el ends here
diff --git a/lisp/language/tamil.el b/lisp/language/tamil.el
new file mode 100644 (file)
index 0000000..dfa1cdb
--- /dev/null
@@ -0,0 +1,43 @@
+;;; tamil.el --- Support for Tamil -*- coding: iso-2022-7bit; no-byte-compile: t -*-
+
+;; Copyright (C) 2003 Free Software Foundation, Inc.
+
+;; Maintainer: KAWABATA, Taichi <batta@beige.ocn.ne.jp>
+;; Keywords: multilingual, Indian, Tamil
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; This file defines language-info of Tamil script.
+
+;;; Code:
+
+(set-language-info-alist
+ "Tamil" '((charset mule-unicode-0100-24ff indian-glyph )
+               (coding-system utf-8)
+               (coding-priority utf-8)
+               (input-method . "tamil-itrans")
+               (features tml-util)
+               (documentation . "\
+South Indian Language Tamikl supported in this language environment."))
+ '("Indian"))
+
+(provide 'tamil)
+
+;;; tamil.el ends here
diff --git a/lisp/language/tml-util.el b/lisp/language/tml-util.el
new file mode 100644 (file)
index 0000000..bb8c8f1
--- /dev/null
@@ -0,0 +1,367 @@
+;;; tml-util.el --- support for composing tamil characters  -*-coding: iso-2022-7bit;-*-
+
+;; Copyright (C) 2001 Free Software Foundation, Inc.
+
+;; Maintainer: KAWABATA, Taichi <kawabata@m17n.org>
+;; Keywords: multilingual, Indian, Tamil
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; Created: Nov. 08. 2002
+
+;;; Commentary:
+
+;; This file provides character(Unicode) to glyph(CDAC) conversion and
+;; composition of Tamil script characters.
+
+;;; Code:
+
+;; Tamil Composable Pattern
+;;    C .. Consonants
+;;    V .. Vowel
+;;    H .. Pulli
+;;    M .. Matra
+;;    V .. Vowel
+;;    A .. Anuswar
+;;    D .. Chandrabindu
+;; 1. vowel
+;;  V
+;; 2. syllable : only ligature-formed pattern forms composition.
+;;  (CkHCs|C)(H|M)?
+;; 3. sri special
+;;  (CsHCrVi)
+
+;;  oririnal
+;;  ((CH)?(CH)?(CH)?CH)?C(H|M?(A|D)?)?
+
+(defconst tamil-consonant
+  "[\e$,1<5\e(B-\e$,1<Y\e(B]")
+
+(defconst tamil-composable-pattern
+  (concat
+   "\\([\e$,1<%\e(B-\e$,1<4\e(B]\\)\\|"
+   "[\e$,1<"<#\e(B]\\|" ;; vowel modifier considered independent
+   "\\(\\(?:\\(?:\e$,1<5<m<W\e(B\\)\\|[\e$,1<5\e(B-\e$,1<Y\e(B]\\)[\e$,1<m<^\e(B-\e$,1<l\e(B]?\\)\\|"
+   "\\(\e$,1<W<m<P<`\e(B\\)")
+  "Regexp matching a composable sequence of Tamil characters.")
+
+;;;###autoload
+(defun tamil-compose-region (from to)
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region from to)
+      (goto-char (point-min))
+      (while (re-search-forward tamil-composable-pattern nil t)
+       (tamil-compose-syllable-region (match-beginning 0)
+                                           (match-end 0))))))
+(defun tamil-compose-string (string)
+  (with-temp-buffer
+    (insert (decompose-string string))
+    (tamil-compose-region (point-min) (point-max))
+    (buffer-string)))
+
+(defun tamil-post-read-conversion (len)
+  (save-excursion
+    (save-restriction
+      (let ((buffer-modified-p (buffer-modified-p)))
+       (narrow-to-region (point) (+ (point) len))
+       (tamil-compose-region (point-min) (point-max))
+       (set-buffer-modified-p buffer-modified-p)
+       (- (point-max) (point-min))))))
+
+(defun tamil-range (from to)
+  "Make the list of the integers of range FROM to TO."
+  (let (result)
+    (while (<= from to) (setq result (cons to result) to (1- to))) result))
+
+(defun tamil-regexp-of-hashtbl-keys (hashtbl)
+  "Return a regular expression that matches all keys in hashtable HASHTBL."
+  (let ((max-specpdl-size 1000))
+    (regexp-opt
+     (sort
+      (let (dummy)
+       (maphash (function (lambda (key val) (setq dummy (cons key dummy)))) hashtbl)
+       dummy)
+      (function (lambda (x y) (> (length x) (length y))))))))
+
+
+;;;###autoload
+(defun tamil-composition-function (from to pattern  &optional string)
+  "Compose Tamil characters in REGION, or STRING if specified.
+Assume that the REGION or STRING must fully match the composable 
+PATTERN regexp."
+  (if string (tamil-compose-syllable-string string)
+    (tamil-compose-syllable-region from to))
+  (- to from))
+
+;; Register a function to compose Tamil characters.
+(mapc
+ (function (lambda (ucs)
+   (aset composition-function-table (decode-char 'ucs ucs)
+        (list (cons tamil-composable-pattern
+                     'tamil-composition-function)))))
+ (nconc '(#x0b82 #x0b83) (tamil-range #x0b85 #x0bb9)))
+
+;; Notes on conversion steps.
+
+;; 1. chars to glyphs
+;; Simple replacement of characters to glyphs is done.
+
+;; 2. glyphs reordering.
+;; following "\e$,4)j\e(B", "\e$,4)k\e(B", "\e$,4)l\e(B" goes to the front.
+
+;; 3. glyphs to glyphs
+;; reordered vowels are ligatured to consonants.
+
+;; 4. Composition.
+;; left modifiers will be attached at the left.
+;; others will be attached right.
+
+(defvar tml-char-glyph
+  '(;; various signs
+    ;;("\e$,1<"\e(B" . "")
+    ("\e$,1<#\e(B" . "\e$,4*G\e(B")
+    ;; Independent Vowels
+    ("\e$,1<%\e(B" . "\e$,4*<\e(B")
+    ("\e$,1<&\e(B" . "\e$,4*=\e(B")
+    ("\e$,1<'\e(B" . "\e$,4*>\e(B")
+    ("\e$,1<(\e(B" . "\e$,4*?\e(B")
+    ("\e$,1<)\e(B" . "\e$,4*@\e(B")
+    ("\e$,1<*\e(B" . "\e$,4*A\e(B")
+    ("\e$,1<.\e(B" . "\e$,4*B\e(B")
+    ("\e$,1</\e(B" . "\e$,4*C\e(B")
+    ("\e$,1<0\e(B" . "\e$,4*D\e(B")
+    ("\e$,1<2\e(B" . "\e$,4*E\e(B")
+    ("\e$,1<3\e(B" . "\e$,4*F\e(B")
+    ("\e$,1<4\e(B" . "\e$,4*E*W\e(B")
+    ;; Consonants
+    ("\e$,1<5<m<W<m\e(B" . "\e$,4):\e(B")  ; ks.
+    ("\e$,1<5<m<W\e(B" . "\e$,4*^\e(B")    ; ks
+    ("\e$,1<5\e(B" . "\e$,4*H\e(B")
+
+    ("\e$,1<9\e(B" . "\e$,4*I\e(B")
+    ("\e$,1<:\e(B" . "\e$,4*J\e(B")
+    ("\e$,1<<\e(B" . "\e$,4*\\e(B")
+    ("\e$,1<<<m\e(B" . "\e$,4)8\e(B")
+    ("\e$,1<>\e(B" . "\e$,4*K\e(B")
+    ("\e$,1<?\e(B" . "\e$,4*L\e(B")
+    ("\e$,1<C\e(B" . "\e$,4*M\e(B")
+    ("\e$,1<D\e(B" . "\e$,4*N\e(B")
+    ("\e$,1<H\e(B" . "\e$,4*O\e(B")
+    ("\e$,1<I\e(B" . "\e$,4*Y\e(B")
+    ("\e$,1<I<m\e(B" . "\e$,4)a\e(B")
+    ("\e$,1<J\e(B" . "\e$,4*P\e(B")
+    ("\e$,1<N\e(B" . "\e$,4*Q\e(B")
+    ("\e$,1<O\e(B" . "\e$,4*R\e(B")
+    ("\e$,1<P\e(B" . "\e$,4*S\e(B")
+    ("\e$,1<Q\e(B" . "\e$,4*X\e(B")
+    ("\e$,1<R\e(B" . "\e$,4*T\e(B")
+    ("\e$,1<S\e(B" . "\e$,4*W\e(B")
+    ("\e$,1<T\e(B" . "\e$,4*V\e(B")
+    ("\e$,1<U\e(B" . "\e$,4*U\e(B")
+    ("\e$,1<W\e(B" . "\e$,4*[\e(B")
+    ("\e$,1<W<m\e(B" . "\e$,4)7\e(B")
+    ("\e$,1<W<m<P<`\e(B" . "\e$,4*_\e(B")
+    ("\e$,1<X\e(B" . "\e$,4*Z\e(B")
+    ("\e$,1<X<m\e(B" . "\e$,4)6\e(B")
+    ("\e$,1<Y\e(B" . "\e$,4*]\e(B")
+    ("\e$,1<Y<m\e(B" . "\e$,4)9\e(B")
+
+    ;; Dependent vowel signs
+    ("\e$,1<^\e(B" . "\e$,4)c\e(B")
+    ("\e$,1<_\e(B" . "\e$,4)d\e(B")
+    ("\e$,1<`\e(B" . "\e$,4)f\e(B")
+    ("\e$,1<a\e(B" . "\e$,4)g\e(B")
+    ("\e$,1<b\e(B" . "\e$,4)h\e(B")
+    ("\e$,1<f\e(B" . "\e$,4)j\e(B")
+    ("\e$,1<g\e(B" . "\e$,4)k\e(B")
+    ("\e$,1<h\e(B" . "\e$,4)l\e(B")
+    ("\e$,1<j\e(B" . "\e$,4)j)c\e(B")
+    ("\e$,1<k\e(B" . "\e$,4)k)c\e(B")
+    ("\e$,1<l\e(B" . "\e$,4)j*W\e(B")
+
+    ;; Various signs
+    ("\e$,1<m\e(B" . "\e$,4)b\e(B")
+    ("\e$,1<w\e(B" . "nil") ;; not supported?
+    ))
+
+(defvar tml-char-glyph-hash
+  (let* ((hash (make-hash-table :test 'equal)))
+    (mapc (function (lambda (x) (puthash (car x) (cdr x) hash)))
+         tml-char-glyph)
+    hash))
+
+(defvar tml-char-glyph-regexp
+  (tamil-regexp-of-hashtbl-keys tml-char-glyph-hash))
+
+;; Tamil languages needed to be reordered.
+
+(defvar tml-consonants-regexp
+  "[\e$,4*H*^*I*J*\*K*L*M*N*O*Y*P*Q*R*S*X*T*W*V*U*[*Z*]\e(B]")
+
+(defvar tml-glyph-reorder-key-glyphs "[\e$,4)j)k)l\e(B]")
+
+(defvar tml-glyph-reordering-regexp-list
+  (cons
+   (concat "\\(" tml-consonants-regexp "\\)\\([\e$,4)j)k)l\e(B]\\)") "\\2\\1"))
+
+;; Tamil vowel modifiers to be ligatured.
+(defvar tml-glyph-glyph
+  '(
+    ("\e$,4*H)d\e(B" . "\e$,4(a\e(B")      ; ki
+    ("\e$,4*^)d\e(B" . "\e$,4(v\e(B")      ; ksi
+    ("\e$,4*^)f\e(B" . "\e$,4)2\e(B")      ; ksi~
+    ("\e$,4*I)d\e(B" . "\e$,4(b\e(B")      ; n^i
+    ("\e$,4*J)d\e(B" . "\e$,4(c\e(B")      ; ci
+    ("\e$,4*K)d\e(B" . "\e$,4(d\e(B")      ; n~i
+    ("\e$,4*L)d\e(B" . "\e$,4)n\e(B")      ; t.i
+    ("\e$,4*M)d\e(B" . "\e$,4(e\e(B")      ; n.i
+    ("\e$,4*N)d\e(B" . "\e$,4(f\e(B")      ; ti
+    ("\e$,4*O)d\e(B" . "\e$,4(g\e(B")      ; ni
+    ("\e$,4*P)d\e(B" . "\e$,4(h\e(B")      ; pi
+    ("\e$,4*Q)d\e(B" . "\e$,4(i\e(B")      ; mi
+    ("\e$,4*R)d\e(B" . "\e$,4(j\e(B")      ; yi
+    ("\e$,4*S)d\e(B" . "\e$,4(k\e(B")      ; ri
+    ("\e$,4*T)d\e(B" . "\e$,4(l\e(B")      ; li
+    ("\e$,4*U)d\e(B" . "\e$,4(m\e(B")      ; vi
+    ("\e$,4*V)d\e(B" . "\e$,4(n\e(B")      ; l_i
+    ("\e$,4*W)d\e(B" . "\e$,4(o\e(B")      ; l.i
+    ("\e$,4*X)d\e(B" . "\e$,4(p\e(B")      ; r_i
+    ("\e$,4*Y)d\e(B" . "\e$,4(q\e(B")      ; n_i
+    ("\e$,4*Z)d\e(B" . "\e$,4(r\e(B")      ; si
+    ("\e$,4*[)d\e(B" . "\e$,4(s\e(B")      ; s'i
+    ("\e$,4*\)d\e(B" . "\e$,4(t\e(B")      ; ji
+    ("\e$,4*])d\e(B" . "\e$,4(u\e(B")      ; hi
+
+    ("\e$,4*H)f\e(B" . "\e$,4(w\e(B")      ; ki~
+    ("\e$,4*I)f\e(B" . "\e$,4(x\e(B")      ; n^i~
+    ("\e$,4*J)f\e(B" . "\e$,4(y\e(B")      ; ci~
+    ("\e$,4*K)f\e(B" . "\e$,4(z\e(B")      ; n~i~
+    ("\e$,4*L)f\e(B" . "\e$,4)o\e(B")      ; t.i~
+    ("\e$,4*M)f\e(B" . "\e$,4)!\e(B")      ; n.i~
+    ("\e$,4*N)f\e(B" . "\e$,4)"\e(B")      ; ti~
+    ("\e$,4*O)f\e(B" . "\e$,4)#\e(B")      ; ni~
+    ("\e$,4*P)f\e(B" . "\e$,4)$\e(B")      ; pi~
+    ("\e$,4*Q)f\e(B" . "\e$,4)%\e(B")      ; mi~
+    ("\e$,4*R)f\e(B" . "\e$,4)&\e(B")      ; yi~
+    ("\e$,4*S)f\e(B" . "\e$,4)'\e(B")      ; ri~
+    ("\e$,4*T)f\e(B" . "\e$,4)(\e(B")      ; li~
+    ("\e$,4*U)f\e(B" . "\e$,4))\e(B")      ; vi~
+    ("\e$,4*V)f\e(B" . "\e$,4)*\e(B")      ; l_i~
+    ("\e$,4*W)f\e(B" . "\e$,4)+\e(B")      ; l.i~
+    ("\e$,4*X)f\e(B" . "\e$,4),\e(B")      ; r_i~
+    ("\e$,4*Y)f\e(B" . "\e$,4)-\e(B")      ; n_i~
+    ("\e$,4*Z)f\e(B" . "\e$,4).\e(B")      ; si~
+    ("\e$,4*[)f\e(B" . "\e$,4)/\e(B")      ; s'i~
+    ("\e$,4*\)f\e(B" . "\e$,4)0\e(B")      ; ji~
+    ("\e$,4*])f\e(B" . "\e$,4)1\e(B")      ; hi~
+
+    ("\e$,4*H)g\e(B" . "\e$,4)p\e(B")      ; ku
+    ("\e$,4*I)g\e(B" . "\e$,4)q\e(B")      ; n^u
+    ("\e$,4*J)g\e(B" . "\e$,4)r\e(B")      ; cu
+    ("\e$,4*K)g\e(B" . "\e$,4)s\e(B")      ; n~u
+    ("\e$,4*L)g\e(B" . "\e$,4)t\e(B")      ; t.u
+    ("\e$,4*M)g\e(B" . "\e$,4)u\e(B")      ; n.u
+    ("\e$,4*N)g\e(B" . "\e$,4)v\e(B")      ; tu
+    ("\e$,4*O)g\e(B" . "\e$,4)x\e(B")      ; nu
+    ("\e$,4*P)g\e(B" . "\e$,4)y\e(B")      ; pu
+    ("\e$,4*Q)g\e(B" . "\e$,4)z\e(B")      ; mu
+    ("\e$,4*R)g\e(B" . "\e$,4){\e(B")      ; yu
+    ("\e$,4*S)g\e(B" . "\e$,4)|\e(B")      ; ru
+    ("\e$,4*T)g\e(B" . "\e$,4)}\e(B")      ; lu
+    ("\e$,4*U)g\e(B" . "\e$,4)~\e(B")      ; vu
+    ("\e$,4*V)g\e(B" . "\e$,4)\7f\e(B")      ; l_u
+    ("\e$,4*W)g\e(B" . "\e$,4* \e(B")      ; l.u
+    ("\e$,4*X)g\e(B" . "\e$,4*!\e(B")      ; r_u
+    ("\e$,4*Y)g\e(B" . "\e$,4*"\e(B")      ; n_u
+
+    ("\e$,4*H)h\e(B" . "\e$,4*#\e(B")      ; ku~
+    ("\e$,4*I)h\e(B" . "\e$,4*$\e(B")      ; n^u~
+    ("\e$,4*J)h\e(B" . "\e$,4*%\e(B")      ; cu~
+    ("\e$,4*K)h\e(B" . "\e$,4*&\e(B")      ; n~u~
+    ("\e$,4*L)h\e(B" . "\e$,4*'\e(B")      ; t.u~
+    ("\e$,4*M)h\e(B" . "\e$,4*(\e(B")      ; n.u~
+    ("\e$,4*N)h\e(B" . "\e$,4*)\e(B")      ; tu~
+    ("\e$,4*O)h\e(B" . "\e$,4*+\e(B")      ; nu~
+    ("\e$,4*P)h\e(B" . "\e$,4*,\e(B")      ; pu~
+    ("\e$,4*Q)h\e(B" . "\e$,4*-\e(B")      ; mu~
+    ("\e$,4*R)h\e(B" . "\e$,4*.\e(B")      ; yu~
+    ("\e$,4*S)h\e(B" . "\e$,4*/\e(B")      ; ru~
+    ("\e$,4*T)h\e(B" . "\e$,4*6\e(B")      ; lu~
+    ("\e$,4*U)h\e(B" . "\e$,4*7\e(B")      ; vu~
+    ("\e$,4*V)h\e(B" . "\e$,4*8\e(B")      ; l_u~
+    ("\e$,4*W)h\e(B" . "\e$,4*9\e(B")      ; l.u~
+    ("\e$,4*X)h\e(B" . "\e$,4*:\e(B")      ; r_u~
+    ("\e$,4*Y)h\e(B" . "\e$,4*;\e(B")      ; n_u~
+    ))
+
+(defvar tml-glyph-glyph-hash
+  (let* ((hash (make-hash-table :test 'equal)))
+    (mapc (function (lambda (x) (puthash (car x) (cdr x) hash)))
+         tml-glyph-glyph)
+    hash))
+
+(defvar tml-glyph-glyph-regexp
+  (tamil-regexp-of-hashtbl-keys tml-glyph-glyph-hash))
+
+(defun tamil-compose-syllable-string (string)
+  (with-temp-buffer
+    (insert (decompose-string string))
+    (tamil-compose-syllable-region (point-min) (point-max))
+    (buffer-string)))
+
+(defun tamil-compose-syllable-region (from to)
+  "Compose tamil syllable in region FROM to TO."
+  (let (glyph-str match-str glyph-reorder-regexps)
+    (save-excursion
+      (save-restriction
+        (narrow-to-region from to)
+        (goto-char (point-min))
+        ;; char-glyph-conversion
+        (while (re-search-forward tml-char-glyph-regexp nil t)
+          (setq match-str (match-string 0))
+          (setq glyph-str
+                (concat glyph-str (gethash match-str tml-char-glyph-hash))))
+        ;; glyph reordering
+        (when (string-match tml-glyph-reorder-key-glyphs glyph-str)
+          (if (string-match (car tml-glyph-reordering-regexp-list)
+                            glyph-str)
+              (setq glyph-str
+                    (replace-match (cdr tml-glyph-reordering-regexp-list)
+                                   nil nil glyph-str))))
+        ;; glyph-glyph-conversion
+        (when (string-match tml-glyph-glyph-regexp glyph-str)
+          (setq match-str (match-string 0 glyph-str))
+          (setq glyph-str 
+                (replace-match (gethash match-str tml-glyph-glyph-hash)
+                               nil nil glyph-str)))
+        ;; concatenate and attach reference-points.
+        (setq glyph-str
+              (cdr
+               (apply
+                'nconc
+                (mapcar
+                 (function 
+                  (lambda (x) (list '(5 . 3) x))) ;; default ref. point.
+                 glyph-str))))
+        (compose-region from to glyph-str)))))
+
+(provide 'tml-util)
+
+;;; tml-util.el ends here