diff options
| -rw-r--r-- | lisp/international/mule.el | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 4291ef9fb4b..3ffb5d982a5 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -438,12 +438,13 @@ coding system whose eol-type is N." | |||
| 438 | 438 | ||
| 439 | (defun make-coding-system (coding-system type mnemonic doc-string | 439 | (defun make-coding-system (coding-system type mnemonic doc-string |
| 440 | &optional flags properties) | 440 | &optional flags properties) |
| 441 | "Define a new CODING-SYSTEM (symbol). | 441 | "Define a new coding system CODING-SYSTEM (symbol). |
| 442 | Remaining arguments are TYPE, MNEMONIC, DOC-STRING, FLAGS (optional), | 442 | Remaining arguments are TYPE, MNEMONIC, DOC-STRING, FLAGS (optional), |
| 443 | and PROPERTIES (optional) which construct a coding-spec of CODING-SYSTEM | 443 | and PROPERTIES (optional) which construct a coding-spec of CODING-SYSTEM |
| 444 | in the following format: | 444 | in the following format: |
| 445 | [TYPE MNEMONIC DOC-STRING PLIST FLAGS] | 445 | [TYPE MNEMONIC DOC-STRING PLIST FLAGS] |
| 446 | TYPE is an integer value indicating the type of coding-system as follows: | 446 | |
| 447 | TYPE is an integer value indicating the type of the coding system as follows: | ||
| 447 | 0: Emacs internal format, | 448 | 0: Emacs internal format, |
| 448 | 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PC, | 449 | 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PC, |
| 449 | 2: ISO-2022 including many variants, | 450 | 2: ISO-2022 including many variants, |
| @@ -451,13 +452,13 @@ TYPE is an integer value indicating the type of coding-system as follows: | |||
| 451 | 4: private, CCL programs provide encoding/decoding algorithm, | 452 | 4: private, CCL programs provide encoding/decoding algorithm, |
| 452 | 5: Raw-text, which means that text contains random 8-bit codes. | 453 | 5: Raw-text, which means that text contains random 8-bit codes. |
| 453 | 454 | ||
| 454 | MNEMONIC is a character to be displayed on mode line for the coding-system. | 455 | MNEMONIC is a character to be displayed on mode line for the coding system. |
| 455 | 456 | ||
| 456 | DOC-STRING is a documentation string for the coding-system. | 457 | DOC-STRING is a documentation string for the coding system. |
| 457 | 458 | ||
| 458 | FLAGS specifies more precise information of each TYPE. | 459 | FLAGS specifies more detailed information of the coding system as follows: |
| 459 | 460 | ||
| 460 | If TYPE is 2 (ISO-2022), FLAGS should be a list of: | 461 | If TYPE is 2 (ISO-2022), FLAGS is a list of these elements: |
| 461 | CHARSET0, CHARSET1, CHARSET2, CHARSET3, SHORT-FORM, | 462 | CHARSET0, CHARSET1, CHARSET2, CHARSET3, SHORT-FORM, |
| 462 | ASCII-EOL, ASCII-CNTL, SEVEN, LOCKING-SHIFT, SINGLE-SHIFT, | 463 | ASCII-EOL, ASCII-CNTL, SEVEN, LOCKING-SHIFT, SINGLE-SHIFT, |
| 463 | USE-ROMAN, USE-OLDJIS, NO-ISO6429, INIT-BOL, DESIGNATION-BOL, | 464 | USE-ROMAN, USE-OLDJIS, NO-ISO6429, INIT-BOL, DESIGNATION-BOL, |
| @@ -487,17 +488,22 @@ FLAGS specifies more precise information of each TYPE. | |||
| 487 | a code specified in `latin-extra-code-table' (which see) as a valid | 488 | a code specified in `latin-extra-code-table' (which see) as a valid |
| 488 | code of the coding system. | 489 | code of the coding system. |
| 489 | 490 | ||
| 490 | 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, for |
| 491 | for decoding and encoding. See the documentation of CCL for more detail. | 492 | decoding and encoding. CCL programs should be specified by their |
| 493 | symbols. | ||
| 492 | 494 | ||
| 493 | PROPERTIES is an alist of properties vs the corresponding values. | 495 | PROPERTIES is an alist of properties vs the corresponding values. |
| 494 | These properties are set in PLIST, a property list. This function | 496 | These properties are set in PLIST, a property list. This function |
| 495 | also sets properties `coding-category' and `alias-coding-systems' | 497 | also sets properties `coding-category' and `alias-coding-systems' |
| 496 | automatically. | 498 | automatically. |
| 497 | 499 | ||
| 498 | Kludgy feature: For backward compatibility, if PROPERTIES is a list of | 500 | Kludgy features for backward compatibility: |
| 499 | character sets, the list is set as a value of `safe-charsets' in | 501 | |
| 500 | PLIST." | 502 | 1. If TYPE is 4 and car or cdr of FLAGS is a vector, the vector is |
| 503 | treated as a compiled CCL code. | ||
| 504 | |||
| 505 | 2. If PROPERTIES is just a list of character sets, the list is set as | ||
| 506 | a value of `safe-charsets' in PLIST." | ||
| 501 | (if (memq coding-system coding-system-list) | 507 | (if (memq coding-system coding-system-list) |
| 502 | (error "Coding system %s already exists" coding-system)) | 508 | (error "Coding system %s already exists" coding-system)) |
| 503 | 509 | ||
| @@ -573,11 +579,17 @@ PLIST." | |||
| 573 | (setq coding-category 'coding-category-big5)) | 579 | (setq coding-category 'coding-category-big5)) |
| 574 | ((= type 4) ; private | 580 | ((= type 4) ; private |
| 575 | (setq coding-category 'coding-category-binary) | 581 | (setq coding-category 'coding-category-binary) |
| 576 | (if (and (consp flags) | 582 | (if (not (consp flags)) |
| 577 | (vectorp (car flags)) | 583 | (error "Invalid FLAGS argument for TYPE 4 (CCL)") |
| 578 | (vectorp (cdr flags))) | 584 | (let ((decoder (check-ccl-program |
| 579 | (aset coding-spec 4 flags) | 585 | (car flags) |
| 580 | (error "Invalid FLAGS argument for TYPE 4 (CCL)"))) | 586 | (intern (format "%s-decoder" coding-system)))) |
| 587 | (encoder (check-ccl-program | ||
| 588 | (cdr flags) | ||
| 589 | (intern (format "%s-encoder" coding-system))))) | ||
| 590 | (if (and decoder encoder) | ||
| 591 | (aset coding-spec 4 (cons decoder encoder)) | ||
| 592 | (error "Invalid FLAGS argument for TYPE 4 (CCL)"))))) | ||
| 581 | (t ; i.e. (= type 5) | 593 | (t ; i.e. (= type 5) |
| 582 | (setq coding-category 'coding-category-raw-text))) | 594 | (setq coding-category 'coding-category-raw-text))) |
| 583 | 595 | ||