]> code.delx.au - gnu-emacs/blobdiff - lisp/language/devan-util.el
Merge from emacs--devo--0
[gnu-emacs] / lisp / language / devan-util.el
index b25e90cebe9cebd7287c3d5e933bc9ff79ea1b3f..b236a95e3b466645dcb205cd105719b547d22006 100644 (file)
@@ -1,4 +1,4 @@
-;;; devan-util.el --- Support for composing Devanagari characters
+;;; devan-util.el --- Support for composing Devanagari characters -*-coding: iso-2022-7bit;-*-
 
 ;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006, 2007
 ;;   Free Software Foundation, Inc.
@@ -35,8 +35,6 @@
 
 ;;; Code:
 
-;;;###autoload
-
 ;; Devanagari Composable Pattern
 ;;    C .. Consonants
 ;;    V .. Vowel
 (defconst devanagari-consonant
   "[\e$,15U\e(B-\e$,15y68\e(B-\e$,16?\e(B]")
 
+    ;;("\e$,16B\e(B" . nil)
+    ;;("\e$,16A\e(B" . nil)
+    ;;("\e$,16C\e(B" . nil)
+
+
 (defconst devanagari-composable-pattern
   (concat
    "\\([\e$,15E\e(B-\e$,15T6@6A\e(B][\e$,15A5B\e(B]?\\)\\|[\e$,15C6D\e(B]"
    "\\)")
   "Regexp matching a composable sequence of Devanagari characters.")
 
+(dolist (range '((#x0903 . #x0903)
+                (#x0905 . #x0939)
+                (#x0958 . #x0961)))
+  (set-char-table-range indian-composable-pattern range
+                       devanagari-composable-pattern))
+
 ;;;###autoload
 (defun devanagari-compose-region (from to)
   (interactive "r")
@@ -72,8 +81,8 @@
       (narrow-to-region from to)
       (goto-char (point-min))
       (while (re-search-forward devanagari-composable-pattern nil t)
-        (devanagari-compose-syllable-region (match-beginning 0)
-                                            (match-end 0))))))
+       (devanagari-compose-syllable-region (match-beginning 0)
+                                           (match-end 0))))))
 (defun devanagari-compose-string (string)
   (with-temp-buffer
     (insert (decompose-string string))
        (set-buffer-modified-p buffer-modified-p)
        (- (point-max) (point-min))))))
 
-(defun devanagari-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 devanagari-regexp-of-hashtbl-keys (hashtbl)
   "Return a regular expression that matches all keys in hashtable HASHTBL."
   (let ((max-specpdl-size 1000))
        dummy)
       (function (lambda (x y) (> (length x) (length y))))))))
 
-(defun devanagari-composition-function (from to pattern &optional string)
-  "Compose Devanagari characters in REGION, or STRING if specified.
-Assume that the REGION or STRING must fully match the composable
-PATTERN regexp."
-  (if string (devanagari-compose-syllable-string string)
-    (devanagari-compose-syllable-region from to))
-  (- to from))
-
-;; Register a function to compose Devanagari characters.
-(mapc
- (function (lambda (ucs)
-   (aset composition-function-table (decode-char 'ucs ucs)
-        (list (cons devanagari-composable-pattern
-                     'devanagari-composition-function)))))
- (nconc '(#x0903) (devanagari-range #x0905 #x0939) (devanagari-range #x0958 #x0961)))
+;;;###autoload
+(defun devanagari-composition-function (pos &optional string)
+  "Compose Devanagari characters after the position POS.
+If STRING is not nil, it is a string, and POS is an index to the string.
+In this case, compose characters after POS of the string."
+  (if string
+      ;; Not yet implemented.
+      nil
+    (goto-char pos)
+    (if (looking-at devanagari-composable-pattern)
+       (prog1 (match-end 0)
+         (devanagari-compose-syllable-region pos (match-end 0))))))
 
 ;; Notes on conversion steps.
 
@@ -496,11 +497,10 @@ preferred rule from the sanskrit fonts."  )
 (defvar dev-glyph-glyph-2-regexp
   (devanagari-regexp-of-hashtbl-keys dev-glyph-glyph-2-hash))
 
-
 (defun dev-charseq (from &optional to)
   (if (null to) (setq to from))
-  (mapcar (function (lambda (x) (indian-glyph-char x 'devanagari)))
-          (devanagari-range from to)))
+  (number-sequence (decode-char 'devanagari-cdac from)
+                  (decode-char 'devanagari-cdac to)))
 
 (defvar dev-glyph-cvn
   (append