# HG changeset patch # User Miles Bader # Date 1203866625 0 # Node ID 37d6263f580b9d5c60b174379d5509a88b109570 # Parent 2c181d4110e5c260e35a8a0ad08f4ea5025562ab Revert removal of `mm-hack-charsets' in Gnus Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1076 diff -r 2c181d4110e5 -r 37d6263f580b lisp/gnus/ChangeLog --- a/lisp/gnus/ChangeLog Sun Feb 24 15:08:06 2008 +0000 +++ b/lisp/gnus/ChangeLog Sun Feb 24 15:23:45 2008 +0000 @@ -1,3 +1,11 @@ +2008-02-24 Miles Bader + + * mm-util.el (mm-hack-charsets, mm-iso-8859-15-compatible) + (mm-iso-8859-x-to-15-table, mm-iso-8859-x-to-15-region) + (mm-find-mime-charset-region): + * mm-bodies.el (mm-encode-body): + * mml.el (mml-parse-1): Revert removal of `mm-hack-charsets'. + 2008-02-16 Reiner Steib * mail-source.el (mail-source-delete-incoming): Change default. diff -r 2c181d4110e5 -r 37d6263f580b lisp/gnus/mm-bodies.el --- a/lisp/gnus/mm-bodies.el Sun Feb 24 15:08:06 2008 +0000 +++ b/lisp/gnus/mm-bodies.el Sun Feb 24 15:23:45 2008 +0000 @@ -104,7 +104,8 @@ (mm-charset-to-coding-system charset)) charset) (goto-char (point-min)) - (let ((charsets (mm-find-mime-charset-region (point-min) (point-max)))) + (let ((charsets (mm-find-mime-charset-region (point-min) (point-max) + mm-hack-charsets))) (cond ;; No encoding. ((null charsets) diff -r 2c181d4110e5 -r 37d6263f580b lisp/gnus/mm-util.el --- a/lisp/gnus/mm-util.el Sun Feb 24 15:08:06 2008 +0000 +++ b/lisp/gnus/mm-util.el Sun Feb 24 15:23:45 2008 +0000 @@ -576,6 +576,36 @@ (push (cons mime (delq 'ascii mule)) alist))) (setq mm-mime-mule-charset-alist (nreverse alist))))) +(defvar mm-hack-charsets '(iso-8859-15 iso-2022-jp-2) + "A list of special charsets. +Valid elements include: +`iso-8859-15' convert ISO-8859-1, -9 to ISO-8859-15 if ISO-8859-15 exists. +`iso-2022-jp-2' convert ISO-2022-jp to ISO-2022-jp-2 if ISO-2022-jp-2 exists." +) + +(defvar mm-iso-8859-15-compatible + '((iso-8859-1 "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE") + (iso-8859-9 "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE\xD0\xDD\xDE\xF0\xFD\xFE")) + "ISO-8859-15 exchangeable coding systems and inconvertible characters.") + +(defvar mm-iso-8859-x-to-15-table + (and (fboundp 'coding-system-p) + (mm-coding-system-p 'iso-8859-15) + (mapcar + (lambda (cs) + (if (mm-coding-system-p (car cs)) + (let ((c (string-to-char + (decode-coding-string "\341" (car cs))))) + (cons (char-charset c) + (cons + (- (string-to-char + (decode-coding-string "\341" 'iso-8859-15)) c) + (string-to-list (decode-coding-string (car (cdr cs)) + (car cs)))))) + '(gnus-charset 0))) + mm-iso-8859-15-compatible)) + "A table of the difference character between ISO-8859-X and ISO-8859-15.") + (defcustom mm-coding-system-priorities (if (boundp 'current-language-environment) (let ((lang (symbol-value 'current-language-environment))) @@ -829,6 +859,27 @@ default-enable-multibyte-characters t))) +(defun mm-iso-8859-x-to-15-region (&optional b e) + (if (fboundp 'char-charset) + (let (charset item c inconvertible) + (save-restriction + (if e (narrow-to-region b e)) + (goto-char (point-min)) + (skip-chars-forward "\0-\177") + (while (not (eobp)) + (cond + ((not (setq item (assq (char-charset (setq c (char-after))) + mm-iso-8859-x-to-15-table))) + (forward-char)) + ((memq c (cdr (cdr item))) + (setq inconvertible t) + (forward-char)) + (t + (insert-before-markers (prog1 (+ c (car (cdr item))) + (delete-char 1))))) + (skip-chars-forward "\0-\177"))) + (not inconvertible)))) + (defun mm-sort-coding-systems-predicate (a b) (let ((priorities (mapcar (lambda (cs) @@ -976,6 +1027,26 @@ (mapcar 'mm-mime-charset (delq 'ascii (mm-find-charset-region b e)))))) + (if (and (> (length charsets) 1) + (memq 'iso-8859-15 charsets) + (memq 'iso-8859-15 hack-charsets) + (save-excursion (mm-iso-8859-x-to-15-region b e))) + (dolist (x mm-iso-8859-15-compatible) + (setq charsets (delq (car x) charsets)))) + (if (and (memq 'iso-2022-jp-2 charsets) + (memq 'iso-2022-jp-2 hack-charsets)) + (setq charsets (delq 'iso-2022-jp charsets))) + ;; Attempt to reduce the number of charsets if utf-8 is available. + (if (and (featurep 'xemacs) + (> (length charsets) 1) + (mm-coding-system-p 'utf-8)) + (let ((mm-coding-system-priorities + (cons 'utf-8 mm-coding-system-priorities))) + (setq charsets + (mm-delete-duplicates + (mapcar 'mm-mime-charset + (delq 'ascii + (mm-find-charset-region b e))))))) charsets)) (defmacro mm-with-unibyte-buffer (&rest forms) diff -r 2c181d4110e5 -r 37d6263f580b lisp/gnus/mml.el --- a/lisp/gnus/mml.el Sun Feb 24 15:08:06 2008 +0000 +++ b/lisp/gnus/mml.el Sun Feb 24 15:23:45 2008 +0000 @@ -284,7 +284,8 @@ (list (intern (downcase (cdr (assq 'charset tag)))))) (t - (mm-find-mime-charset-region point (point))))) + (mm-find-mime-charset-region point (point) + mm-hack-charsets)))) (when (and (not raw) (memq nil charsets)) (if (or (memq 'unknown-encoding mml-confirmation-set) (message-options-get 'unknown-encoding)