(gnus-sieve-script): Use the crosspost argument to gnus-sieve-script,
[gnus] / lisp / mailcap.el
1 ;;; mailcap.el --- MIME media types configuration
2 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3
4 ;; Author: William M. Perry <wmperry@aventail.com>
5 ;;      Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news, mail, multimedia
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
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.
30
31 ;;; Code:
32
33 (eval-when-compile (require 'cl))
34 (require 'mail-parse)
35 (require 'mm-util)
36
37 (defgroup mailcap nil
38   "Definition of viewers for MIME types."
39   :version "21.1"
40   :group 'mime)
41
42 (defvar mailcap-parse-args-syntax-table
43   (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
44     (modify-syntax-entry ?' "\"" table)
45     (modify-syntax-entry ?` "\"" table)
46     (modify-syntax-entry ?{ "(" table)
47     (modify-syntax-entry ?} ")" table)
48     table)
49   "A syntax table for parsing sgml attributes.")
50
51 ;; Postpone using defcustom for this as it's so big and we essentially
52 ;; have to have two copies of the data around then.  Perhaps just
53 ;; customize the Lisp viewers and rely on the normal configuration
54 ;; files for the rest?  -- fx
55 (defvar mailcap-mime-data
56   '(("application"
57      ("vnd.ms-excel"
58       (viewer . "gnumeric %s")
59       (test   . (getenv "DISPLAY"))
60       (type . "application/vnd.ms-excel"))
61      ("x-x509-ca-cert"
62       (viewer . ssl-view-site-cert)
63       (test . (fboundp 'ssl-view-site-cert))
64       (type . "application/x-x509-ca-cert"))
65      ("x-x509-user-cert"
66       (viewer . ssl-view-user-cert)
67       (test . (fboundp 'ssl-view-user-cert))
68       (type . "application/x-x509-user-cert"))
69      ("octet-stream"
70       (viewer . mailcap-save-binary-file)
71       (non-viewer . t)
72       (type . "application/octet-stream"))
73 ;;; XEmacs says `ns' device-type not implemented.
74 ;;      ("dvi"
75 ;;       (viewer . "open %s")
76 ;;       (type   . "application/dvi")
77 ;;       (test   . (eq (mm-device-type) 'ns)))
78      ("dvi"
79       (viewer . "xdvi -safer %s")
80       (test   . (eq window-system 'x))
81       ("needsx11")
82       (type   . "application/dvi"))
83      ("dvi"
84       (viewer . "dvitty %s")
85       (test   . (not (getenv "DISPLAY")))
86       (type   . "application/dvi"))
87      ("emacs-lisp"
88       (viewer . mailcap-maybe-eval)
89       (type   . "application/emacs-lisp"))
90      ("x-emacs-lisp"
91       (viewer . mailcap-maybe-eval)
92       (type   . "application/x-emacs-lisp"))
93      ("x-tar"
94       (viewer . mailcap-save-binary-file)
95       (non-viewer . t)
96       (type   . "application/x-tar"))
97      ("x-latex"
98       (viewer . tex-mode)
99       (test   . (fboundp 'tex-mode))
100       (type   . "application/x-latex"))
101      ("x-tex"
102       (viewer . tex-mode)
103       (test   . (fboundp 'tex-mode))
104       (type   . "application/x-tex"))
105      ("latex"
106       (viewer . tex-mode)
107       (test   . (fboundp 'tex-mode))
108       (type   . "application/latex"))
109      ("tex"
110       (viewer . tex-mode)
111       (test   . (fboundp 'tex-mode))
112       (type   . "application/tex"))
113      ("texinfo"
114       (viewer . texinfo-mode)
115       (test   . (fboundp 'texinfo-mode))
116       (type   . "application/tex"))
117      ("zip"
118       (viewer . mailcap-save-binary-file)
119       (non-viewer . t)
120       (type   . "application/zip")
121       ("copiousoutput"))
122      ;; Prefer free viewers.
123      ("pdf"
124       (viewer . "gv -safer %s")
125       (type . "application/pdf")
126       (test . window-system))
127      ("pdf"
128       (viewer . "xpdf %s")
129       (type . "application/pdf")
130       (test . (eq window-system 'x)))
131      ("pdf"
132       (viewer . "acroread %s")
133       (type   . "application/pdf"))
134 ;;; XEmacs says `ns' device-type not implemented.
135 ;;      ("postscript"
136 ;;       (viewer . "open %s")
137 ;;       (type   . "application/postscript")
138 ;;       (test   . (eq (mm-device-type) 'ns)))
139      ("postscript"
140       (viewer . "gv -safer %s")
141       (type . "application/postscript")
142       (test   . window-system)
143       ("needsx11"))
144      ("postscript"
145       (viewer . "ghostview -dSAFER %s")
146       (type . "application/postscript")
147       (test   . (eq window-system 'x))
148       ("needsx11"))
149      ("postscript"