;;; mailcap.el --- MIME media types configuration
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2015 Free Software Foundation, Inc.
;; Author: William M. Perry <wmperry@aventail.com>
;; Lars Magne Ingebrigtsen <larsi@gnus.org>
(list lpr-switches)
lpr-switches)))
" ")
- "Shell command (including switches) used to print Postscript files.")
+ "Shell command (including switches) used to print PostScript files.")
;; Postpone using defcustom for this as it's so big and we essentially
;; have to have two copies of the data around then. Perhaps just
;; files for the rest? -- fx
(defvar mailcap-mime-data
`(("application"
- ("vnd.ms-excel"
+ ("vnd\\.ms-excel"
(viewer . "gnumeric %s")
(test . (getenv "DISPLAY"))
(type . "application/vnd.ms-excel"))
(non-viewer . t)
(type . "application/zip")
("copiousoutput"))
+ ("pdf"
+ (viewer . pdf-view-mode)
+ (type . "application/pdf")
+ (test . (and (fboundp 'pdf-view-mode)
+ (eq window-system 'x))))
+ ("pdf"
+ (viewer . doc-view-mode)
+ (type . "application/pdf")
+ (test . (and (fboundp 'doc-view-mode)
+ (eq window-system 'x))))
("pdf"
(viewer . "gv -safer %s")
(type . "application/pdf")
(viewer . vm-mode)
(test . (fboundp 'vm-mode))
(type . "message/rfc822"))
- ("rfc-*822"
- (viewer . w3-mode)
- (test . (fboundp 'w3-mode))
- (type . "message/rfc822"))
("rfc-*822"
(viewer . view-mode)
(type . "message/rfc822")))
(test . (eq window-system 'x))
("needsx11")))
("text"
- ("plain"
- (viewer . w3-mode)
- (test . (fboundp 'w3-mode))
- (type . "text/plain"))
("plain"
(viewer . view-mode)
(test . (fboundp 'view-mode))
(viewer . enriched-decode)
(test . (fboundp 'enriched-decode))
(type . "text/enriched"))
- ("html"
- (viewer . mm-w3-prepare-buffer)
- (test . (fboundp 'w3-prepare-buffer))
- (type . "text/html"))
("dns"
(viewer . dns-mode)
(test . (fboundp 'dns-mode))
results)))
(defun mailcap-mailcap-entry-passes-test (info)
- "Return non-nil if mailcap entry INFO passes its test clause.
-Also return non-nil if no test clause is present."
+ "Replace the test clause of INFO itself with a boolean for some cases.
+This function supports only `test -n $DISPLAY' and `test -z $DISPLAY',
+replaces them with t or nil. As for others or if INFO has a interactive
+spec (needsterm, needsterminal, or needsx11) but DISPLAY is not set,
+the test clause will be unchanged."
(let ((test (assq 'test info)) ; The test clause
status)
(setq status (and test (split-string (cdr test) " ")))
;;;
(defvar mailcap-mime-extensions
- '(("" . "text/plain")
+ '(("" . "text/plain")
+ (".1" . "text/plain") ;; Manual pages
+ (".3" . "text/plain")
+ (".8" . "text/plain")
(".abs" . "audio/x-mpeg")
(".aif" . "audio/aiff")
(".aifc" . "audio/aiff")
(".css" . "text/css")
(".dvi" . "application/x-dvi")
(".diff" . "text/x-patch")
+ (".dpatch". "test/x-patch")
(".el" . "application/emacs-lisp")
(".eps" . "application/postscript")
(".etx" . "text/x-setext")
(".pict" . "image/pict")
(".png" . "image/png")
(".pnm" . "image/x-portable-anymap")
+ (".pod" . "text/plain")
(".ppm" . "image/portable-pixmap")
(".ps" . "application/postscript")
(".qt" . "video/quicktime")
(".zip" . "application/zip")
(".ai" . "application/postscript")
(".jpe" . "image/jpeg")
- (".jpeg" . "image/jpeg"))
+ (".jpeg" . "image/jpeg")
+ (".org" . "text/x-org"))
"An alist of file extensions and corresponding MIME content-types.
This exists for you to customize the information in Lisp. It is
merged with values from mailcap files by `mailcap-parse-mimetypes'.")
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