diff options
| author | Kenichi Handa | 2003-05-22 01:50:11 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-05-22 01:50:11 +0000 |
| commit | a985cd2f2ae3027fdc4835a24a1ef992588ce455 (patch) | |
| tree | 9c92ba8ac628935c5d2c6d5e200ee66a0fed9067 | |
| parent | c67de8bae7a302efad1db433de6fc455c6602d62 (diff) | |
| download | emacs-a985cd2f2ae3027fdc4835a24a1ef992588ce455.tar.gz emacs-a985cd2f2ae3027fdc4835a24a1ef992588ce455.zip | |
(select-safe-coding-system): Try
default-buffer-file-coding-system too for automatic selection.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/international/mule-cmds.el | 36 |
2 files changed, 28 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 04c8b488364..69f7c007df7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2003-05-22 Stefan Monnier <monnier@cs.yale.edu> | ||
| 2 | |||
| 3 | * international/mule-cmds.el (select-safe-coding-system): Try | ||
| 4 | default-buffer-file-coding-system too for automatic selection. | ||
| 5 | |||
| 1 | 2003-05-21 Dave Love <fx@gnu.org> | 6 | 2003-05-21 Dave Love <fx@gnu.org> |
| 2 | 7 | ||
| 3 | * descr-text.el (unicodedata-file): New. | 8 | * descr-text.el (unicodedata-file): New. |
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 9754ec00020..e9b769d9c12 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; mule-cmds.el --- commands for mulitilingual environment | 1 | ;;; mule-cmds.el --- commands for mulitilingual environment |
| 2 | ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | 2 | ;; Copyright (C) 1995, 2003 Electrotechnical Laboratory, JAPAN. |
| 3 | ;; Licensed to the Free Software Foundation. | 3 | ;; Licensed to the Free Software Foundation. |
| 4 | ;; Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | 4 | ;; Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
| 5 | 5 | ||
| @@ -631,7 +631,8 @@ The candidates of coding systems which can safely encode a text | |||
| 631 | between FROM and TO are shown in a popup window. Among them, the most | 631 | between FROM and TO are shown in a popup window. Among them, the most |
| 632 | proper one is suggested as the default. | 632 | proper one is suggested as the default. |
| 633 | 633 | ||
| 634 | The list of `buffer-file-coding-system' of the current buffer and the | 634 | The list of `buffer-file-coding-system' of the current buffer, |
| 635 | the `default-buffer-file-coding-system', and the | ||
| 635 | most preferred coding system (if it corresponds to a MIME charset) is | 636 | most preferred coding system (if it corresponds to a MIME charset) is |
| 636 | treated as the default coding system list. Among them, the first one | 637 | treated as the default coding system list. Among them, the first one |
| 637 | that safely encodes the text is normally selected silently and | 638 | that safely encodes the text is normally selected silently and |
| @@ -648,8 +649,8 @@ Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a | |||
| 648 | list of coding systems to be prepended to the default coding system | 649 | list of coding systems to be prepended to the default coding system |
| 649 | list. However, if DEFAULT-CODING-SYSTEM is a list and the first | 650 | list. However, if DEFAULT-CODING-SYSTEM is a list and the first |
| 650 | element is t, the cdr part is used as the defualt coding system list, | 651 | element is t, the cdr part is used as the defualt coding system list, |
| 651 | i.e. `buffer-file-coding-system' and the most prepended coding system | 652 | i.e. `buffer-file-coding-system', `default-buffer-file-coding-system', |
| 652 | is not used. | 653 | and the most preferred coding system are not used. |
| 653 | 654 | ||
| 654 | Optional 4th arg ACCEPT-DEFAULT-P, if non-nil, is a function to | 655 | Optional 4th arg ACCEPT-DEFAULT-P, if non-nil, is a function to |
| 655 | determine the acceptability of the silently selected coding system. | 656 | determine the acceptability of the silently selected coding system. |
| @@ -679,6 +680,9 @@ and TO is ignored." | |||
| 679 | (mapcar (function (lambda (x) (cons x (coding-system-base x)))) | 680 | (mapcar (function (lambda (x) (cons x (coding-system-base x)))) |
| 680 | default-coding-system)) | 681 | default-coding-system)) |
| 681 | 682 | ||
| 683 | ;; From now on, the list of defaults is reversed. | ||
| 684 | (setq default-coding-system (nreverse default-coding-system)) | ||
| 685 | |||
| 682 | (unless no-other-defaults | 686 | (unless no-other-defaults |
| 683 | ;; If buffer-file-coding-system is not nil nor undecided, append it | 687 | ;; If buffer-file-coding-system is not nil nor undecided, append it |
| 684 | ;; to the defaults. | 688 | ;; to the defaults. |
| @@ -686,24 +690,30 @@ and TO is ignored." | |||
| 686 | (let ((base (coding-system-base buffer-file-coding-system))) | 690 | (let ((base (coding-system-base buffer-file-coding-system))) |
| 687 | (or (eq base 'undecided) | 691 | (or (eq base 'undecided) |
| 688 | (rassq base default-coding-system) | 692 | (rassq base default-coding-system) |
| 689 | (setq default-coding-system | 693 | (push (cons buffer-file-coding-system base) |
| 690 | (append default-coding-system | 694 | default-coding-system)))) |
| 691 | (list (cons buffer-file-coding-system base))))))) | 695 | |
| 696 | ;; If default-buffer-file-coding-system is not nil nor undecided, | ||
| 697 | ;; append it to the defaults. | ||
| 698 | (if default-buffer-file-coding-system | ||
| 699 | (let ((base (coding-system-base default-buffer-file-coding-system))) | ||
| 700 | (or (eq base 'undecided) | ||
| 701 | (rassq base default-coding-system) | ||
| 702 | (push (cons default-buffer-file-coding-system base) | ||
| 703 | default-coding-system)))) | ||
| 692 | 704 | ||
| 693 | ;; If the most preferred coding system has the property mime-charset, | 705 | ;; If the most preferred coding system has the property mime-charset, |
| 694 | ;; append it to the defaults. | 706 | ;; append it to the defaults. |
| 695 | (let ((tail coding-category-list) | 707 | (let ((tail coding-category-list) |
| 696 | preferred base) | 708 | preferred base) |
| 697 | (while (and tail | 709 | (while (and tail (not (setq preferred (symbol-value (car tail))))) |
| 698 | (not (setq preferred (symbol-value (car tail))))) | ||
| 699 | (setq tail (cdr tail))) | 710 | (setq tail (cdr tail))) |
| 700 | (and (coding-system-p preferred) | 711 | (and (coding-system-p preferred) |
| 701 | (setq base (coding-system-base preferred)) | 712 | (setq base (coding-system-base preferred)) |
| 702 | (coding-system-get preferred 'mime-charset) | 713 | (coding-system-get preferred 'mime-charset) |
| 703 | (not (rassq base default-coding-system)) | 714 | (not (rassq base default-coding-system)) |
| 704 | (setq default-coding-system | 715 | (push (cons preferred base) |
| 705 | (append default-coding-system | 716 | default-coding-system))))) |
| 706 | (list (cons preferred base)))))))) | ||
| 707 | 717 | ||
| 708 | (if select-safe-coding-system-accept-default-p | 718 | (if select-safe-coding-system-accept-default-p |
| 709 | (setq accept-default-p select-safe-coding-system-accept-default-p)) | 719 | (setq accept-default-p select-safe-coding-system-accept-default-p)) |
| @@ -724,7 +734,7 @@ and TO is ignored." | |||
| 724 | (push (car elt) safe)) | 734 | (push (car elt) safe)) |
| 725 | (push (car elt) unsafe))) | 735 | (push (car elt) unsafe))) |
| 726 | (if safe | 736 | (if safe |
| 727 | (setq coding-system (car (last safe))))) | 737 | (setq coding-system (car safe)))) |
| 728 | 738 | ||
| 729 | ;; If all the defaults failed, ask a user. | 739 | ;; If all the defaults failed, ask a user. |
| 730 | (when (not coding-system) | 740 | (when (not coding-system) |