Importing Pterodactyl Gnus v0.98.
[elisp/gnus.git-] / lisp / mm-decode.el
index 0b5f57f..98a167c 100644 (file)
     "message/rfc822")
   "A list of MIME types to be displayed automatically.")
 
-(defvar mm-attachment-override-types
-  '("text/plain" "text/x-vcard")
+(defvar mm-attachment-override-types '("text/x-vcard")
   "Types that should have \"attachment\" ignored if they can be displayed inline.")
 
 (defvar mm-automatic-external-display nil
@@ -191,7 +190,11 @@ to:
       (if (or (not ctl)
              (not (string-match "/" (car ctl))))
          (mm-dissect-singlepart
-          '("text/plain") nil no-strict-mime
+          '("text/plain") 
+          (and cte (intern (downcase (mail-header-remove-whitespace
+                                      (mail-header-remove-comments
+                                       cte)))))
+          no-strict-mime
           (and cd (ignore-errors (mail-header-parse-content-disposition cd)))
           description)
        (setq type (split-string (car ctl) "/"))
@@ -437,17 +440,22 @@ external if displayed external."
 
 (defun mm-display-inline (handle)
   (let* ((type (mm-handle-media-type handle))
-        (function (cadr (assoc type mm-inline-media-tests))))
+        (function (cadr (mm-assoc-string-match mm-inline-media-tests type))))
     (funcall function handle)
     (goto-char (point-min))))
 
+(defun mm-assoc-string-match (alist type)
+  (dolist (elem alist)
+    (when (string-match (car elem) type)
+      (return elem))))
+
 (defun mm-inlinable-p (handle)
   "Say whether HANDLE can be displayed inline."
   (let ((alist mm-inline-media-tests)
        (type (mm-handle-media-type handle))
        test)
     (while alist
-      (when (equal type (caar alist))
+      (when (string-match (caar alist) type)
        (setq test (caddar alist)
              alist nil)
        (setq test (funcall test handle)))
@@ -566,15 +574,10 @@ external if displayed external."
 (defun mm-save-part-to-file (handle file)
   (mm-with-unibyte-buffer
     (mm-insert-part handle)
-    ;; Now every coding system is 100% binary within mm-with-unibyte-buffer
-    ;; Is text still special?
-    (let ((coding-system-for-write
-          (if (equal "text" (mm-handle-media-supertype handle))
-              buffer-file-coding-system
-            'binary))
+    (let ((coding-system-for-write 'binary)
          ;; Don't re-compress .gz & al.  Arguably we should make
          ;; `file-name-handler-alist' nil, but that would chop
-         ;; ange-ftp which it's reasonable to use here.
+         ;; ange-ftp, which is reasonable to use here.
          (inhibit-file-name-operation 'write-region)
          (inhibit-file-name-handlers
           (if (equal (mm-handle-media-type handle)