Mercurial > emacs
comparison lisp/language/european.el @ 41875:e31b7be17ab2
(diacritic-composition-pattern): New constant.
(diacritic-compose-region, diacritic-compose-string)
(diacritic-compose-buffer, diacritic-post-read-conversion)
(diacritic-composition-function): New functions.
author | Dave Love <fx@gnu.org> |
---|---|
date | Fri, 07 Dec 2001 14:48:40 +0000 |
parents | 06145993e54d |
children | 8fb314e3c7fd |
comparison
equal
deleted
inserted
replaced
41874:1b93abfcbd87 | 41875:e31b7be17ab2 |
---|---|
540 '(decode-mac-roman . encode-mac-roman) | 540 '(decode-mac-roman . encode-mac-roman) |
541 '((safe-chars . mac-roman-encoder) | 541 '((safe-chars . mac-roman-encoder) |
542 (valid-codes (0 . 255)) | 542 (valid-codes (0 . 255)) |
543 (mime-charset . macintosh))) ; per IANA, rfc1345 | 543 (mime-charset . macintosh))) ; per IANA, rfc1345 |
544 | 544 |
545 (defconst diacritic-composition-pattern "\\C^\\c^+") | |
546 | |
547 ;;;###autoload | |
548 (defun diacritic-compose-region (beg end) | |
549 "Compose diacritic characters in the region. | |
550 When called from a program, expects two arguments, | |
551 positions (integers or markers) specifying the region." | |
552 (interactive "r") | |
553 (save-restriction | |
554 (narrow-to-region beg end) | |
555 (goto-char (point-min)) | |
556 (while (re-search-forward diacritic-composition-pattern nil t) | |
557 (compose-region (match-beginning 0) (match-end 0))))) | |
558 | |
559 ;;;###autoload | |
560 (defun diacritic-compose-string (string) | |
561 "Compose diacritic characters in STRING and return the resulting string." | |
562 (let ((idx 0)) | |
563 (while (setq idx (string-match diacritic-composition-pattern string idx)) | |
564 (compose-string string idx (match-end 0)) | |
565 (setq idx (match-end 0)))) | |
566 string) | |
567 | |
568 ;;;###autoload | |
569 (defun diacritic-compose-buffer () | |
570 "Compose diacritic characters in the current buffer." | |
571 (interactive) | |
572 (diacritic-compose-region (point-min) (point-max))) | |
573 | |
574 ;;;###autoload | |
575 (defun diacritic-post-read-conversion (len) | |
576 (diacritic-compose-region (point) (+ (point) len)) | |
577 len) | |
578 | |
579 ;;;###autoload | |
580 (defun diacritic-composition-function (from to pattern &optional string) | |
581 "Compose diacritic text in the region FROM and TO. | |
582 The text matches the regular expression PATTERN. | |
583 Optional 4th argument STRING, if non-nil, is a string containing text | |
584 to compose. | |
585 | |
586 The return value is number of composed characters." | |
587 (if (< (1+ from) to) | |
588 (prog1 (- to from) | |
589 (if string | |
590 (compose-string string from to) | |
591 (compose-region from to)) | |
592 (- to from)))) | |
593 | |
594 ;; Register a function to compose Unicode diacrtics and marks. | |
595 (let ((patterns '(("\\C^\\c^+" . diacrtic-composition-function)))) | |
596 (let ((c #x300)) | |
597 (while (<= c #x362) | |
598 (aset composition-function-table (decode-char 'ucs c) patterns) | |
599 (setq c (1+ c))) | |
600 (setq c #x20d0) | |
601 (while (<= c #x20e3) | |
602 (aset composition-function-table (decode-char 'ucs c) patterns) | |
603 (setq c (1+ c))))) | |
604 | |
545 (provide 'european) | 605 (provide 'european) |
546 | 606 |
547 ;;; european.el ends here | 607 ;;; european.el ends here |