Don't output messages when saving.
[gnus] / lisp / mailcap.el
1 ;;; mailcap.el --- MIME media types configuration
2
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5
6 ;; Author: William M. Perry <wmperry@aventail.com>
7 ;;      Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; Keywords: news, mail, multimedia
9
10 ;; This file is part of GNU Emacs.
11
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.
16
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.
21
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/>.
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 (autoload 'mail-header-parse-content-type "mail-parse")
35
36 ;; `mm-delete-duplicates' is an alias for `delete-dups' in Emacs 22.
37 (defalias 'mailcap-delete-duplicates
38   (if (fboundp 'delete-dups)
39       'delete-dups
40     (autoload 'mm-delete-duplicates "mm-util")
41     'mm-delete-duplicates))
42
43 ;; `mailcap-replace-in-string' is an alias like `gnus-replace-in-string'.
44 (eval-and-compile
45   (cond
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))))
55
56 (defgroup mailcap nil
57   "Definition of viewers for MIME types."
58   :version "21.1"
59   :group 'mime)
60
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)
67     table)
68   "A syntax table for parsing SGML attributes.")
69
70 (eval-and-compile
71   (when (featurep 'xemacs)
72     (condition-case nil
73         (require 'lpr)
74       (error nil))))
75
76 (defvar mailcap-print-command
77   (mapconcat 'identity
78              (cons (if (boundp 'lpr-command)
79                        lpr-command
80                      "lpr")
81                    (when (boundp 'lpr-switches)
82                      (if (stringp lpr-switches)
83                          (list lpr-switches)
84                        lpr-switches)))
85              " ")
86   "Shell command (including switches) used to print Postscript files.")
87
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
93   `(("application"
94      ("vnd.ms-excel"
95       (viewer . "gnumeric %s")
96       (test   . (getenv "DISPLAY"))
97       (type . "application/vnd.ms-excel"))
98      ("x-x509-ca-cert"
99       (viewer . ssl-view-site-cert)
100       (test . (fboundp 'ssl-view-site-cert))
101       (type . "application/x-x509-ca-cert"))
102      ("x-x509-user-cert"
103       (viewer . ssl-view-user-cert)
104       (test . (fboundp 'ssl-view-user-cert))
105       (type . "application/x-x509-user-cert"))
106      ("octet-stream"
107       (viewer . mailcap-save-binary-file)
108       (non-viewer . t)
109       (type . "application/octet-stream"))
110      ("dvi"
111       (viewer . "xdvi -safer %s")
112       (test   . (eq window-system 'x))
113       ("needsx11")
114       (type   . "application/dvi")
115       ("print" . "dvips -qRP %s"))
116      ("dvi"
117       (viewer . "dvitty %s")
118       (test   . (not (getenv "DISPLAY")))
119