* hashcash.el (mail-add-payment): Replace mapcar called for effect with mapc.
[gnus] / lisp / mm-util.el
index 1ae8480..7187aab 100644 (file)
@@ -9,7 +9,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
     (require 'timer)))
 
 (eval-and-compile
-  (mapcar
+  (mapc
    (lambda (elem)
      (let ((nfunc (intern (format "mm-%s" (car elem)))))
        (if (fboundp (car elem))
           (defalias nfunc (car elem))
         (defalias nfunc (cdr elem)))))
-   '((decode-coding-string . (lambda (s a) s))
-     (encode-coding-string . (lambda (s a) s))
-     (encode-coding-region . ignore)
-     (coding-system-list . ignore)
-     (decode-coding-region . ignore)
+   '((coding-system-list . ignore)
      (char-int . identity)
      (coding-system-equal . equal)
      (annotationp . ignore)
                            (string-match (car elem) buffer-name)
                            (throw 'return (cdr elem))))))))))))
 
+(eval-and-compile
+  (if (featurep 'xemacs)
+      (if (featurep 'file-coding)
+         ;; Don't modify string if CODING-SYSTEM is nil.
+         (progn
+           (defun mm-decode-coding-string (str coding-system)
+             (if coding-system
+                 (decode-coding-string str coding-system)
+               str))
+           (defun mm-encode-coding-string (str coding-system)
+             (if coding-system
+                 (encode-coding-string str coding-system)
+               str))
+           (defun mm-decode-coding-region (start end coding-system)
+             (if coding-system
+                 (decode-coding-region start end coding-system)))
+           (defun mm-encode-coding-region (start end coding-system)
+             (if coding-system
+                 (encode-coding-region start end coding-system))))
+       (defun mm-decode-coding-string (str coding-system) str)
+       (defun mm-encode-coding-string (str coding-system) str)
+       (defalias 'mm-decode-coding-region 'ignore)
+       (defalias 'mm-encode-coding-region 'ignore))
+    (defalias 'mm-decode-coding-string 'decode-coding-string)
+    (defalias 'mm-encode-coding-string 'encode-coding-string)
+    (defalias 'mm-decode-coding-region 'decode-coding-region)
+    (defalias 'mm-encode-coding-region 'encode-coding-region)))
+
 (defalias 'mm-string-to-multibyte
   (cond
    ((featurep 'xemacs)
@@ -204,7 +228,7 @@ the alias.  Else windows-NUMBER is used."
               (mm-coding-system-p cp))
       (add-to-list 'mm-charset-synonym-alist (cons alias cp)))))
 
-(defcustom mm-charset-synonym-alist
+(defvar mm-charset-synonym-alist
   `(
     ;; Not in XEmacs, but it's not a proper MIME charset anyhow.
     ,@(unless (mm-coding-system-p 'x-ctext)
@@ -229,24 +253,20 @@ the alias.  Else windows-NUMBER is used."
     ,@(when (and (not (mm-coding-system-p 'windows-31j))
                 (mm-coding-system-p 'cp932))
        '((windows-31j . cp932)))
-    ;; ISO8859-1 is ISO-8859-1
+    ;; Charset name: GBK, Charset aliases: CP936, MS936, windows-936
+    ;; http://www.iana.org/assignments/charset-reg/GBK
+    ;; Emacs 22.1 has cp936, but not gbk, so we alias it:
+    ,@(when (and (not (mm-coding-system-p 'gbk))
+                (mm-coding-system-p 'cp936))
+       '((gbk . cp936)))
+    ;; ISO8859-1 is a bogus name for ISO-8859-1
     ,@(when (and (not (mm-coding-system-p 'iso8859-1))
                 (mm-coding-system-p 'iso-8859-1))
        '((iso8859-1 . iso-8859-1)))
     )
   "A mapping from unknown or invalid charset names to the real charset names.
 
-See `mm-codepage-iso-8859-list' and `mm-codepage-ibm-list'."
-  :type '(repeat
-         :convert-widget (lambda (widget)
-                           (apply 'widget-convert (widget-type widget)
-                                  (eval (car (widget-get widget :args)))))
-         `((cons :format "%v"
-                 (symbol :tag "Synonym")
-                 ,(if (get 'coding-system 'widget-type)
-                      'coding-system
-                    '(symbol :tag "Coding system")))))
-  :group 'mime)
+See `mm-codepage-iso-8859-list' and `mm-codepage-ibm-list'.")
 
 (defcustom mm-codepage-iso-8859-list
   (list 1250 ;; Windows-1250 is a variant of Latin-2 heavily used by Microsoft
@@ -992,8 +1012,8 @@ charset, and a longer list means no appropriate charset."
             (memq 'iso-8859-15 charsets)
             (memq 'iso-8859-15 hack-charsets)
             (save-excursion (mm-iso-8859-x-to-15-region b e)))
-       (mapcar (lambda (x) (setq charsets (delq (car x) charsets)))
-               mm-iso-8859-15-compatible))
+       (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)))
@@ -1075,10 +1095,10 @@ Emacs 23 (unicode)."
     ;; Remove composition since the base charsets have been included.
     ;; Remove eight-bit-*, treat them as ascii.
     (let ((css (find-charset-region b e)))
-      (mapcar (lambda (cs) (setq css (delq cs css)))
-             '(composition eight-bit-control eight-bit-graphic
-                           control-1))
-      css))
+      (dolist (cs
+              '(composition eight-bit-control eight-bit-graphic control-1)
+              css)
+       (setq css (delq cs css)))))
    (t
     ;; We are in a unibyte buffer or XEmacs non-mule, so we futz around a bit.
     (save-excursion