diff options
| author | Dave Love | 2000-06-08 15:54:26 +0000 |
|---|---|---|
| committer | Dave Love | 2000-06-08 15:54:26 +0000 |
| commit | e56d79009215572ca4ed80643d1ca38482b32464 (patch) | |
| tree | 728c3960894e24992d24d9fa951da1ffdb7c59e8 | |
| parent | 0b8a3a6df213e39e2420a64a8b505a9008dcc3ff (diff) | |
| download | emacs-e56d79009215572ca4ed80643d1ca38482b32464.tar.gz emacs-e56d79009215572ca4ed80643d1ca38482b32464.zip | |
(select-safe-coding-system): If
DEFAULT-CODING-SYSTEM is not specified, also check the most
preferred coding-system if buffer-file-coding-system is
`undecided'. From handa.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/international/mule-cmds.el | 51 |
2 files changed, 45 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ed96ee213a2..322005b1794 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2000-06-08 Dave Love <fx@gnu.org> | ||
| 2 | |||
| 3 | * international/mule-cmds.el (select-safe-coding-system): If | ||
| 4 | DEFAULT-CODING-SYSTEM is not specified, also check the most | ||
| 5 | preferred coding-system if buffer-file-coding-system is | ||
| 6 | `undecided'. From Handa. | ||
| 7 | |||
| 1 | 2000-06-08 Kenichi Handa <handa@etl.go.jp> | 8 | 2000-06-08 Kenichi Handa <handa@etl.go.jp> |
| 2 | 9 | ||
| 3 | * international/mule.el | 10 | * international/mule.el |
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 33f0da1311e..25a588ef2fb 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -463,7 +463,9 @@ checked at first. If omitted, buffer-file-coding-system of the | |||
| 463 | current buffer is used. | 463 | current buffer is used. |
| 464 | 464 | ||
| 465 | If the text can be encoded safely by DEFAULT-CODING-SYSTEM, it is | 465 | If the text can be encoded safely by DEFAULT-CODING-SYSTEM, it is |
| 466 | returned without any user interaction. | 466 | returned without any user interaction. DEFAULT-CODING-SYSTEM may also |
| 467 | be a list, from which the first coding system that can safely encode the | ||
| 468 | text is chosen, if any can. | ||
| 467 | 469 | ||
| 468 | Kludgy feature: if FROM is a string, the string is the target text, | 470 | Kludgy feature: if FROM is a string, the string is the target text, |
| 469 | and TO is ignored." | 471 | and TO is ignored." |
| @@ -471,15 +473,38 @@ and TO is ignored." | |||
| 471 | (setq default-coding-system buffer-file-coding-system)) | 473 | (setq default-coding-system buffer-file-coding-system)) |
| 472 | (let* ((charsets (if (stringp from) (find-charset-string from) | 474 | (let* ((charsets (if (stringp from) (find-charset-string from) |
| 473 | (find-charset-region from to))) | 475 | (find-charset-region from to))) |
| 474 | (safe-coding-systems (find-coding-systems-for-charsets charsets))) | 476 | (safe-coding-systems (find-coding-systems-for-charsets charsets)) |
| 477 | (coding-system t) ; t means not yet decided. | ||
| 478 | eol-type) | ||
| 475 | (if (or (not enable-multibyte-characters) | 479 | (if (or (not enable-multibyte-characters) |
| 476 | (eq (car safe-coding-systems) 'undecided) | 480 | (eq (car safe-coding-systems) 'undecided)) |
| 477 | (eq default-coding-system 'no-conversion) | 481 | ;; As the text doesn't contain a multibyte character, we can |
| 482 | ;; use any coding system. | ||
| 483 | (setq coding-system default-coding-system) | ||
| 484 | |||
| 485 | ;; Try the default. If the default is nil or undecided, try the | ||
| 486 | ;; most prefered one or one of its subsidiaries that converts | ||
| 487 | ;; EOL as the same way as the default. | ||
| 488 | (if (or (not default-coding-system) | ||
| 489 | (eq (coding-system-base default-coding-system) 'undecided)) | ||
| 490 | (progn | ||
| 491 | (setq eol-type | ||
| 492 | (and default-coding-system | ||
| 493 | (coding-system-eol-type default-coding-system))) | ||
| 494 | (setq default-coding-system | ||
| 495 | (symbol-value (car coding-category-list))) | ||
| 496 | (or (not eol-type) | ||
| 497 | (vectorp eol-type) | ||
| 498 | (setq default-coding-system | ||
| 499 | (coding-system-change-eol-conversion | ||
| 500 | default-coding-system eol-type))))) | ||
| 501 | (if (or (eq default-coding-system 'no-conversion) | ||
| 478 | (and default-coding-system | 502 | (and default-coding-system |
| 479 | (memq (coding-system-base default-coding-system) | 503 | (memq (coding-system-base default-coding-system) |
| 480 | safe-coding-systems))) | 504 | safe-coding-systems))) |
| 481 | default-coding-system | 505 | (setq coding-system default-coding-system))) |
| 482 | 506 | ||
| 507 | (when (eq coding-system t) | ||
| 483 | ;; At first, change each coding system to the corresponding | 508 | ;; At first, change each coding system to the corresponding |
| 484 | ;; mime-charset name if it is also a coding system. | 509 | ;; mime-charset name if it is also a coding system. |
| 485 | (let ((l safe-coding-systems) | 510 | (let ((l safe-coding-systems) |
| @@ -565,17 +590,17 @@ Please select one from the following safe coding systems:\n" | |||
| 565 | (car safe-coding-systems)) | 590 | (car safe-coding-systems)) |
| 566 | safe-names nil t nil nil | 591 | safe-names nil t nil nil |
| 567 | (car (car safe-names))))) | 592 | (car (car safe-names))))) |
| 568 | (setq last-coding-system-specified (intern name)) | 593 | (setq last-coding-system-specified (intern name) |
| 569 | (if (integerp (coding-system-eol-type default-coding-system)) | 594 | coding-system last-coding-system-specified) |
| 570 | (setq last-coding-system-specified | 595 | (or (not eol-type) |
| 571 | (coding-system-change-eol-conversion | 596 | (vectorp eol-type) |
| 572 | last-coding-system-specified | 597 | (setq coding-system (coding-system-change-eol-conversion |
| 573 | (coding-system-eol-type default-coding-system)))) | 598 | coding-system eol-type))))) |
| 574 | last-coding-system-specified)) | ||
| 575 | (kill-buffer "*Warning*") | 599 | (kill-buffer "*Warning*") |
| 576 | (while overlays | 600 | (while overlays |
| 577 | (delete-overlay (car overlays)) | 601 | (delete-overlay (car overlays)) |
| 578 | (setq overlays (cdr overlays))))))))) | 602 | (setq overlays (cdr overlays))))))) |
| 603 | coding-system)) | ||
| 579 | 604 | ||
| 580 | (setq select-safe-coding-system-function 'select-safe-coding-system) | 605 | (setq select-safe-coding-system-function 'select-safe-coding-system) |
| 581 | 606 | ||