diff lisp/gnus/mailcap.el @ 87097:781256628613

Merge from gnus--devo--0 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-941
author Miles Bader <miles@gnu.org>
date Thu, 06 Dec 2007 00:21:00 +0000
parents a3c27999decb
children 107ccd98fa12 53108e6cea98
line wrap: on
line diff
--- a/lisp/gnus/mailcap.el	Thu Dec 06 00:17:56 2007 +0000
+++ b/lisp/gnus/mailcap.el	Thu Dec 06 00:21:00 2007 +0000
@@ -33,8 +33,14 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))
-(require 'mail-parse)
-(require 'mm-util)
+(autoload 'mail-header-parse-content-type "mail-parse")
+
+;; `mm-delete-duplicates' is an alias for `delete-dups' in Emacs 22.
+(defalias 'mailcap-delete-duplicates
+  (if (fboundp 'delete-dups)
+      'delete-dups
+    (autoload 'mm-delete-duplicates "mm-util")
+    'mm-delete-duplicates))
 
 (defgroup mailcap nil
   "Definition of viewers for MIME types."
@@ -722,7 +728,7 @@
       t)
      (t nil))))
 
-(defun mailcap-mime-info (string &optional request)
+(defun mailcap-mime-info (string &optional request no-decode)
   "Get the MIME viewer command for STRING, return nil if none found.
 Expects a complete content-type header line as its argument.
 
@@ -732,7 +738,11 @@
 corresponding to that string will be returned (print, description,
 whatever).  If a number, then all the information for this specific
 viewer is returned.  If `all', then all possible viewers for
-this type is returned."
+this type is returned.
+
+If NO-DECODE is non-nil, don't decode STRING."
+  ;; NO-DECODE avoids calling `mail-header-parse-content-type' from
+  ;; `mail-parse.el'
   (let (
 	major				; Major encoding (text, etc)
 	minor				; Minor encoding (html, etc)
@@ -746,7 +756,10 @@
 	viewer				; The one and only viewer
 	ctl)
     (save-excursion
-      (setq ctl (mail-header-parse-content-type (or string "text/plain")))
+      (setq ctl
+	    (if no-decode
+		(list (or string "text/plain"))
+	      (mail-header-parse-content-type (or string "text/plain"))))
       (setq major (split-string (car ctl) "/"))
       (setq minor (cadr major)
 	    major (car major))
@@ -766,7 +779,7 @@
 	(setq viewer (car passed)))
       (cond
        ((and (null viewer) (not (equal major "default")) request)
-	(mailcap-mime-info "default" request))
+	(mailcap-mime-info "default" request no-decode))
        ((or (null request) (equal request ""))
 	(mailcap-unescape-mime-test (cdr (assq 'viewer viewer)) info))
        ((stringp request)
@@ -976,7 +989,7 @@
 (defun mailcap-mime-types ()
   "Return a list of MIME media types."
   (mailcap-parse-mimetypes)
-  (mm-delete-duplicates
+  (mailcap-delete-duplicates
    (nconc
     (mapcar 'cdr mailcap-mime-extensions)
     (apply