diff options
| author | Kenichi Handa | 2006-07-20 11:28:48 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2006-07-20 11:28:48 +0000 |
| commit | ccb063408798294ae58efe52f9e3a5c5ef0fe81d (patch) | |
| tree | 3424d990373154640f8eb87a41807aea752b6948 | |
| parent | 26b8f810d0ef4c002215a99f77de3625956c5607 (diff) | |
| download | emacs-ccb063408798294ae58efe52f9e3a5c5ef0fe81d.tar.gz emacs-ccb063408798294ae58efe52f9e3a5c5ef0fe81d.zip | |
(select-safe-coding-system): Fix the
way of deciding eol-type of the coding system.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/international/mule-cmds.el | 52 |
2 files changed, 38 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a71ea08d741..d73fa96056a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2006-07-20 Kenichi Handa <handa@m17n.org> | ||
| 2 | |||
| 3 | * international/mule-cmds.el (select-safe-coding-system): Fix the | ||
| 4 | way of deciding eol-type of the coding system. | ||
| 5 | |||
| 1 | 2006-07-20 Alan Mackenzie <acm@muc.de> | 6 | 2006-07-20 Alan Mackenzie <acm@muc.de> |
| 2 | 7 | ||
| 3 | * progmodes/cc-langs.el (c-emacs-variable-inits): new variable. | 8 | * progmodes/cc-langs.el (c-emacs-variable-inits): new variable. |
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index ae664121a5d..9adc4746b91 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -831,7 +831,7 @@ re-visited and edited.) | |||
| 831 | Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a | 831 | Optional 3rd arg DEFAULT-CODING-SYSTEM specifies a coding system or a |
| 832 | list of coding systems to be prepended to the default coding system | 832 | list of coding systems to be prepended to the default coding system |
| 833 | list. However, if DEFAULT-CODING-SYSTEM is a list and the first | 833 | list. However, if DEFAULT-CODING-SYSTEM is a list and the first |
| 834 | element is t, the cdr part is used as the defualt coding system list, | 834 | element is t, the cdr part is used as the default coding system list, |
| 835 | i.e. `buffer-file-coding-system', `default-buffer-file-coding-system', | 835 | i.e. `buffer-file-coding-system', `default-buffer-file-coding-system', |
| 836 | and the most preferred coding system are not used. | 836 | and the most preferred coding system are not used. |
| 837 | 837 | ||
| @@ -898,9 +898,6 @@ It is highly recommended to fix it before writing to a file." | |||
| 898 | (rassq base default-coding-system) | 898 | (rassq base default-coding-system) |
| 899 | (push (cons auto-cs base) default-coding-system)))) | 899 | (push (cons auto-cs base) default-coding-system)))) |
| 900 | 900 | ||
| 901 | ;; From now on, the list of defaults is reversed. | ||
| 902 | (setq default-coding-system (nreverse default-coding-system)) | ||
| 903 | |||
| 904 | (unless no-other-defaults | 901 | (unless no-other-defaults |
| 905 | ;; If buffer-file-coding-system is not nil nor undecided, append it | 902 | ;; If buffer-file-coding-system is not nil nor undecided, append it |
| 906 | ;; to the defaults. | 903 | ;; to the defaults. |
| @@ -908,8 +905,9 @@ It is highly recommended to fix it before writing to a file." | |||
| 908 | (let ((base (coding-system-base buffer-file-coding-system))) | 905 | (let ((base (coding-system-base buffer-file-coding-system))) |
| 909 | (or (eq base 'undecided) | 906 | (or (eq base 'undecided) |
| 910 | (rassq base default-coding-system) | 907 | (rassq base default-coding-system) |
| 911 | (push (cons buffer-file-coding-system base) | 908 | (setq default-coding-system |
| 912 | default-coding-system)))) | 909 | (append default-coding-system |
| 910 | (list (cons buffer-file-coding-system base))))))) | ||
| 913 | 911 | ||
| 914 | ;; If default-buffer-file-coding-system is not nil nor undecided, | 912 | ;; If default-buffer-file-coding-system is not nil nor undecided, |
| 915 | ;; append it to the defaults. | 913 | ;; append it to the defaults. |
| @@ -917,8 +915,10 @@ It is highly recommended to fix it before writing to a file." | |||
| 917 | (let ((base (coding-system-base default-buffer-file-coding-system))) | 915 | (let ((base (coding-system-base default-buffer-file-coding-system))) |
| 918 | (or (eq base 'undecided) | 916 | (or (eq base 'undecided) |
| 919 | (rassq base default-coding-system) | 917 | (rassq base default-coding-system) |
| 920 | (push (cons default-buffer-file-coding-system base) | 918 | (setq default-coding-system |
| 921 | default-coding-system)))) | 919 | (append default-coding-system |
| 920 | (list (cons default-buffer-file-coding-system | ||
| 921 | base))))))) | ||
| 922 | 922 | ||
| 923 | ;; If the most preferred coding system has the property mime-charset, | 923 | ;; If the most preferred coding system has the property mime-charset, |
| 924 | ;; append it to the defaults. | 924 | ;; append it to the defaults. |
| @@ -930,18 +930,40 @@ It is highly recommended to fix it before writing to a file." | |||
| 930 | (setq base (coding-system-base preferred)) | 930 | (setq base (coding-system-base preferred)) |
| 931 | (coding-system-get preferred 'mime-charset) | 931 | (coding-system-get preferred 'mime-charset) |
| 932 | (not (rassq base default-coding-system)) | 932 | (not (rassq base default-coding-system)) |
| 933 | (push (cons preferred base) | 933 | (setq default-coding-system |
| 934 | default-coding-system)))) | 934 | (append default-coding-system |
| 935 | (list (cons preferred base))))))) | ||
| 935 | 936 | ||
| 936 | (if select-safe-coding-system-accept-default-p | 937 | (if select-safe-coding-system-accept-default-p |
| 937 | (setq accept-default-p select-safe-coding-system-accept-default-p)) | 938 | (setq accept-default-p select-safe-coding-system-accept-default-p)) |
| 938 | 939 | ||
| 940 | ;; Decide the eol-type from the top of the default codings, | ||
| 941 | ;; buffer-file-coding-system, or | ||
| 942 | ;; default-buffer-file-coding-system. | ||
| 943 | (if default-coding-system | ||
| 944 | (let ((default-eol-type (coding-system-eol-type | ||
| 945 | (caar default-coding-system)))) | ||
| 946 | (if (and (vectorp default-eol-type) buffer-file-coding-system) | ||
| 947 | (setq default-eol-type (coding-system-eol-type | ||
| 948 | buffer-file-coding-system))) | ||
| 949 | (if (and (vectorp default-eol-type) default-buffer-file-coding-system) | ||
| 950 | (setq default-eol-type (coding-system-eol-type | ||
| 951 | default-buffer-file-coding-system))) | ||
| 952 | (if (and default-eol-type (not (vectorp default-eol-type))) | ||
| 953 | (dolist (elt default-coding-system) | ||
| 954 | (setcar elt (coding-system-change-eol-conversion | ||
| 955 | (car elt) default-eol-type)))))) | ||
| 956 | |||
| 939 | (let ((codings (find-coding-systems-region from to)) | 957 | (let ((codings (find-coding-systems-region from to)) |
| 940 | (coding-system nil) | 958 | (coding-system nil) |
| 941 | safe rejected unsafe) | 959 | safe rejected unsafe) |
| 942 | (if (eq (car codings) 'undecided) | 960 | (if (eq (car codings) 'undecided) |
| 943 | ;; Any coding system is ok. | 961 | ;; Any coding system is ok. |
| 944 | (setq coding-system t) | 962 | (setq coding-system (caar default-coding-system)) |
| 963 | ;; Reverse the list so that elements are accumulated in safe, | ||
| 964 | ;; rejected, and unsafe in the correct order. | ||
| 965 | (setq default-coding-system (nreverse default-coding-system)) | ||
| 966 | |||
| 945 | ;; Classify the defaults into safe, rejected, and unsafe. | 967 | ;; Classify the defaults into safe, rejected, and unsafe. |
| 946 | (dolist (elt default-coding-system) | 968 | (dolist (elt default-coding-system) |
| 947 | (if (memq (cdr elt) codings) | 969 | (if (memq (cdr elt) codings) |
| @@ -958,14 +980,6 @@ It is highly recommended to fix it before writing to a file." | |||
| 958 | (setq coding-system (select-safe-coding-system-interactively | 980 | (setq coding-system (select-safe-coding-system-interactively |
| 959 | from to codings unsafe rejected (car codings)))) | 981 | from to codings unsafe rejected (car codings)))) |
| 960 | 982 | ||
| 961 | (if (vectorp (coding-system-eol-type coding-system)) | ||
| 962 | (let ((eol (coding-system-eol-type buffer-file-coding-system))) | ||
| 963 | (if (numberp eol) | ||
| 964 | (setq coding-system | ||
| 965 | (coding-system-change-eol-conversion coding-system eol))))) | ||
| 966 | |||
| 967 | (if (eq coding-system t) | ||
| 968 | (setq coding-system buffer-file-coding-system)) | ||
| 969 | ;; Check we're not inconsistent with what `coding:' spec &c would | 983 | ;; Check we're not inconsistent with what `coding:' spec &c would |
| 970 | ;; give when file is re-read. | 984 | ;; give when file is re-read. |
| 971 | ;; But don't do this if we explicitly ignored the cookie | 985 | ;; But don't do this if we explicitly ignored the cookie |