Synch to No Gnus 200601241028.
[elisp/gnus.git-] / lisp / mm-util.el
index 512cf28..da0d2a8 100644 (file)
                               (make-directory file))
                           file)))
      (insert-byte . insert-char)
-     (multibyte-char-to-unibyte . identity))))
+     (multibyte-char-to-unibyte . identity)
+     (special-display-p
+      . (lambda (buffer-name)
+         "Returns non-nil if a buffer named BUFFER-NAME gets a special frame."
+         (and special-display-function
+              (or (and (member buffer-name special-display-buffer-names) t)
+                  (cdr (assoc buffer-name special-display-buffer-names))
+                  (catch 'return
+                    (dolist (elem special-display-regexps)
+                      (and (stringp elem)
+                           (string-match elem buffer-name)
+                           (throw 'return t))
+                      (and (consp elem)
+                           (stringp (car elem))
+                           (string-match (car elem) buffer-name)
+                           (throw 'return (cdr elem))))))))))))
 
 (eval-and-compile
   (defalias 'mm-char-or-char-int-p
@@ -184,7 +199,6 @@ the alias.  Else windows-NUMBER is used."
     (unless (mm-coding-system-p cp)
       (codepage-setup number))
     (when (and alias
-              (mm-coding-system-p alias)
               ;; Don't add alias if setup of cp failed.
               (mm-coding-system-p cp))
       (add-to-list 'mm-charset-synonym-alist (cons alias cp)))))
@@ -491,11 +505,17 @@ mail with multiple parts is preferred to sending a Unicode one.")
        (pop alist))
       out)))
 
-(defun mm-charset-to-coding-system (charset &optional lbt)
+(defun mm-charset-to-coding-system (charset &optional lbt
+                                           allow-override)
   "Return coding-system corresponding to CHARSET.
 CHARSET is a symbol naming a MIME charset.
 If optional argument LBT (`unix', `dos' or `mac') is specified, it is
-used as the line break code type of the coding system."
+used as the line break code type of the coding system.
+
+If ALLOW-OVERRIDE is given, use `mm-charset-override-alist' to
+map undesired charset names to their replacement.  This should
+only be used for decoding, not for encoding."
+  ;; OVERRIDE is used (only) in `mm-decode-body'.
   (when (stringp charset)
     (setq charset (intern (downcase charset))))
   (when lbt
@@ -507,9 +527,11 @@ used as the line break code type of the coding system."
    ((or (null (mm-get-coding-system-list))
        (not (fboundp 'coding-system-get)))
     charset)
-   ;; Check override list quite early:
-   ((let ((cs (cdr (assq charset mm-charset-override-alist))))
-      (and cs (mm-coding-system-p cs) cs)))
+   ;; Check override list quite early.  Should only used for decoding, not for
+   ;; encoding!
+   ((and allow-override
+        (let ((cs (cdr (assq charset mm-charset-override-alist))))
+          (and cs (mm-coding-system-p cs) cs))))
    ;; ascii
    ((eq charset 'us-ascii)
     'ascii)