diff options
| author | Kenichi Handa | 2003-09-17 06:41:36 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-09-17 06:41:36 +0000 |
| commit | 51f54e789960e204de6b2b219bc017331cdb9dd9 (patch) | |
| tree | a8ff22d701db4cc58bb21beb78d13a47be1e0417 | |
| parent | 2ccf3102d2ebc6f60838c80cb44b5557851c2168 (diff) | |
| download | emacs-51f54e789960e204de6b2b219bc017331cdb9dd9.tar.gz emacs-51f54e789960e204de6b2b219bc017331cdb9dd9.zip | |
(devanagari-post-read-conversion): Add autoload cookie.
| -rw-r--r-- | lisp/language/devan-util.el | 153 |
1 files changed, 77 insertions, 76 deletions
diff --git a/lisp/language/devan-util.el b/lisp/language/devan-util.el index bef403fc074..20bcffdad49 100644 --- a/lisp/language/devan-util.el +++ b/lisp/language/devan-util.el | |||
| @@ -75,6 +75,7 @@ | |||
| 75 | (devanagari-compose-region (point-min) (point-max)) | 75 | (devanagari-compose-region (point-min) (point-max)) |
| 76 | (buffer-string))) | 76 | (buffer-string))) |
| 77 | 77 | ||
| 78 | ;;;###autoload | ||
| 78 | (defun devanagari-post-read-conversion (len) | 79 | (defun devanagari-post-read-conversion (len) |
| 79 | (save-excursion | 80 | (save-excursion |
| 80 | (save-restriction | 81 | (save-restriction |
| @@ -564,84 +565,84 @@ preferred rule from the sanskrit fonts." ) | |||
| 564 | (defun devanagari-compose-syllable-region (from to) | 565 | (defun devanagari-compose-syllable-region (from to) |
| 565 | "Compose devanagari syllable in region FROM to TO." | 566 | "Compose devanagari syllable in region FROM to TO." |
| 566 | (let ((glyph-str nil) (cons-num 0) glyph-str-list | 567 | (let ((glyph-str nil) (cons-num 0) glyph-str-list |
| 567 | (last-halant nil) (preceding-r nil) (last-modifier nil) | 568 | (last-halant nil) (preceding-r nil) (last-modifier nil) |
| 568 | (last-char (char-before to)) match-str | 569 | (last-char (char-before to)) match-str |
| 569 | glyph-block split-pos) | 570 | glyph-block split-pos) |
| 570 | (save-excursion | 571 | (save-excursion |
| 571 | (save-restriction | 572 | (save-restriction |
| 572 | ;;; *** char-to-glyph conversion *** | 573 | ;;; *** char-to-glyph conversion *** |
| 573 | ;; Special rule 1. -- Last halant must be preserved. | 574 | ;; Special rule 1. -- Last halant must be preserved. |
| 574 | (if (eq last-char ?$,16-(B) | 575 | (if (eq last-char ?$,16-(B) |
| 575 | (progn | 576 | (progn |
| 576 | (setq last-halant t) | 577 | (setq last-halant t) |
| 577 | (narrow-to-region from (1- to))) | 578 | (narrow-to-region from (1- to))) |
| 578 | (narrow-to-region from to) | 579 | (narrow-to-region from to) |
| 579 | ;; note if the last char is modifier. | 580 | ;; note if the last char is modifier. |
| 580 | (if (or (eq last-char ?$,15A(B) (eq last-char ?$,15B(B)) | 581 | (if (or (eq last-char ?$,15A(B) (eq last-char ?$,15B(B)) |
| 581 | (setq last-modifier t))) | 582 | (setq last-modifier t))) |
| 582 | (goto-char (point-min)) | 583 | (goto-char (point-min)) |
| 583 | ;; Special rule 2. -- preceding "r halant" must be modifier. | 584 | ;; Special rule 2. -- preceding "r halant" must be modifier. |
| 584 | (when (looking-at "$,15p6-(B.") | 585 | (when (looking-at "$,15p6-(B.") |
| 585 | (setq preceding-r t) | 586 | (setq preceding-r t) |
| 586 | (goto-char (+ 2 (point)))) | 587 | (goto-char (+ 2 (point)))) |
| 587 | ;; translate the rest characters into glyphs | 588 | ;; translate the rest characters into glyphs |
| 588 | (while (re-search-forward dev-char-glyph-regexp nil t) | 589 | (while (re-search-forward dev-char-glyph-regexp nil t) |
| 589 | (setq match-str (match-string 0)) | 590 | (setq match-str (match-string 0)) |
| 590 | (setq glyph-str | 591 | (setq glyph-str |
| 591 | (concat glyph-str | 592 | (concat glyph-str |
| 592 | (gethash match-str dev-char-glyph-hash))) | 593 | (gethash match-str dev-char-glyph-hash))) |
| 593 | ;; count the number of consonant-glyhs. | 594 | ;; count the number of consonant-glyhs. |
| 594 | (if (string-match devanagari-consonant match-str) | 595 | (if (string-match devanagari-consonant match-str) |
| 595 | (setq cons-num (1+ cons-num)))) | 596 | (setq cons-num (1+ cons-num)))) |
| 596 | ;; preceding-r must be attached before the anuswar if exists. | 597 | ;; preceding-r must be attached before the anuswar if exists. |
| 597 | (if preceding-r | 598 | (if preceding-r |
| 598 | (if last-modifier | 599 | (if last-modifier |
| 599 | (setq glyph-str (concat (substring glyph-str 0 -1) | 600 | (setq glyph-str (concat (substring glyph-str 0 -1) |
| 600 | "$,4"'(B" (substring glyph-str -1))) | 601 | "$,4"'(B" (substring glyph-str -1))) |
| 601 | (setq glyph-str (concat glyph-str "$,4"'(B")))) | 602 | (setq glyph-str (concat glyph-str "$,4"'(B")))) |
| 602 | (if last-halant (setq glyph-str (concat glyph-str "$,4""(B"))) | 603 | (if last-halant (setq glyph-str (concat glyph-str "$,4""(B"))) |
| 603 | ;;; *** glyph-to-glyph conversion *** | 604 | ;;; *** glyph-to-glyph conversion *** |
| 604 | (when (string-match dev-glyph-glyph-regexp glyph-str) | 605 | (when (string-match dev-glyph-glyph-regexp glyph-str) |
| 605 | (setq glyph-str | 606 | (setq glyph-str |
| 606 | (replace-match (gethash (match-string 0 glyph-str) | 607 | (replace-match (gethash (match-string 0 glyph-str) |
| 607 | dev-glyph-glyph-hash) | 608 | dev-glyph-glyph-hash) |
| 608 | nil t glyph-str)) | 609 | nil t glyph-str)) |
| 609 | (if (and (> cons-num 1) | 610 | (if (and (> cons-num 1) |
| 610 | (string-match dev-glyph-glyph-2-regexp glyph-str)) | 611 | (string-match dev-glyph-glyph-2-regexp glyph-str)) |
| 611 | (setq glyph-str | 612 | (setq glyph-str |
| 612 | (replace-match (gethash (match-string 0 glyph-str) | 613 | (replace-match (gethash (match-string 0 glyph-str) |
| 613 | dev-glyph-glyph-2-hash) | 614 | dev-glyph-glyph-2-hash) |
| 614 | nil t glyph-str)))) | 615 | nil t glyph-str)))) |
| 615 | ;;; *** glyph reordering *** | 616 | ;;; *** glyph reordering *** |
| 616 | (while (setq split-pos (string-match "$,4""(B\\|.$" glyph-str)) | 617 | (while (setq split-pos (string-match "$,4""(B\\|.$" glyph-str)) |
| 617 | (setq glyph-block (substring glyph-str 0 (1+ split-pos))) | 618 | (setq glyph-block (substring glyph-str 0 (1+ split-pos))) |
| 618 | (setq glyph-str (substring glyph-str (1+ split-pos))) | 619 | (setq glyph-str (substring glyph-str (1+ split-pos))) |
| 619 | (setq | 620 | (setq |
| 620 | glyph-block | 621 | glyph-block |
| 621 | (if (string-match dev-glyph-right-modifier-regexp glyph-block) | 622 | (if (string-match dev-glyph-right-modifier-regexp glyph-block) |
| 622 | (sort (string-to-list glyph-block) | 623 | (sort (string-to-list glyph-block) |
| 623 | (function (lambda (x y) | 624 | (function (lambda (x y) |
| 624 | (< (get-char-code-property x 'composition-order) | 625 | (< (get-char-code-property x 'composition-order) |
| 625 | (get-char-code-property y 'composition-order))))) | 626 | (get-char-code-property y 'composition-order))))) |
| 626 | (sort (string-to-list glyph-block) | 627 | (sort (string-to-list glyph-block) |
| 627 | (function (lambda (x y) | 628 | (function (lambda (x y) |
| 628 | (let ((xo (get-char-code-property x 'composition-order)) | 629 | (let ((xo (get-char-code-property x 'composition-order)) |
| 629 | (yo (get-char-code-property y 'composition-order))) | 630 | (yo (get-char-code-property y 'composition-order))) |
| 630 | (if (= xo 2) nil (if (= yo 2) t (< xo yo))))))))) | 631 | (if (= xo 2) nil (if (= yo 2) t (< xo yo))))))))) |
| 631 | (setq glyph-str-list (nconc glyph-str-list glyph-block))) | 632 | (setq glyph-str-list (nconc glyph-str-list glyph-block))) |
| 632 | ;; concatenate and attach reference-points. | 633 | ;; concatenate and attach reference-points. |
| 633 | (setq glyph-str | 634 | (setq glyph-str |
| 634 | (cdr | 635 | (cdr |
| 635 | (apply | 636 | (apply |
| 636 | 'nconc | 637 | 'nconc |
| 637 | (mapcar | 638 | (mapcar |
| 638 | (function (lambda (x) | 639 | (function (lambda (x) |
| 639 | (list | 640 | (list |
| 640 | (or (get-char-code-property x 'reference-point) | 641 | (or (get-char-code-property x 'reference-point) |
| 641 | '(5 . 3) ;; default reference point. | 642 | '(5 . 3) ;; default reference point. |
| 642 | ) | 643 | ) |
| 643 | x))) | 644 | x))) |
| 644 | glyph-str-list)))))) | 645 | glyph-str-list)))))) |
| 645 | (compose-region from to glyph-str))) | 646 | (compose-region from to glyph-str))) |
| 646 | 647 | ||
| 647 | (provide 'devan-util) | 648 | (provide 'devan-util) |