-;;; 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.
;;; 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")
(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.
(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