aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2004-12-06 12:37:22 +0000
committerKenichi Handa2004-12-06 12:37:22 +0000
commita77c22c2772ba89f43c0dfc18fb26d4ca801d5f4 (patch)
tree4e9b6152a2c04647ef7589a24249045e6369b6df
parent7f4649179e24d3c4fbbb8234af77a2164df2d374 (diff)
downloademacs-a77c22c2772ba89f43c0dfc18fb26d4ca801d5f4.tar.gz
emacs-a77c22c2772ba89f43c0dfc18fb26d4ca801d5f4.zip
(select-safe-coding-system-interactively):
Change 'mime-charset to :mime-charset. (select-safe-coding-system): Use above (sync to HEAD). (set-language-environment): Delete unnecessary code for handling overriding-fontspec
-rw-r--r--lisp/international/mule-cmds.el182
1 files changed, 5 insertions, 177 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index fca6c6a18ab..3de363a596f 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -649,8 +649,9 @@ DEFAULT is the coding system to use by default in the query."
649 (let ((l codings) 649 (let ((l codings)
650 mime-charset) 650 mime-charset)
651 (while l 651 (while l
652 (setq mime-charset (coding-system-get (car l) 'mime-charset)) 652 (setq mime-charset (coding-system-get (car l) :mime-charset))
653 (if (and mime-charset (coding-system-p mime-charset)) 653 (if (and mime-charset (coding-system-p mime-charset)
654 (coding-system-equal (car l) mime-charset))
654 (setcar l mime-charset)) 655 (setcar l mime-charset))
655 (setq l (cdr l)))) 656 (setq l (cdr l))))
656 657
@@ -890,173 +891,8 @@ and TO is ignored."
890 891
891 ;; If all the defaults failed, ask a user. 892 ;; If all the defaults failed, ask a user.
892 (unless coding-system 893 (unless coding-system
893 ;; At first, if some defaults are unsafe, record at most 11 894 (setq coding-system (select-safe-coding-system-interactively
894 ;; problematic characters and their positions for them by turning 895 from to codings unsafe rejected (car codings))))
895 ;; (CODING ...)
896 ;; into
897 ;; ((CODING (POS . CHAR) (POS . CHAR) ...) ...)
898 (if unsafe
899 (if (stringp from)
900 (setq unsafe
901 (mapcar #'(lambda (coding)
902 (cons coding
903 (mapcar #'(lambda (pos)
904 (cons pos (aref from pos)))
905 (unencodable-char-position
906 0 (length from) coding
907 11 from))))
908 unsafe))
909 (setq unsafe
910 (mapcar #'(lambda (coding)
911 (cons coding
912 (mapcar #'(lambda (pos)
913 (cons pos (char-after pos)))
914 (unencodable-char-position
915 from to coding 11))))
916 unsafe))))
917
918 ;; Change each safe coding system to the corresponding
919 ;; mime-charset name if it is also a coding system. Such a name
920 ;; is more friendly to users.
921 (let ((l codings)
922 mime-charset)
923 (while l
924 (setq mime-charset (coding-system-get (car l) :mime-charset))
925 (if (and mime-charset (coding-system-p mime-charset)
926 (coding-system-equal (car l) mime-charset))
927 (setcar l mime-charset))
928 (setq l (cdr l))))
929
930 ;; Don't offer variations with locking shift, which you
931 ;; basically never want.
932 (let (l)
933 (dolist (elt codings (setq codings (nreverse l)))
934 (unless (or (eq 'coding-category-iso-7-else
935 (coding-system-category elt))
936 (eq 'coding-category-iso-8-else
937 (coding-system-category elt)))
938 (push elt l))))
939
940 ;; Remove raw-text, emacs-mule and no-conversion unless nothing
941 ;; else is available.
942 (setq codings
943 (or (delq 'raw-text
944 (delq 'emacs-mule
945 (delq 'no-conversion codings)))
946 '(raw-text emacs-mule no-conversion)))
947
948 (let ((window-configuration (current-window-configuration)))
949 (save-excursion
950 ;; If some defaults are unsafe, make sure the offending
951 ;; buffer is displayed.
952 (when (and unsafe (not (stringp from)))
953 (pop-to-buffer bufname)
954 (goto-char (apply 'min (mapcar #'(lambda (x) (car (cadr x)))
955 unsafe))))
956 ;; Then ask users to select one from CODINGS while showing
957 ;; the reason why none of the defaults are not used.
958 (with-output-to-temp-buffer "*Warning*"
959 (save-excursion
960 (set-buffer standard-output)
961 (if (not default-coding-system)
962 (insert "No default coding systems to try for "
963 (if (stringp from)
964 (format "string \"%s\"." from)
965 (format "buffer `%s'." bufname)))
966 (insert
967 "These default coding systems were tried to encode"
968 (if (stringp from)
969 (concat " \"" (if (> (length from) 10)
970 (concat (substring from 0 10) "...\"")
971 (concat from "\"")))
972 (format " text\nin the buffer `%s'" bufname))
973 ":\n")
974 (let ((pos (point))
975 (fill-prefix " "))
976 (mapc #'(lambda (x) (princ " ") (princ (car x)))
977 default-coding-system)
978 (insert "\n")
979 (fill-region-as-paragraph pos (point)))
980 (when rejected
981 (insert "These safely encodes the target text,
982but it is not recommended for encoding text in this context,
983e.g., for sending an email message.\n ")
984 (mapc #'(lambda (x) (princ " ") (princ x)) rejected)
985 (insert "\n"))
986 (when unsafe
987 (insert (if rejected "And the others"
988 "However, each of them")
989 " encountered these problematic characters:\n")
990 (mapc
991 #'(lambda (coding)
992 (insert (format " %s:" (car coding)))
993 (let ((i 0)
994 (func1
995 #'(lambda (bufname pos)
996 (when (buffer-live-p (get-buffer bufname))
997 (pop-to-buffer bufname)
998 (goto-char pos))))
999 (func2
1000 #'(lambda (bufname pos coding)
1001 (when (buffer-live-p (get-buffer bufname))
1002 (pop-to-buffer bufname)
1003 (if (< (point) pos)
1004 (goto-char pos)
1005 (forward-char 1)
1006 (search-unencodable-char coding)
1007 (forward-char -1))))))
1008 (dolist (elt (cdr coding))
1009 (insert " ")
1010 (if (stringp from)
1011 (insert (if (< i 10) (cdr elt) "..."))
1012 (if (< i 10)
1013 (insert-text-button
1014 (cdr elt)
1015 :type 'help-xref
1016 'help-echo
1017 "mouse-2, RET: jump to this character"
1018 'help-function func1
1019 'help-args (list bufname (car elt)))
1020 (insert-text-button
1021 "..."
1022 :type 'help-xref
1023 'help-echo
1024 "mouse-2, RET: next unencodable character"
1025 'help-function func2
1026 'help-args (list bufname (car elt)
1027 (car coding)))))
1028 (setq i (1+ i))))
1029 (insert "\n"))
1030 unsafe)
1031 (insert "\
1032The first problematic character is at point in the displayed buffer,\n"
1033 (substitute-command-keys "\
1034and \\[universal-argument] \\[what-cursor-position] will give information about it.\n"))))
1035 (insert (if rejected
1036 "\nSelect the above, or "
1037 "\nSelect ")
1038 "\
1039one of the following safe coding systems, or edit the buffer:\n")
1040 (let ((pos (point))
1041 (fill-prefix " "))
1042 (mapcar (function (lambda (x) (princ " ") (princ x)))
1043 codings)
1044 (insert "\n")
1045 (fill-region-as-paragraph pos (point)))
1046 (insert "Or specify any other coding system
1047at the risk of losing the problematic characters.\n")))
1048
1049 ;; Read a coding system.
1050 (setq default-coding-system (or (car safe) (car codings)))
1051 (setq coding-system
1052 (read-coding-system
1053 (format "Select coding system (default %s): "
1054 default-coding-system)
1055 default-coding-system))
1056 (setq last-coding-system-specified coding-system))
1057
1058 (kill-buffer "*Warning*")
1059 (set-window-configuration window-configuration)))
1060 896
1061 (if (and coding-system (vectorp (coding-system-eol-type coding-system))) 897 (if (and coding-system (vectorp (coding-system-eol-type coding-system)))
1062 (let ((eol (coding-system-eol-type buffer-file-coding-system))) 898 (let ((eol (coding-system-eol-type buffer-file-coding-system)))
@@ -1927,14 +1763,6 @@ specifies the character set for the major languages of Western Europe."
1927 (require (car required-features)) 1763 (require (car required-features))
1928 (setq required-features (cdr required-features)))) 1764 (setq required-features (cdr required-features))))
1929 1765
1930 ;; Don't invoke fontset-related functions if fontsets aren't
1931 ;; supported in this build of Emacs.
1932 (when (fboundp 'fontset-list)
1933 (let ((overriding-fontspec (get-language-info language-name
1934 'overriding-fontspec)))
1935 (if overriding-fontspec
1936 (set-overriding-fontspec-internal overriding-fontspec))))
1937
1938 (let ((func (get-language-info language-name 'setup-function))) 1766 (let ((func (get-language-info language-name 'setup-function)))
1939 (if (functionp func) 1767 (if (functionp func)
1940 (funcall func))) 1768 (funcall func)))