diff options
| author | Andreas Schwab | 1999-02-08 09:50:26 +0000 |
|---|---|---|
| committer | Andreas Schwab | 1999-02-08 09:50:26 +0000 |
| commit | 857ea15ca99ef305572ab55e2039ddfe6b573848 (patch) | |
| tree | 818354d5e0631c75c4c9f78d773da806c2cf52fb | |
| parent | 9a092df0810107a9a572edf1f7835fec3f01a003 (diff) | |
| download | emacs-857ea15ca99ef305572ab55e2039ddfe6b573848.tar.gz emacs-857ea15ca99ef305572ab55e2039ddfe6b573848.zip | |
(coding-system-lessp): Moved here from
mule-util.el
(add-to-coding-system-list): New function.
(make-subsidiary-coding-system, make-coding-system,
define-coding-system-alias): Use it instead of setting
coding-system-list directly.
| -rw-r--r-- | lisp/international/mule.el | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el index c7800d85f01..a1fb36cb619 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el | |||
| @@ -445,6 +445,34 @@ detected automatically. Nth element of the vector is the subsidiary | |||
| 445 | coding system whose eol-type is N." | 445 | coding system whose eol-type is N." |
| 446 | (get coding-system 'eol-type)) | 446 | (get coding-system 'eol-type)) |
| 447 | 447 | ||
| 448 | (defun coding-system-lessp (x y) | ||
| 449 | (cond ((eq x 'no-conversion) t) | ||
| 450 | ((eq y 'no-conversion) nil) | ||
| 451 | ((eq x 'emacs-mule) t) | ||
| 452 | ((eq y 'emacs-mule) nil) | ||
| 453 | ((eq x 'undecided) t) | ||
| 454 | ((eq y 'undecided) nil) | ||
| 455 | (t (let ((c1 (coding-system-mnemonic x)) | ||
| 456 | (c2 (coding-system-mnemonic y))) | ||
| 457 | (or (< (downcase c1) (downcase c2)) | ||
| 458 | (and (not (> (downcase c1) (downcase c2))) | ||
| 459 | (< c1 c2))))))) | ||
| 460 | |||
| 461 | ;; Add CODING-SYSTEM to coding-system-list while keeping it sorted. | ||
| 462 | (defun add-to-coding-system-list (coding-system) | ||
| 463 | (if (or (null coding-system-list) | ||
| 464 | (coding-system-lessp coding-system (car coding-system-list))) | ||
| 465 | (setq coding-system-list (cons coding-system coding-system-list)) | ||
| 466 | (let ((len (length coding-system-list)) | ||
| 467 | mid (tem coding-system-list)) | ||
| 468 | (while (> len 1) | ||
| 469 | (setq mid (nthcdr (/ len 2) tem)) | ||
| 470 | (if (coding-system-lessp (car mid) coding-system) | ||
| 471 | (setq tem mid | ||
| 472 | len (- len (/ len 2))) | ||
| 473 | (setq len (/ len 2)))) | ||
| 474 | (setcdr tem (cons coding-system (cdr tem)))))) | ||
| 475 | |||
| 448 | ;; Make subsidiary coding systems (eol-type variants) of CODING-SYSTEM. | 476 | ;; Make subsidiary coding systems (eol-type variants) of CODING-SYSTEM. |
| 449 | (defun make-subsidiary-coding-system (coding-system) | 477 | (defun make-subsidiary-coding-system (coding-system) |
| 450 | (let ((coding-spec (coding-system-spec coding-system)) | 478 | (let ((coding-spec (coding-system-spec coding-system)) |
| @@ -456,8 +484,7 @@ coding system whose eol-type is N." | |||
| 456 | (while (< i 3) | 484 | (while (< i 3) |
| 457 | (put (aref subsidiaries i) 'coding-system coding-spec) | 485 | (put (aref subsidiaries i) 'coding-system coding-spec) |
| 458 | (put (aref subsidiaries i) 'eol-type i) | 486 | (put (aref subsidiaries i) 'eol-type i) |
| 459 | (setq coding-system-list | 487 | (add-to-coding-system-list (aref subsidiaries i)) |
| 460 | (cons (aref subsidiaries i) coding-system-list)) | ||
| 461 | (setq coding-system-alist | 488 | (setq coding-system-alist |
| 462 | (cons (list (symbol-name (aref subsidiaries i))) | 489 | (cons (list (symbol-name (aref subsidiaries i))) |
| 463 | coding-system-alist)) | 490 | coding-system-alist)) |
| @@ -653,7 +680,7 @@ a value of `safe-charsets' in PLIST." | |||
| 653 | 680 | ||
| 654 | ;; At last, register CODING-SYSTEM in `coding-system-list' and | 681 | ;; At last, register CODING-SYSTEM in `coding-system-list' and |
| 655 | ;; `coding-system-alist'. | 682 | ;; `coding-system-alist'. |
| 656 | (setq coding-system-list (cons coding-system coding-system-list)) | 683 | (add-to-coding-system-list coding-system) |
| 657 | (setq coding-system-alist (cons (list (symbol-name coding-system)) | 684 | (setq coding-system-alist (cons (list (symbol-name coding-system)) |
| 658 | coding-system-alist)) | 685 | coding-system-alist)) |
| 659 | 686 | ||
| @@ -678,7 +705,7 @@ a value of `safe-charsets' in PLIST." | |||
| 678 | "Define ALIAS as an alias for coding system CODING-SYSTEM." | 705 | "Define ALIAS as an alias for coding system CODING-SYSTEM." |
| 679 | (put alias 'coding-system (coding-system-spec coding-system)) | 706 | (put alias 'coding-system (coding-system-spec coding-system)) |
| 680 | (nconc (coding-system-get alias 'alias-coding-systems) (list alias)) | 707 | (nconc (coding-system-get alias 'alias-coding-systems) (list alias)) |
| 681 | (setq coding-system-list (cons alias coding-system-list)) | 708 | (add-to-coding-system-list alias) |
| 682 | (setq coding-system-alist (cons (list (symbol-name alias)) | 709 | (setq coding-system-alist (cons (list (symbol-name alias)) |
| 683 | coding-system-alist)) | 710 | coding-system-alist)) |
| 684 | (let ((eol-type (coding-system-eol-type coding-system))) | 711 | (let ((eol-type (coding-system-eol-type coding-system))) |