mailcap.el: Make it easier to use mailcap for viewing single files
[gnus] / lisp / mailcap.el
index 4f1bdf4..1a1a992 100644 (file)
@@ -152,6 +152,10 @@ This is a compatibility function for different Emacsen."
       (non-viewer . t)
       (type   . "application/zip")
       ("copiousoutput"))
+     ("pdf"
+      (viewer . doc-view-mode)
+      (type . "application/pdf")
+      (test . (eq window-system 'x)))
      ("pdf"
       (viewer . "gv -safer %s")
       (type . "application/pdf")
@@ -1060,6 +1064,18 @@ If FORCE, re-parse even if already parsed."
                             common-mime-info)))))
     commands))
 
+(defun mailcap-view-mime (type)
+  "View the data in the current buffer that has MIME type TYPE.
+`mailcap-mime-data' determines the method to use."
+  (let ((method (mailcap-mime-info type)))
+    (if (stringp method)
+       (shell-command-on-region (point-min) (point-max)
+                                ;; Use stdin as the "%s".
+                                (format method "-")
+                                (current-buffer)
+                                t)
+      (funcall method))))
+
 (provide 'mailcap)
 
 ;;; mailcap.el ends here