diff options
| author | Kenichi Handa | 1998-01-22 01:42:20 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-01-22 01:42:20 +0000 |
| commit | d9e3229d1e8b7797d452d261a37da0d0394546d0 (patch) | |
| tree | 95d4caaafc823e4dd9d5b8e1f142519b40c78bb4 | |
| parent | f9222bef23c81c5cc423af31574c3ec21bd9d449 (diff) | |
| download | emacs-d9e3229d1e8b7797d452d261a37da0d0394546d0.tar.gz emacs-d9e3229d1e8b7797d452d261a37da0d0394546d0.zip | |
(define-character-unification-table): New
function.
(coding-system-base): Doc-string modified.
(make-coding-system): The 6th optional arg is changed to
PROPERTIES.
(set-buffer-file-coding-system): Show "(default, nil)" in prompt.
(set-coding-priority): Code tuned.
| -rw-r--r-- | lisp/international/mule.el | 124 |
1 files changed, 82 insertions, 42 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index f26d0105788..c13b6817e57 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -389,8 +389,8 @@ for more detail." | |||
| 389 | 389 | ||
| 390 | (defun coding-system-base (coding-system) | 390 | (defun coding-system-base (coding-system) |
| 391 | "Return the base coding system of CODING-SYSTEM. | 391 | "Return the base coding system of CODING-SYSTEM. |
| 392 | A base coding system is what made by `make-coding-system', | 392 | A base coding system is what made by `make-coding-system'. |
| 393 | not what made by `define-coding-system-alias'." | 393 | Any alias nor subsidiary coding systems are not base coding system." |
| 394 | (car (coding-system-get coding-system 'alias-coding-systems))) | 394 | (car (coding-system-get coding-system 'alias-coding-systems))) |
| 395 | 395 | ||
| 396 | (defalias 'coding-system-parent 'coding-system-base) | 396 | (defalias 'coding-system-parent 'coding-system-base) |
| @@ -438,10 +438,10 @@ coding system whose eol-type is N." | |||
| 438 | subsidiaries)) | 438 | subsidiaries)) |
| 439 | 439 | ||
| 440 | (defun make-coding-system (coding-system type mnemonic doc-string | 440 | (defun make-coding-system (coding-system type mnemonic doc-string |
| 441 | &optional flags safe-charsets) | 441 | &optional flags properties) |
| 442 | "Define a new CODING-SYSTEM (symbol). | 442 | "Define a new CODING-SYSTEM (symbol). |
| 443 | Remaining arguments are TYPE, MNEMONIC, DOC-STRING, FLAGS (optional), | 443 | Remaining arguments are TYPE, MNEMONIC, DOC-STRING, FLAGS (optional), |
| 444 | and CHARSETS (optional) which construct a coding-spec of CODING-SYSTEM | 444 | and PROPERTIES (optional) which construct a coding-spec of CODING-SYSTEM |
| 445 | in the following format: | 445 | in the following format: |
| 446 | [TYPE MNEMONIC DOC-STRING PLIST FLAGS] | 446 | [TYPE MNEMONIC DOC-STRING PLIST FLAGS] |
| 447 | TYPE is an integer value indicating the type of coding-system as follows: | 447 | TYPE is an integer value indicating the type of coding-system as follows: |
| @@ -456,12 +456,6 @@ MNEMONIC is a character to be displayed on mode line for the coding-system. | |||
| 456 | 456 | ||
| 457 | DOC-STRING is a documentation string for the coding-system. | 457 | DOC-STRING is a documentation string for the coding-system. |
| 458 | 458 | ||
| 459 | PLIST is the propert list for CODING-SYSTEM. This function sets | ||
| 460 | properties coding-category, alias-coding-systems, safe-charsets. The | ||
| 461 | first two are set automatically. The last one is set to the argument | ||
| 462 | SAFE-CHARSETS. SAFE-CHARSETS is a list of character sets encoded | ||
| 463 | safely in CODING-SYSTEM, or t which means all character sets are safe. | ||
| 464 | |||
| 465 | FLAGS specifies more precise information of each TYPE. | 459 | FLAGS specifies more precise information of each TYPE. |
| 466 | 460 | ||
| 467 | If TYPE is 2 (ISO-2022), FLAGS should be a list of: | 461 | If TYPE is 2 (ISO-2022), FLAGS should be a list of: |
| @@ -495,14 +489,23 @@ FLAGS specifies more precise information of each TYPE. | |||
| 495 | code of the coding system. | 489 | code of the coding system. |
| 496 | 490 | ||
| 497 | If TYPE is 4 (private), FLAGS should be a cons of CCL programs, | 491 | If TYPE is 4 (private), FLAGS should be a cons of CCL programs, |
| 498 | for decoding and encoding. See the documentation of CCL for more detail." | 492 | for decoding and encoding. See the documentation of CCL for more detail. |
| 493 | |||
| 494 | PROPERTIES is an alist of properties vs the corresponding values. | ||
| 495 | These properties are set in PLIST, a property list. This function | ||
| 496 | also sets properties `coding-category' and `alias-coding-systems' | ||
| 497 | automatically. | ||
| 499 | 498 | ||
| 499 | Kludgy feature: For backward compatibility, if PROPERTIES is a list of | ||
| 500 | character sets, the list is set as a value of `safe-charsets' in | ||
| 501 | PLIST." | ||
| 500 | (if (memq coding-system coding-system-list) | 502 | (if (memq coding-system coding-system-list) |
| 501 | (error "Coding system %s already exists")) | 503 | (error "Coding system %s already exists" coding-system)) |
| 502 | 504 | ||
| 503 | ;; Set a value of `coding-system' property. | 505 | ;; Set a value of `coding-system' property. |
| 504 | (let ((coding-spec (make-vector 5 nil)) | 506 | (let ((coding-spec (make-vector 5 nil)) |
| 505 | (no-initial-designation nil) | 507 | (no-initial-designation t) |
| 508 | (no-alternative-designation t) | ||
| 506 | coding-category) | 509 | coding-category) |
| 507 | (if (or (not (integerp type)) (< type 0) (> type 5)) | 510 | (if (or (not (integerp type)) (< type 0) (> type 5)) |
| 508 | (error "TYPE argument must be 0..5")) | 511 | (error "TYPE argument must be 0..5")) |
| @@ -520,7 +523,6 @@ FLAGS specifies more precise information of each TYPE. | |||
| 520 | (let ((i 0) | 523 | (let ((i 0) |
| 521 | (vec (make-vector 32 nil)) | 524 | (vec (make-vector 32 nil)) |
| 522 | (g1-designation nil)) | 525 | (g1-designation nil)) |
| 523 | (setq no-initial-designation t) | ||
| 524 | (while (< i 4) | 526 | (while (< i 4) |
| 525 | (let ((charset (car flags))) | 527 | (let ((charset (car flags))) |
| 526 | (if (and no-initial-designation | 528 | (if (and no-initial-designation |
| @@ -536,12 +538,16 @@ FLAGS specifies more precise information of each TYPE. | |||
| 536 | elt) | 538 | elt) |
| 537 | (while tail | 539 | (while tail |
| 538 | (setq elt (car tail)) | 540 | (setq elt (car tail)) |
| 539 | (or (not elt) (eq elt t) (charsetp elt) | 541 | (if (eq elt t) |
| 540 | (error "Invalid charset: %s" elt)) | 542 | (setq no-alternative-designation nil) |
| 543 | (if (and elt (not (charsetp elt))) | ||
| 544 | (error "Invalid charset: %s" elt))) | ||
| 541 | (setq tail (cdr tail))) | 545 | (setq tail (cdr tail))) |
| 542 | (setq g1-designation (car charset))) | 546 | (setq g1-designation (car charset))) |
| 543 | (if (and charset (not (eq charset t))) | 547 | (if charset |
| 544 | (error "Invalid charset: %s" charset)))) | 548 | (if (eq charset t) |
| 549 | (setq no-alternative-designation nil) | ||
| 550 | (error "Invalid charset: %s" charset))))) | ||
| 545 | (aset vec i charset)) | 551 | (aset vec i charset)) |
| 546 | (setq flags (cdr flags) i (1+ i))) | 552 | (setq flags (cdr flags) i (1+ i))) |
| 547 | (while (and (< i 32) flags) | 553 | (while (and (< i 32) flags) |
| @@ -555,7 +561,9 @@ FLAGS specifies more precise information of each TYPE. | |||
| 555 | (if (aref vec 7) ; 7-bit only. | 561 | (if (aref vec 7) ; 7-bit only. |
| 556 | (if (aref vec 9) ; Use single-shift. | 562 | (if (aref vec 9) ; Use single-shift. |
| 557 | 'coding-category-iso-7-else | 563 | 'coding-category-iso-7-else |
| 558 | 'coding-category-iso-7) | 564 | (if no-alternative-designation |
| 565 | 'coding-category-iso-7-tight | ||
| 566 | 'coding-category-iso-7)) | ||
| 559 | (if no-initial-designation | 567 | (if no-initial-designation |
| 560 | 'coding-category-iso-8-else | 568 | 'coding-category-iso-8-else |
| 561 | (if (and (charsetp g1-designation) | 569 | (if (and (charsetp g1-designation) |
| @@ -575,11 +583,18 @@ FLAGS specifies more precise information of each TYPE. | |||
| 575 | (setq coding-category 'coding-category-raw-text))) | 583 | (setq coding-category 'coding-category-raw-text))) |
| 576 | 584 | ||
| 577 | (let ((plist (list 'coding-category coding-category | 585 | (let ((plist (list 'coding-category coding-category |
| 578 | 'alias-coding-systems (list coding-system) | 586 | 'alias-coding-systems (list coding-system)))) |
| 579 | 'safe-charsets safe-charsets))) | ||
| 580 | (if no-initial-designation | 587 | (if no-initial-designation |
| 581 | (setq plist (cons 'no-initial-designation | 588 | (plist-put plist 'no-initial-designation t)) |
| 582 | (cons no-initial-designation plist)))) | 589 | (if (and properties |
| 590 | (or (eq properties t) | ||
| 591 | (not (consp (car properties))))) | ||
| 592 | ;; In the old version, the arg PROPERTIES is a list to be | ||
| 593 | ;; set in PLIST as a value of property `safe-charsets'. | ||
| 594 | (plist-put plist 'safe-charsets properties) | ||
| 595 | (while properties | ||
| 596 | (plist-put plist (car (car properties)) (cdr (car properties))) | ||
| 597 | (setq properties (cdr properties)))) | ||
| 583 | (aset coding-spec coding-spec-plist-idx plist)) | 598 | (aset coding-spec coding-spec-plist-idx plist)) |
| 584 | (put coding-system 'coding-system coding-spec) | 599 | (put coding-system 'coding-system coding-spec) |
| 585 | (put coding-category 'coding-systems | 600 | (put coding-category 'coding-systems |
| @@ -597,7 +612,8 @@ FLAGS specifies more precise information of each TYPE. | |||
| 597 | ;; `coding-system-alist'. | 612 | ;; `coding-system-alist'. |
| 598 | (setq coding-system-list (cons coding-system coding-system-list)) | 613 | (setq coding-system-list (cons coding-system coding-system-list)) |
| 599 | (setq coding-system-alist (cons (list (symbol-name coding-system)) | 614 | (setq coding-system-alist (cons (list (symbol-name coding-system)) |
| 600 | coding-system-alist))) | 615 | coding-system-alist)) |
| 616 | coding-system) | ||
| 601 | 617 | ||
| 602 | (defun define-coding-system-alias (alias coding-system) | 618 | (defun define-coding-system-alias (alias coding-system) |
| 603 | "Define ALIAS as an alias for coding system CODING-SYSTEM." | 619 | "Define ALIAS as an alias for coding system CODING-SYSTEM." |
| @@ -622,7 +638,7 @@ conversion, and CODING-SYSTEM does not specify one, CODING-SYSTEM is | |||
| 622 | merged with the already-specified end-of-line conversion. | 638 | merged with the already-specified end-of-line conversion. |
| 623 | However, if the optional prefix argument FORCE is non-nil, | 639 | However, if the optional prefix argument FORCE is non-nil, |
| 624 | then CODING-SYSTEM is used exactly as specified." | 640 | then CODING-SYSTEM is used exactly as specified." |
| 625 | (interactive "zCoding system for visited file: \nP") | 641 | (interactive "zCoding system for visited file (default, nil): \nP") |
| 626 | (check-coding-system coding-system) | 642 | (check-coding-system coding-system) |
| 627 | (if (null force) | 643 | (if (null force) |
| 628 | (let ((x (coding-system-eol-type buffer-file-coding-system)) | 644 | (let ((x (coding-system-eol-type buffer-file-coding-system)) |
| @@ -706,24 +722,21 @@ For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems]." | |||
| 706 | (force-mode-line-update)) | 722 | (force-mode-line-update)) |
| 707 | 723 | ||
| 708 | (defun set-coding-priority (arg) | 724 | (defun set-coding-priority (arg) |
| 709 | "Set priority of coding-category according to LIST. | 725 | "Set priority of coding categories according to LIST. |
| 710 | LIST is a list of coding-categories ordered by priority." | 726 | LIST is a list of coding categories ordered by priority." |
| 711 | (let (l) | 727 | (let ((l arg) |
| 712 | ;; Put coding-categories listed in ARG to L while checking the | 728 | (current-list (copy-sequence coding-category-list))) |
| 713 | ;; validity. We assume that `coding-category-list' contains whole | 729 | ;; Check the varidity of ARG while deleting coding categories in |
| 714 | ;; coding-categories. | 730 | ;; ARG from CURRENT-LIST. We assume that CODING-CATEGORY-LIST |
| 715 | (while arg | 731 | ;; contains all coding categories. |
| 716 | (if (null (memq (car arg) coding-category-list)) | 732 | (while l |
| 717 | (error "Invalid element in argument: %s" (car arg))) | 733 | (if (or (null (get (car l) 'coding-category-index)) |
| 718 | (setq l (cons (car arg) l)) | 734 | (null (memq (car l) current-list))) |
| 719 | (setq arg (cdr arg))) | 735 | (error "Invalid or duplicated element in argument: %s" arg)) |
| 720 | ;; Put coding-category not listed in ARG to L. | 736 | (setq current-list (delq (car l) current-list)) |
| 721 | (while coding-category-list | 737 | (setq l (cdr l))) |
| 722 | (if (null (memq (car coding-category-list) l)) | ||
| 723 | (setq l (cons (car coding-category-list) l))) | ||
| 724 | (setq coding-category-list (cdr coding-category-list))) | ||
| 725 | ;; Update `coding-category-list' and return it. | 738 | ;; Update `coding-category-list' and return it. |
| 726 | (setq coding-category-list (nreverse l)))) | 739 | (setq coding-category-list (append arg current-list)))) |
| 727 | 740 | ||
| 728 | ;;; FILE I/O | 741 | ;;; FILE I/O |
| 729 | 742 | ||
| @@ -998,6 +1011,33 @@ without changing their position code(s)." | |||
| 998 | ;; Return TABLE just created. | 1011 | ;; Return TABLE just created. |
| 999 | table)) | 1012 | table)) |
| 1000 | 1013 | ||
| 1014 | (defun define-character-unification-table (symbol &rest args) | ||
| 1015 | "define character unification table. This function call make-unification-table, | ||
| 1016 | store a returned table to character-unification-table-vector. | ||
| 1017 | And then set the table as SYMBOL's unification-table property, | ||
| 1018 | the index of the vector as SYMBOL's unification-table-id." | ||
| 1019 | (let ((table (apply 'make-unification-table args)) | ||
| 1020 | (len (length character-unification-table-vector)) | ||
| 1021 | (id 0) | ||
| 1022 | slot) | ||
| 1023 | (or (symbolp symbol) | ||
| 1024 | (signal 'wrong-type-argument symbol)) | ||
| 1025 | (put symbol 'unification-table table) | ||
| 1026 | (while (and (< id len) | ||
| 1027 | (if (consp (setq slot (aref character-unification-table-vector id))) | ||
| 1028 | (if (eq (car slot) symbol) nil t) | ||
| 1029 | (aset character-unification-table-vector id (cons symbol table)) | ||
| 1030 | nil)) | ||
| 1031 | (setq id (1+ id))) | ||
| 1032 | (if (= id len) | ||
| 1033 | (progn | ||
| 1034 | (setq character-unification-table-vector | ||
| 1035 | (vconcat character-unification-table-vector (make-vector len nil))) | ||
| 1036 | (aset character-unification-table-vector id (cons symbol table)))) | ||
| 1037 | (put symbol 'unification-table-id id) | ||
| 1038 | id)) | ||
| 1039 | |||
| 1040 | |||
| 1001 | ;;; Initialize some variables. | 1041 | ;;; Initialize some variables. |
| 1002 | 1042 | ||
| 1003 | (put 'use-default-ascent 'char-table-extra-slots 0) | 1043 | (put 'use-default-ascent 'char-table-extra-slots 0) |