| 566 | | "Add entries for CODING-SYSTEM to `char-coding-system-table'. |
|---|
| 567 | | If SAFE-CHARS is a char-table, its non-nil entries specify characters |
|---|
| 568 | | which CODING-SYSTEM encodes safely. If SAFE-CHARS is t, register |
|---|
| 569 | | CODING-SYSTEM as a general one which can encode all characters." |
|---|
| 570 | | (let ((general (char-table-extra-slot char-coding-system-table 0)) |
|---|
| 571 | | ;; Charsets which have some members in the table, but not all |
|---|
| 572 | | ;; of them (i.e. not just a generic character): |
|---|
| 573 | | (partials (char-table-extra-slot char-coding-system-table 1))) |
|---|
| | 566 | (let ((general (char-table-extra-slot char-coding-system-table 0))) |
|---|
| 579 | | (lambda (key val) |
|---|
| 580 | | (if (and (>= key 128) val) |
|---|
| 581 | | (let ((codings (aref char-coding-system-table key)) |
|---|
| 582 | | (charset (char-charset key))) |
|---|
| 583 | | (unless (memq coding-system codings) |
|---|
| 584 | | (if (and (generic-char-p key) |
|---|
| 585 | | (memq charset partials)) |
|---|
| 586 | | ;; The generic char would clobber individual |
|---|
| 587 | | ;; entries already in the table. First save the |
|---|
| 588 | | ;; separate existing entries for all chars of the |
|---|
| 589 | | ;; charset (with the generic entry added, if |
|---|
| 590 | | ;; necessary). |
|---|
| 591 | | (let (entry existing) |
|---|
| 592 | | (map-charset-chars |
|---|
| 593 | | (lambda (start end) |
|---|
| 594 | | (while (<= start end) |
|---|
| 595 | | (setq entry (aref char-coding-system-table start)) |
|---|
| 596 | | (when entry |
|---|
| 597 | | (push (cons |
|---|
| 598 | | start |
|---|
| 599 | | (if (memq coding-system entry) |
|---|
| 600 | | entry |
|---|
| 601 | | (cons coding-system entry))) |
|---|
| 602 | | existing)) |
|---|
| 603 | | (setq start (1+ start)))) |
|---|
| 604 | | charset) |
|---|
| 605 | | ;; Update the generic entry. |
|---|
| 606 | | (aset char-coding-system-table key |
|---|
| 607 | | (cons coding-system codings)) |
|---|
| 608 | | ;; Override with the saved entries. |
|---|
| 609 | | (dolist (elt existing) |
|---|
| 610 | | (aset char-coding-system-table (car elt) (cdr elt)))) |
|---|
| 611 | | (aset char-coding-system-table key |
|---|
| 612 | | (cons coding-system codings)) |
|---|
| 613 | | (unless (or (memq charset partials) |
|---|
| 614 | | (generic-char-p key)) |
|---|
| 615 | | (push charset partials))))))) |
|---|
| 616 | | safe-chars) |
|---|
| 617 | | (set-char-table-extra-slot char-coding-system-table 1 partials)))) |
|---|
| | 572 | (function |
|---|
| | 573 | (lambda (key val) |
|---|
| | 574 | (if (and (>= key 128) val) |
|---|
| | 575 | (let ((codings (aref char-coding-system-table key))) |
|---|
| | 576 | (or (memq coding-system codings) |
|---|
| | 577 | (aset char-coding-system-table key |
|---|
| | 578 | (cons coding-system codings))))))) |
|---|
| | 579 | safe-chars)))) |
|---|