aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2008-02-24 15:23:45 +0000
committerMiles Bader2008-02-24 15:23:45 +0000
commitf5490ddcb4374e73c07a5729b4cfd7fbffd8b60a (patch)
tree2f080ea4ce2029a6a24c8456d00f449b805f0f32
parent2a36efcfc245388b81913d2b192ee9ca74cb4a04 (diff)
downloademacs-f5490ddcb4374e73c07a5729b4cfd7fbffd8b60a.tar.gz
emacs-f5490ddcb4374e73c07a5729b4cfd7fbffd8b60a.zip
Revert removal of `mm-hack-charsets' in Gnus
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1076
-rw-r--r--lisp/gnus/ChangeLog8
-rw-r--r--lisp/gnus/mm-bodies.el3
-rw-r--r--lisp/gnus/mm-util.el71
-rw-r--r--lisp/gnus/mml.el3
4 files changed, 83 insertions, 2 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 8b65a32aed3..93151d1389e 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,11 @@
12008-02-24 Miles Bader <miles@gnu.org>
2
3 * mm-util.el (mm-hack-charsets, mm-iso-8859-15-compatible)
4 (mm-iso-8859-x-to-15-table, mm-iso-8859-x-to-15-region)
5 (mm-find-mime-charset-region):
6 * mm-bodies.el (mm-encode-body):
7 * mml.el (mml-parse-1): Revert removal of `mm-hack-charsets'.
8
12008-02-16 Reiner Steib <Reiner.Steib@gmx.de> 92008-02-16 Reiner Steib <Reiner.Steib@gmx.de>
2 10
3 * mail-source.el (mail-source-delete-incoming): Change default. 11 * mail-source.el (mail-source-delete-incoming): Change default.
diff --git a/lisp/gnus/mm-bodies.el b/lisp/gnus/mm-bodies.el
index be209a3e004..90d4acbdcd7 100644
--- a/lisp/gnus/mm-bodies.el
+++ b/lisp/gnus/mm-bodies.el
@@ -104,7 +104,8 @@ If no encoding was done, nil is returned."
104 (mm-charset-to-coding-system charset)) 104 (mm-charset-to-coding-system charset))
105 charset) 105 charset)
106 (goto-char (point-min)) 106 (goto-char (point-min))
107 (let ((charsets (mm-find-mime-charset-region (point-min) (point-max)))) 107 (let ((charsets (mm-find-mime-charset-region (point-min) (point-max)
108 mm-hack-charsets)))
108 (cond 109 (cond
109 ;; No encoding. 110 ;; No encoding.
110 ((null charsets) 111 ((null charsets)
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index 2f473ff184c..8e625c936e4 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -576,6 +576,36 @@ with Mule charsets. It is completely useless for Emacs."
576 (push (cons mime (delq 'ascii mule)) alist))) 576 (push (cons mime (delq 'ascii mule)) alist)))
577 (setq mm-mime-mule-charset-alist (nreverse alist))))) 577 (setq mm-mime-mule-charset-alist (nreverse alist)))))
578 578
579(defvar mm-hack-charsets '(iso-8859-15 iso-2022-jp-2)
580 "A list of special charsets.
581Valid elements include:
582`iso-8859-15' convert ISO-8859-1, -9 to ISO-8859-15 if ISO-8859-15 exists.
583`iso-2022-jp-2' convert ISO-2022-jp to ISO-2022-jp-2 if ISO-2022-jp-2 exists."
584)
585
586(defvar mm-iso-8859-15-compatible
587 '((iso-8859-1 "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE")
588 (iso-8859-9 "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE\xD0\xDD\xDE\xF0\xFD\xFE"))
589 "ISO-8859-15 exchangeable coding systems and inconvertible characters.")
590
591(defvar mm-iso-8859-x-to-15-table
592 (and (fboundp 'coding-system-p)
593 (mm-coding-system-p 'iso-8859-15)
594 (mapcar
595 (lambda (cs)
596 (if (mm-coding-system-p (car cs))
597 (let ((c (string-to-char
598 (decode-coding-string "\341" (car cs)))))
599 (cons (char-charset c)
600 (cons
601 (- (string-to-char
602 (decode-coding-string "\341" 'iso-8859-15)) c)
603 (string-to-list (decode-coding-string (car (cdr cs))
604 (car cs))))))
605 '(gnus-charset 0)))
606 mm-iso-8859-15-compatible))
607 "A table of the difference character between ISO-8859-X and ISO-8859-15.")
608
579(defcustom mm-coding-system-priorities 609(defcustom mm-coding-system-priorities
580 (if (boundp 'current-language-environment) 610 (if (boundp 'current-language-environment)
581 (let ((lang (symbol-value 'current-language-environment))) 611 (let ((lang (symbol-value 'current-language-environment)))
@@ -829,6 +859,27 @@ This affects whether coding conversion should be attempted generally."
829 default-enable-multibyte-characters 859 default-enable-multibyte-characters
830 t))) 860 t)))
831 861
862(defun mm-iso-8859-x-to-15-region (&optional b e)
863 (if (fboundp 'char-charset)
864 (let (charset item c inconvertible)
865 (save-restriction
866 (if e (narrow-to-region b e))
867 (goto-char (point-min))
868 (skip-chars-forward "\0-\177")
869 (while (not (eobp))
870 (cond
871 ((not (setq item (assq (char-charset (setq c (char-after)))
872 mm-iso-8859-x-to-15-table)))
873 (forward-char))
874 ((memq c (cdr (cdr item)))
875 (setq inconvertible t)
876 (forward-char))
877 (t
878 (insert-before-markers (prog1 (+ c (car (cdr item)))
879 (delete-char 1)))))
880 (skip-chars-forward "\0-\177")))
881 (not inconvertible))))
882
832(defun mm-sort-coding-systems-predicate (a b) 883(defun mm-sort-coding-systems-predicate (a b)
833 (let ((priorities 884 (let ((priorities
834 (mapcar (lambda (cs) 885 (mapcar (lambda (cs)
@@ -976,6 +1027,26 @@ charset, and a longer list means no appropriate charset."
976 (mapcar 'mm-mime-charset 1027 (mapcar 'mm-mime-charset
977 (delq 'ascii 1028 (delq 'ascii
978 (mm-find-charset-region b e)))))) 1029 (mm-find-charset-region b e))))))
1030 (if (and (> (length charsets) 1)
1031 (memq 'iso-8859-15 charsets)
1032 (memq 'iso-8859-15 hack-charsets)
1033 (save-excursion (mm-iso-8859-x-to-15-region b e)))
1034 (dolist (x mm-iso-8859-15-compatible)
1035 (setq charsets (delq (car x) charsets))))
1036 (if (and (memq 'iso-2022-jp-2 charsets)
1037 (memq 'iso-2022-jp-2 hack-charsets))
1038 (setq charsets (delq 'iso-2022-jp charsets)))
1039 ;; Attempt to reduce the number of charsets if utf-8 is available.
1040 (if (and (featurep 'xemacs)
1041 (> (length charsets) 1)
1042 (mm-coding-system-p 'utf-8))
1043 (let ((mm-coding-system-priorities
1044 (cons 'utf-8 mm-coding-system-priorities)))
1045 (setq charsets
1046 (mm-delete-duplicates
1047 (mapcar 'mm-mime-charset
1048 (delq 'ascii
1049 (mm-find-charset-region b e)))))))
979 charsets)) 1050 charsets))
980 1051
981(defmacro mm-with-unibyte-buffer (&rest forms) 1052(defmacro mm-with-unibyte-buffer (&rest forms)
diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el
index c335e985d0e..2b5987e5e6e 100644
--- a/lisp/gnus/mml.el
+++ b/lisp/gnus/mml.el
@@ -284,7 +284,8 @@ part. This is for the internal use, you should never modify the value.")
284 (list 284 (list
285 (intern (downcase (cdr (assq 'charset tag)))))) 285 (intern (downcase (cdr (assq 'charset tag))))))
286 (t 286 (t
287 (mm-find-mime-charset-region point (point))))) 287 (mm-find-mime-charset-region point (point)
288 mm-hack-charsets))))
288 (when (and (not raw) (memq nil charsets)) 289 (when (and (not raw) (memq nil charsets))
289 (if (or (memq 'unknown-encoding mml-confirmation-set) 290 (if (or (memq 'unknown-encoding mml-confirmation-set)
290 (message-options-get 'unknown-encoding) 291 (message-options-get 'unknown-encoding)