1 ;;; mailcap.el --- MIME media types configuration
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: William M. Perry <wmperry@aventail.com>
7 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; Keywords: news, mail, multimedia
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; Provides configuration of MIME media types from directly from Lisp
28 ;; and via the usual mailcap mechanism (RFC 1524). Deals with
29 ;; mime.types similarly.
33 (eval-when-compile (require 'cl))
34 (autoload 'mail-header-parse-content-type "mail-parse")
36 ;; `mm-delete-duplicates' is an alias for `delete-dups' in Emacs 22.
37 (defalias 'mailcap-delete-duplicates
38 (if (fboundp 'delete-dups)
40 (autoload 'mm-delete-duplicates "mm-util")
41 'mm-delete-duplicates))
43 ;; `mailcap-replace-in-string' is an alias like `gnus-replace-in-string'.
46 ((fboundp 'replace-regexp-in-string)
47 (defun mailcap-replace-in-string (string regexp newtext &optional literal)
48 "Replace all matches for REGEXP with NEWTEXT in STRING.
49 If LITERAL is non-nil, insert NEWTEXT literally. Return a new
50 string containing the replacements.
51 This is a compatibility function for different Emacsen."
52 (replace-regexp-in-string regexp newtext string nil literal)))
53 ((fboundp 'replace-in-string)
54 (defalias 'mailcap-replace-in-string 'replace-in-string))))
57 "Definition of viewers for MIME types."
61 (defvar mailcap-parse-args-syntax-table
62 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
63 (modify-syntax-entry ?' "\"" table)
64 (modify-syntax-entry ?` "\"" table)
65 (modify-syntax-entry ?{ "(" table)
66 (modify-syntax-entry ?} ")" table)
68 "A syntax table for parsing SGML attributes.")
71 (when (featurep 'xemacs)
76 (defvar mailcap-print-command
78 (cons (if (boundp 'lpr-command)
81 (when (boundp 'lpr-switches)
82 (if (stringp lpr-switches)
86 "Shell command (including switches) used to print Postscript files.")
88 ;; Postpone using defcustom for this as it's so big and we essentially
89 ;; have to have two copies of the data around then. Perhaps just
90 ;; customize the Lisp viewers and rely on the normal configuration
91 ;; files for the rest? -- fx
92 (defvar mailcap-mime-data
95 (viewer . "gnumeric %s")
96 (test . (getenv "DISPLAY"))
97 (type . "application/vnd.ms-excel"))
99 (viewer . ssl-view-site-cert)
100 (test . (fboundp 'ssl-view-site-cert))
101 (type . "application/x-x509-ca-cert"))
103 (viewer . ssl-view-user-cert)
104 (test . (fboundp 'ssl-view-user-cert))
105 (type . "application/x-x509-user-cert"))
107 (viewer . mailcap-save-binary-file)
109 (type . "application/octet-stream"))
111 (viewer . "xdvi -safer %s")
112 (test . (eq window-system 'x))
114 (type . "application/dvi")
115 ("print" . "dvips -qRP %s"))
117 (viewer . "dvitty %s")
118 (test . (not (getenv "DISPLAY")))