Mercurial > emacs
comparison lisp/international/mule.el @ 28018:dade22d104f2
Modify comment about coding system
property `coding-category'.
(make-coding-system): New argument EOL-TYPE. Pay attention to
coding-category property of PROPERTIES.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 07 Mar 2000 06:15:36 +0000 |
parents | 2f284b9ec711 |
children | bbe7b99b5b28 |
comparison
equal
deleted
inserted
replaced
28017:a89f451a3273 | 28018:dade22d104f2 |
---|---|
311 ;; Here's a list of coding system properties currently being used. | 311 ;; Here's a list of coding system properties currently being used. |
312 ;; | 312 ;; |
313 ;; o coding-category | 313 ;; o coding-category |
314 ;; | 314 ;; |
315 ;; The value is a coding category the coding system belongs to. The | 315 ;; The value is a coding category the coding system belongs to. The |
316 ;; function `make-coding-system' and `define-coding-system-alias' sets | 316 ;; function `make-coding-system' sets this value automatically |
317 ;; this value automatically. | 317 ;; unless its argument PROPERTIES specifies this property. |
318 ;; | 318 ;; |
319 ;; o alias-coding-systems | 319 ;; o alias-coding-systems |
320 ;; | 320 ;; |
321 ;; The value is a list of coding systems of the same alias group. The | 321 ;; The value is a list of coding systems of the same alias group. The |
322 ;; first element is the coding system made at first, which we call as | 322 ;; first element is the coding system made at first, which we call as |
323 ;; `base coding system'. The function `make-coding-system' and | 323 ;; `base coding system'. The function `make-coding-system' sets this |
324 ;; `define-coding-system-alias' set this value automatically. | 324 ;; value automatically and `define-coding-system-alias' updates it. |
325 ;; | 325 ;; |
326 ;; o post-read-conversion | 326 ;; o post-read-conversion |
327 ;; | 327 ;; |
328 ;; The value is a function to call after some text is inserted and | 328 ;; The value is a function to call after some text is inserted and |
329 ;; decoded by the coding system itself and before any functions in | 329 ;; decoded by the coding system itself and before any functions in |
527 coding-system-alist)) | 527 coding-system-alist)) |
528 (setq i (1+ i))) | 528 (setq i (1+ i))) |
529 subsidiaries)) | 529 subsidiaries)) |
530 | 530 |
531 (defun make-coding-system (coding-system type mnemonic doc-string | 531 (defun make-coding-system (coding-system type mnemonic doc-string |
532 &optional flags properties) | 532 &optional |
533 flags | |
534 properties | |
535 eol-type) | |
533 "Define a new coding system CODING-SYSTEM (symbol). | 536 "Define a new coding system CODING-SYSTEM (symbol). |
534 Remaining arguments are TYPE, MNEMONIC, DOC-STRING, FLAGS (optional), | 537 Remaining arguments are TYPE, MNEMONIC, DOC-STRING, FLAGS (optional), |
535 and PROPERTIES (optional) which construct a coding-spec of CODING-SYSTEM | 538 and PROPERTIES (optional) which construct a coding-spec of CODING-SYSTEM |
536 in the following format: | 539 in the following format: |
537 [TYPE MNEMONIC DOC-STRING PLIST FLAGS] | 540 [TYPE MNEMONIC DOC-STRING PLIST FLAGS] |
587 | 590 |
588 PROPERTIES is an alist of properties vs the corresponding values. | 591 PROPERTIES is an alist of properties vs the corresponding values. |
589 These properties are set in PLIST, a property list. This function | 592 These properties are set in PLIST, a property list. This function |
590 also sets properties `coding-category' and `alias-coding-systems' | 593 also sets properties `coding-category' and `alias-coding-systems' |
591 automatically. | 594 automatically. |
595 | |
596 EOL-TYPE specifies the EOL type of the coding-system in one of the | |
597 following formats: | |
598 | |
599 o symbol (unix, dos, or mac) | |
600 | |
601 The symbol `unix' means Unix-like EOL (LF), `dos' means | |
602 DOS-like EOL (CRLF), and `mac' means MAC-like EOL (CR). | |
603 | |
604 o number (0, 1, or 2) | |
605 | |
606 The number 0, 1, and 2 mean UNIX, DOS, and MAC-like EOL | |
607 respectively. | |
608 | |
609 o vector of coding-systems of length 3 | |
610 | |
611 The EOL type is detected automatically for the coding system. | |
612 And, according to the detected EOL type, one of the coding | |
613 systems in the vector is selected. Elements of the vector | |
614 corresponds to Unix-liek EOL, DOS-like EOL, and Mac-like EOL | |
615 in this order. | |
592 | 616 |
593 Kludgy features for backward compatibility: | 617 Kludgy features for backward compatibility: |
594 | 618 |
595 1. If TYPE is 4 and car or cdr of FLAGS is a vector, the vector is | 619 1. If TYPE is 4 and car or cdr of FLAGS is a vector, the vector is |
596 treated as a compiled CCL code. | 620 treated as a compiled CCL code. |
696 (or (eq properties t) | 720 (or (eq properties t) |
697 (not (consp (car properties))))) | 721 (not (consp (car properties))))) |
698 ;; In the old version, the arg PROPERTIES is a list to be | 722 ;; In the old version, the arg PROPERTIES is a list to be |
699 ;; set in PLIST as a value of property `safe-charsets'. | 723 ;; set in PLIST as a value of property `safe-charsets'. |
700 (plist-put plist 'safe-charsets properties) | 724 (plist-put plist 'safe-charsets properties) |
725 ;; In the current version PROPERTIES is a property list. | |
726 ;; Reflect it into PLIST one by one. | |
701 (let ((l properties)) | 727 (let ((l properties)) |
702 (while l | 728 (while l |
703 (plist-put plist (car (car l)) (cdr (car l))) | 729 (plist-put plist (car (car l)) (cdr (car l))) |
704 (setq l (cdr l))))) | 730 (setq l (cdr l))))) |
731 ;; The property `coding-category' may have been set differently | |
732 ;; through PROPERTIES. | |
733 (setq coding-category (plist-get plist 'coding-category)) | |
705 (aset coding-spec coding-spec-plist-idx plist)) | 734 (aset coding-spec coding-spec-plist-idx plist)) |
706 (put coding-system 'coding-system coding-spec) | 735 (put coding-system 'coding-system coding-spec) |
707 (put coding-category 'coding-systems | 736 (put coding-category 'coding-systems |
708 (cons coding-system (get coding-category 'coding-systems)))) | 737 (cons coding-system (get coding-category 'coding-systems)))) |
709 | 738 |
710 ;; Next, set a value of `eol-type' property. The value is a vector | 739 ;; Next, set a value of `eol-type' property. |
711 ;; of subsidiary coding systems, each corresponds to a coding system | 740 (if (and (not eol-type) |
712 ;; for the detected end-of-line format. | 741 (or (<= type 3) (= type 5))) |
713 (put coding-system 'eol-type | 742 ;; If EOL-TYPE is nil, set a vector of subsidiary coding |
714 (if (or (<= type 3) (= type 5)) | 743 ;; systems, each corresponds to a coding system for the detected |
715 (make-subsidiary-coding-system coding-system) | 744 ;; EOL format. |
716 0)) | 745 (setq eol-type (make-subsidiary-coding-system coding-system))) |
746 (setq eol-type | |
747 (cond ((or (eq eol-type 'unix) (null eol-type)) | |
748 0) | |
749 ((eq eol-type 'dos) | |
750 1) | |
751 ((eq eol-type 'mac) | |
752 2) | |
753 ((or (and (vectorp eol-type) | |
754 (= (length eol-type) 3)) | |
755 (and (numberp eol-type) | |
756 (and (>= eol-type 0) | |
757 (<= eol-type 2)))) | |
758 eol-type) | |
759 (t | |
760 (error "Invalid EOL-TYPE spec:%S" eol-type)))) | |
761 (put coding-system 'eol-type eol-type) | |
717 | 762 |
718 ;; At last, register CODING-SYSTEM in `coding-system-list' and | 763 ;; At last, register CODING-SYSTEM in `coding-system-list' and |
719 ;; `coding-system-alist'. | 764 ;; `coding-system-alist'. |
720 (add-to-coding-system-list coding-system) | 765 (add-to-coding-system-list coding-system) |
721 (setq coding-system-alist (cons (list (symbol-name coding-system)) | 766 (setq coding-system-alist (cons (list (symbol-name coding-system)) |