aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1998-02-04 11:25:01 +0000
committerKenichi Handa1998-02-04 11:25:01 +0000
commit27463edec5045d1b178abbdd5617994cfad08c60 (patch)
tree0cdb82ef8576c3f8a220f373c2c5ac90595aa8e6
parent39e0da627d03096c30d9524bcbc711bf15736419 (diff)
downloademacs-27463edec5045d1b178abbdd5617994cfad08c60.tar.gz
emacs-27463edec5045d1b178abbdd5617994cfad08c60.zip
Do not require `cl'.
(rule-intersection): New function. (string-conversion-by-rule): Use rule-intersection instead of intersection. (indian-to-devanagari-string): Use aref instead of sref. (devanagari-decompose-string): Likewise.
-rw-r--r--lisp/language/devan-util.el63
1 files changed, 33 insertions, 30 deletions
diff --git a/lisp/language/devan-util.el b/lisp/language/devan-util.el
index c811e62fb64..9fd644bcbe5 100644
--- a/lisp/language/devan-util.el
+++ b/lisp/language/devan-util.el
@@ -41,9 +41,6 @@
41;;; Steps toward composition of Devanagari Characters. 41;;; Steps toward composition of Devanagari Characters.
42;;; 42;;;
43 43
44;;; Intersection Function will be used.
45(require 'cl)
46
47;;;###autoload 44;;;###autoload
48(defun setup-devanagari-environment () 45(defun setup-devanagari-environment ()
49 "Setup multilingual environment (MULE) for languages using Devanagari." 46 "Setup multilingual environment (MULE) for languages using Devanagari."
@@ -100,12 +97,13 @@
100;;;###autoload 97;;;###autoload
101(defun indian-to-devanagari-string (str) 98(defun indian-to-devanagari-string (str)
102 "Convert Indian String to Devanagari Basic Character String." 99 "Convert Indian String to Devanagari Basic Character String."
103 (let ((pos 0) (dst "") (src str) char) 100 (let* ((len (length str))
104 (while (not (equal src "")) 101 (i 0)
105 (setq char (string-to-char src)) 102 (vec (make-vector len 0)))
106 (setq src (substring src (char-bytes char))) 103 (while (< i len)
107 (setq dst (concat dst (char-to-string (indian-to-devanagari char))))) 104 (aset vec i (indian-to-devanagari (aref str i)))
108 dst)) 105 (setq i (1+ i)))
106 (concat vec)))
109 107
110;; Phase 0 - Determine whether the characters can be composed. 108;; Phase 0 - Determine whether the characters can be composed.
111;; 109;;
@@ -262,8 +260,8 @@ of '$(5!*!&!'(B' and nukta sign.")
262;; 260;;
263;; Compose the glyph. 261;; Compose the glyph.
264;; 262;;
265;; => 2$(6!X@![1(B/2$(6!D@"FP!\1(B 263;; => 2$(6!X@![(B1/2$(6!D@"FP!\(B1
266;; => 2$(6!X@![12!D@"FP!\1(B 264;; => 2$(6!X@![(B12$(6!D@"FP!\(B1
267;; 265;;
268 266
269;; 267;;
@@ -562,9 +560,9 @@ of '$(5!*!&!'(B' and nukta sign.")
562;; 560;;
563 561
564(defun max-match-len (regexp-str) 562(defun max-match-len (regexp-str)
565 "This returns the possible length of matched string of given regexp. 563 "Return the possible length of matched string of given regexp.
566 Only [...] pattern of regexp is recognized. The last character of 564Only [...] pattern of regexp is recognized.
567 inside of [....] is used for its length." 565The last character of inside of [....] is used for its length."
568 (let ((dest-str regexp-str)) 566 (let ((dest-str regexp-str))
569 (while (string-match "\\[\\([^\]]\\)+\\]" dest-str) 567 (while (string-match "\\[\\([^\]]\\)+\\]" dest-str)
570 (setq dest-str 568 (setq dest-str
@@ -573,8 +571,17 @@ of '$(5!*!&!'(B' and nukta sign.")
573 (substring dest-str (match-end 0))))) 571 (substring dest-str (match-end 0)))))
574 (length dest-str))) 572 (length dest-str)))
575 573
574;; Return t iff LIST1 and LIST2 has a same member.
575(defun rule-intersection (list1 list2)
576 (let ((found nil))
577 (while (and list1 (not found))
578 (if (memq (car list1) list2)
579 (setq found t)
580 (setq list1 (cdr list1))))
581 found))
582
576(defun string-conversion-by-rule (src-str symbol &rest specs) 583(defun string-conversion-by-rule (src-str symbol &rest specs)
577 " This function converts the SRC-STR to the new string according to 584 "Convert string SRC-STR to a new string according to
578the rules described in the each character's SYMBOL property. The 585the rules described in the each character's SYMBOL property. The
579rules are described in the forms of '((regexp str <specs>) ...), and 586rules are described in the forms of '((regexp str <specs>) ...), and
580the character sequence in the string which matches to 'regexp' are 587the character sequence in the string which matches to 'regexp' are
@@ -602,7 +609,7 @@ subject of the match."
602 (rule-specs (cdr (cdr rule))) 609 (rule-specs (cdr (cdr rule)))
603 search-pos) 610 search-pos)
604 (if (not (or (null rule-specs) 611 (if (not (or (null rule-specs)
605 (intersection specs rule-specs))) 612 (rule-intersection specs rule-specs)))
606 (setq rules (cdr rules)) 613 (setq rules (cdr rules))
607 (if (null (string-match "\\\\(.+\\\\)" regexp)) 614 (if (null (string-match "\\\\(.+\\\\)" regexp))
608 (progn 615 (progn
@@ -625,10 +632,8 @@ subject of the match."
625 (setq rules (cdr rules)))))) 632 (setq rules (cdr rules))))))
626 ;; proceed to next position 633 ;; proceed to next position
627 (if (not found) 634 (if (not found)
628 (let ((nextchar (string-to-char (substring src-str pos)))) 635 (setq dst-str (concat dst-str (substring src-str pos (1+ pos)))
629 (setq pos (+ pos 636 pos (1+ pos)))))
630 (char-bytes (string-to-char (substring src-str pos)))))
631 (setq dst-str (concat dst-str (char-to-string nextchar)))))))
632 dst-str)) 637 dst-str))
633 638
634 639
@@ -1050,7 +1055,7 @@ Ligatures and special rules are processed."
1050 (append ordered-glyphs (list (assq glyph devanagari-composition-rules)))))) 1055 (append ordered-glyphs (list (assq glyph devanagari-composition-rules))))))
1051 (sort ordered-glyphs '(lambda (x y) (< (car (cdr x)) (car (cdr y))))))) 1056 (sort ordered-glyphs '(lambda (x y) (< (car (cdr x)) (car (cdr y)))))))
1052 1057
1053;;(devanagari-compose-to-one-glyph "$(5"5!X![(B") => "2$(6!XP"5@![1(B" 1058;;(devanagari-compose-to-one-glyph "$(5"5!X![(B") => "2$(6!XP"5@![(B1"
1054 1059
1055(defun devanagari-compose-to-one-glyph (devanagari-string) 1060(defun devanagari-compose-to-one-glyph (devanagari-string)
1056 (let* ((o-glyph-list (devanagari-reorder-glyphs-for-composition 1061 (let* ((o-glyph-list (devanagari-reorder-glyphs-for-composition
@@ -1190,15 +1195,13 @@ Ligatures and special rules are processed."
1190 1195
1191;;;###autoload 1196;;;###autoload
1192(defun devanagari-decompose-string (str) 1197(defun devanagari-decompose-string (str)
1193 "This function Decomposes Devanagari glyph string to 1198 "Decompose Devanagari glyph string STR to basic Devanagari character string."
1194basic Devanagari character string." 1199 (let ((len (length str))
1195 (let ((src str) (dst "")) 1200 (i 0)
1196 (while (not (equal src "")) 1201 (dst ""))
1197 (let* ((char (string-to-char src)) 1202 (while (< i len)
1198 (clen (char-bytes char))) 1203 (setq dst (concat dst (devanagari-decompose-char (aref str i)))
1199 (setq src (substring src clen)) 1204 i (1+ i)))
1200 (setq dst (concat dst
1201 (devanagari-decompose-char char)))))
1202 dst)) 1205 dst))
1203 1206
1204;;;###autoload 1207;;;###autoload