aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/language/european.el107
1 files changed, 85 insertions, 22 deletions
diff --git a/lisp/language/european.el b/lisp/language/european.el
index c397d7f7f2b..ef51d3eeac9 100644
--- a/lisp/language/european.el
+++ b/lisp/language/european.el
@@ -563,7 +563,48 @@ method and applying Turkish case rules for the characters i, I, ,C9(B, ,C)(B
563 :mnemonic ?* 563 :mnemonic ?*
564 :charset-list '(adobe-standard-encoding) 564 :charset-list '(adobe-standard-encoding)
565 :mime-charset 'adobe-standard-encoding) 565 :mime-charset 'adobe-standard-encoding)
566
566 567
568;; For automatic composing of diacritics and combining marks.
569(dolist (range '( ;; combining diacritical marks
570 (#x0300 #x0314 (tc . bc))
571 (#x0315 (tr . bl))
572 (#x0316 #x0319 (bc . tc))
573 (#x031A (tr . cl))
574 (#x031B #x0320 (bc . tc))
575 (#x0321 (Br . tr))
576 (#x0322 (Br . tl))
577 (#x0323 #x0333 (bc . tc))
578 (#x0334 #x0338 (Bc . Bc))
579 (#x0339 #x033C (bc . tc))
580 (#x033D #x033F (tc . bc))
581 (#x0340 (tl . bc))
582 (#x0341 (tr . bc))
583 (#x0342 #x0344 (tc . bc))
584 (#x0345 (bc . tc))
585 (#x0346 (tc . bc))
586 (#x0347 #x0349 (bc . tc))
587 (#x034A #x034C (tc . bc))
588 (#x034D #x034E (bc . tc))
589 ;; combining diacritical marks for symbols
590 (#x20D0 #x20D1 (tc . bc))
591 (#x20D2 #x20D3 (Bc . Bc))
592 (#x20D4 #x20D7 (tc . bc))
593 (#x20D8 #x20DA (Bc . Bc))
594 (#x20DB #x20DC (tc . bc))
595 (#x20DD #x20E0 (Bc . Bc))
596 (#x20E1 (tc . bc))
597 (#x20E2 #x20E3 (Bc . Bc))))
598 (let* ((from (car range))
599 (to (if (= (length range) 3)
600 (nth 1 range)
601 from))
602 (composition (car (last range))))
603 (while (<= from to)
604 (put-char-code-property from 'diacritic-composition composition)
605 (aset composition-function-table from 'diacritic-composition-function)
606 (setq from (1+ from)))))
607
567(defconst diacritic-composition-pattern "\\C^\\c^+") 608(defconst diacritic-composition-pattern "\\C^\\c^+")
568 609
569(defun diacritic-compose-region (beg end) 610(defun diacritic-compose-region (beg end)
@@ -594,30 +635,52 @@ positions (integers or markers) specifying the region."
594 (diacritic-compose-region (point) (+ (point) len)) 635 (diacritic-compose-region (point) (+ (point) len))
595 len) 636 len)
596 637
597(defun diacritic-composition-function (from to pattern &optional string) 638(defun diacritic-composition-function (pos &optional string)
598 "Compose diacritic text in the region FROM and TO. 639 "Compose diacritic text around POS.
599The text matches the regular expression PATTERN. 640Optional 2nd argument STRING, if non-nil, is a string containing text
600Optional 4th argument STRING, if non-nil, is a string containing text
601to compose. 641to compose.
602 642
603The return value is number of composed characters." 643The return value is the end position of composed characters,
604 (if (< (1+ from) to) 644or nil if no characters are composed."
605 (prog1 (- to from) 645 (setq pos (1- pos))
606 (if string 646 (if string
607 (compose-string string from to) 647 (let ((ch (aref string pos))
608 (compose-region from to)) 648 start end components ch composition)
609 (- to from)))) 649 (when (and (>= pos 0)
610 650 ;; Previous character is latin.
611;; Register a function to compose Unicode diacrtics and marks. 651 (aref (char-category-set ch) ?l)
612(let ((patterns '(("\\C^\\c^+" . diacritic-composition-function)))) 652 (/= ch 32))
613 (let ((c #x300)) 653 (setq start pos
614 (while (<= c #x362) 654 end (length string)
615 (aset composition-function-table c patterns) 655 components (list ch)
616 (setq c (1+ c))) 656 pos (1+ pos))
617 (setq c #x20d0) 657 (while (and
618 (while (<= c #x20e3) 658 (< pos end)
619 (aset composition-function-table c patterns) 659 (setq ch (aref string pos)
620 (setq c (1+ c))))) 660 composition
661 (get-char-code-property ch 'diacritic-composition)))
662 (setq components (cons ch (cons composition components))
663 pos (1+ pos)))
664 (compose-string string start pos (nreverse components))
665 pos))
666 (let ((ch (char-after pos))
667 start end components composition)
668 (when (and (>= pos (point-min))
669 (aref (char-category-set ch) ?l)
670 (/= ch 32))
671 (setq start pos
672 end (point-max)
673 components (list ch)
674 pos (1+ pos))
675 (while (and
676 (< pos end)
677 (setq ch (char-after pos)
678 composition
679 (get-char-code-property ch 'diacritic-composition)))
680 (setq components (cons ch (cons composition components))
681 pos (1+ pos)))
682 (compose-region start pos (nreverse components))
683 pos))))
621 684
622(provide 'european) 685(provide 'european)
623 686