Mercurial > emacs
comparison lisp/international/mule-cmds.el @ 89661:e4d881b2d51c
(select-safe-coding-system): Fix for
the case that the first element of default-coding-system is t.
Fix a message when some coding systems are rejected.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 25 Nov 2003 13:03:14 +0000 |
parents | 6f848cbaeb52 |
children | 6e3a816383a4 |
comparison
equal
deleted
inserted
replaced
89660:e43b36fafd30 | 89661:e4d881b2d51c |
---|---|
700 | 700 |
701 (let ((codings (find-coding-systems-region from to)) | 701 (let ((codings (find-coding-systems-region from to)) |
702 (coding-system nil) | 702 (coding-system nil) |
703 (bufname (buffer-name)) | 703 (bufname (buffer-name)) |
704 safe rejected unsafe) | 704 safe rejected unsafe) |
705 (if (eq (car codings) 'undecided) | 705 ;; Classify the defaults into safe, rejected, and unsafe. |
706 ;; Any coding system is ok. | 706 (dolist (elt default-coding-system) |
707 (setq coding-system t) | 707 (if (or (eq (car codings) 'undecided) |
708 ;; Classify the defaults into safe, rejected, and unsafe. | 708 (memq (cdr elt) codings)) |
709 (dolist (elt default-coding-system) | 709 (if (and (functionp accept-default-p) |
710 (if (memq (cdr elt) codings) | 710 (not (funcall accept-default-p (cdr elt)))) |
711 (if (and (functionp accept-default-p) | 711 (push (car elt) rejected) |
712 (not (funcall accept-default-p (cdr elt)))) | 712 (push (car elt) safe)) |
713 (push (car elt) rejected) | 713 (push (car elt) unsafe))) |
714 (push (car elt) safe)) | 714 (if safe |
715 (push (car elt) unsafe))) | 715 (setq coding-system (car safe))) |
716 (if safe | |
717 (setq coding-system (car safe)))) | |
718 | 716 |
719 ;; If all the defaults failed, ask a user. | 717 ;; If all the defaults failed, ask a user. |
720 (when (not coding-system) | 718 (unless coding-system |
721 ;; At first, if some defaults are unsafe, record at most 11 | 719 ;; At first, if some defaults are unsafe, record at most 11 |
722 ;; problematic characters and their positions for them by turning | 720 ;; problematic characters and their positions for them by turning |
723 ;; (CODING ...) | 721 ;; (CODING ...) |
724 ;; into | 722 ;; into |
725 ;; ((CODING (POS . CHAR) (POS . CHAR) ...) ...) | 723 ;; ((CODING (POS . CHAR) (POS . CHAR) ...) ...) |
858 unsafe) | 856 unsafe) |
859 (insert "\ | 857 (insert "\ |
860 The first problematic character is at point in the displayed buffer,\n" | 858 The first problematic character is at point in the displayed buffer,\n" |
861 (substitute-command-keys "\ | 859 (substitute-command-keys "\ |
862 and \\[universal-argument] \\[what-cursor-position] will give information about it.\n")))) | 860 and \\[universal-argument] \\[what-cursor-position] will give information about it.\n")))) |
863 (insert (if safe | 861 (insert (if rejected |
864 "\nSelect the above, or " | 862 "\nSelect the above, or " |
865 "\nSelect ") | 863 "\nSelect ") |
866 "\ | 864 "\ |
867 one of the following safe coding systems, or edit the buffer:\n") | 865 one of the following safe coding systems, or edit the buffer:\n") |
868 (let ((pos (point)) | 866 (let ((pos (point)) |
884 (setq last-coding-system-specified coding-system)) | 882 (setq last-coding-system-specified coding-system)) |
885 | 883 |
886 (kill-buffer "*Warning*") | 884 (kill-buffer "*Warning*") |
887 (set-window-configuration window-configuration))) | 885 (set-window-configuration window-configuration))) |
888 | 886 |
889 (if (vectorp (coding-system-eol-type coding-system)) | 887 (if (and coding-system (vectorp (coding-system-eol-type coding-system))) |
890 (let ((eol (coding-system-eol-type buffer-file-coding-system))) | 888 (let ((eol (coding-system-eol-type buffer-file-coding-system))) |
891 (if (numberp eol) | 889 (if (numberp eol) |
892 (setq coding-system | 890 (setq coding-system |
893 (coding-system-change-eol-conversion coding-system eol))))) | 891 (coding-system-change-eol-conversion coding-system eol))))) |
894 | 892 |
895 (if (eq coding-system t) | |
896 (setq coding-system buffer-file-coding-system)) | |
897 ;; Check we're not inconsistent with what `coding:' spec &c would | 893 ;; Check we're not inconsistent with what `coding:' spec &c would |
898 ;; give when file is re-read. | 894 ;; give when file is re-read. |
899 ;; But don't do this if we explicitly ignored the cookie | 895 ;; But don't do this if we explicitly ignored the cookie |
900 ;; by using `find-file-literally'. | 896 ;; by using `find-file-literally'. |
901 (unless (or (stringp from) find-file-literally) | 897 (unless (or (stringp from) find-file-literally) |