comparison lisp/language/european.el @ 89919:80fad817819f

(diacritic-compose-region): Compose diacritical marks only with a character whose syntax is word constituent. (diacritic-compose-string): Likewise. (diacritic-composition-function): Likewise. (diacritic-post-read-conversion): Delete it.
author Kenichi Handa <handa@m17n.org>
date Tue, 20 Apr 2004 05:24:12 +0000
parents 68c22ea6027c
children 4c90ffeb71c5
comparison
equal deleted inserted replaced
89918:2d36fc270f24 89919:80fad817819f
655 (interactive "r") 655 (interactive "r")
656 (save-restriction 656 (save-restriction
657 (narrow-to-region beg end) 657 (narrow-to-region beg end)
658 (goto-char (point-min)) 658 (goto-char (point-min))
659 (while (re-search-forward diacritic-composition-pattern nil t) 659 (while (re-search-forward diacritic-composition-pattern nil t)
660 (compose-region (match-beginning 0) (match-end 0))))) 660 (if (= (char-syntax (char-after (match-beginning 0))) ?w)
661 (compose-region (match-beginning 0) (match-end 0))))))
661 662
662 (defun diacritic-compose-string (string) 663 (defun diacritic-compose-string (string)
663 "Compose diacritic characters in STRING and return the resulting string." 664 "Compose diacritic characters in STRING and return the resulting string."
664 (let ((idx 0)) 665 (let ((idx 0))
665 (while (setq idx (string-match diacritic-composition-pattern string idx)) 666 (while (setq idx (string-match diacritic-composition-pattern string idx))
666 (compose-string string idx (match-end 0)) 667 (if (= (char-syntax (aref string idx)) ?w)
668 (compose-string string idx (match-end 0)))
667 (setq idx (match-end 0)))) 669 (setq idx (match-end 0))))
668 string) 670 string)
669 671
670 (defun diacritic-compose-buffer () 672 (defun diacritic-compose-buffer ()
671 "Compose diacritic characters in the current buffer." 673 "Compose diacritic characters in the current buffer."
672 (interactive) 674 (interactive)
673 (diacritic-compose-region (point-min) (point-max))) 675 (diacritic-compose-region (point-min) (point-max)))
674
675 (defun diacritic-post-read-conversion (len)
676 (diacritic-compose-region (point) (+ (point) len))
677 len)
678 676
679 (defun diacritic-composition-function (pos &optional string) 677 (defun diacritic-composition-function (pos &optional string)
680 "Compose diacritic text around POS. 678 "Compose diacritic text around POS.
681 Optional 2nd argument STRING, if non-nil, is a string containing text 679 Optional 2nd argument STRING, if non-nil, is a string containing text
682 to compose. 680 to compose.
686 (setq pos (1- pos)) 684 (setq pos (1- pos))
687 (if string 685 (if string
688 (if (>= pos 0) 686 (if (>= pos 0)
689 (let ((ch (aref string pos)) 687 (let ((ch (aref string pos))
690 start end components ch composition) 688 start end components ch composition)
691 (when (and (>= ch 32) (or (< ch 127) (>= ch 160))) 689 (when (= (char-syntax ch) ?w)
692 (setq start pos 690 (setq start pos
693 end (length string) 691 end (length string)
694 components (list ch) 692 components (list ch)
695 pos (1+ pos)) 693 pos (1+ pos))
696 (while (and 694 (while (and
704 (compose-string string start pos (nreverse components)) 702 (compose-string string start pos (nreverse components))
705 pos))) 703 pos)))
706 (if (>= pos (point-min)) 704 (if (>= pos (point-min))
707 (let ((ch (char-after pos)) 705 (let ((ch (char-after pos))
708 start end components composition) 706 start end components composition)
709 (when (and (>= ch 32) (or (< ch 127) (>= ch 160))) 707 (when (= (char-syntax ch) ?w)
710 (setq start pos 708 (setq start pos
711 end (point-max) 709 end (point-max)
712 components (list ch) 710 components (list ch)
713 pos (1+ pos)) 711 pos (1+ pos))
714 (while (and 712 (while (and