annotate lisp/gnus/mailcap.el @ 47071:695d2a421704

@cindex{...} -> @code{...}
author Miles Bader <miles@gnu.org>
date Wed, 28 Aug 2002 00:55:11 +0000
parents 0f4506820432
children 0d8b17d428b5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
1 ;;; mailcap.el --- MIME media types configuration
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2 ;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4 ;; Author: William M. Perry <wmperry@aventail.com>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
6 ;; Keywords: news, mail, multimedia
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; any later version.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
27 ;; Provides configuration of MIME media types from directly from Lisp
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
28 ;; and via the usual mailcap mechanism (RFC 1524). Deals with
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
29 ;; mime.types similarly.
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
30
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;;; Code:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 (eval-when-compile (require 'cl))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 (require 'mail-parse)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 (require 'mm-util)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
37 (defgroup mailcap nil
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
38 "Definition of viewers for MIME types."
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
39 :version "21.1"
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
40 :group 'mime)
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
41
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 (defvar mailcap-parse-args-syntax-table
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 (modify-syntax-entry ?' "\"" table)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 (modify-syntax-entry ?` "\"" table)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 (modify-syntax-entry ?{ "(" table)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 (modify-syntax-entry ?} ")" table)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 table)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 "A syntax table for parsing sgml attributes.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
51 ;; Postpone using defcustom for this as it's so big and we essentially
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
52 ;; have to have two copies of the data around then. Perhaps just
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
53 ;; customize the Lisp viewers and rely on the normal configuration
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
54 ;; files for the rest? -- fx
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 (defvar mailcap-mime-data
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 '(("application"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ("x-x509-ca-cert"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 (viewer . ssl-view-site-cert)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 (test . (fboundp 'ssl-view-site-cert))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 (type . "application/x-x509-ca-cert"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ("x-x509-user-cert"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 (viewer . ssl-view-user-cert)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 (test . (fboundp 'ssl-view-user-cert))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 (type . "application/x-x509-user-cert"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ("octet-stream"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 (viewer . mailcap-save-binary-file)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 (non-viewer . t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 (type . "application/octet-stream"))
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
69 ;;; XEmacs says `ns' device-type not implemented.
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
70 ;; ("dvi"
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
71 ;; (viewer . "open %s")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
72 ;; (type . "application/dvi")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
73 ;; (test . (eq (mm-device-type) 'ns)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 ("dvi"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 (viewer . "xdvi %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (test . (eq (mm-device-type) 'x))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ("needsx11")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 (type . "application/dvi"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 ("dvi"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 (viewer . "dvitty %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 (test . (not (getenv "DISPLAY")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 (type . "application/dvi"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ("emacs-lisp"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 (viewer . mailcap-maybe-eval)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 (type . "application/emacs-lisp"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 ("x-tar"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 (viewer . mailcap-save-binary-file)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 (non-viewer . t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 (type . "application/x-tar"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 ("x-latex"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 (viewer . tex-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 (test . (fboundp 'tex-mode))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 (type . "application/x-latex"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 ("x-tex"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 (viewer . tex-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 (test . (fboundp 'tex-mode))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 (type . "application/x-tex"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 ("latex"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 (viewer . tex-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (test . (fboundp 'tex-mode))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 (type . "application/latex"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 ("tex"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 (viewer . tex-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (test . (fboundp 'tex-mode))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 (type . "application/tex"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 ("texinfo"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 (viewer . texinfo-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 (test . (fboundp 'texinfo-mode))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 (type . "application/tex"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 ("zip"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 (viewer . mailcap-save-binary-file)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 (non-viewer . t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 (type . "application/zip")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 ("copiousoutput"))
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
115 ;; Prefer free viewers.
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
116 ("pdf"
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
117 (viewer . "gv %s")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
118 (type . "application/pdf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
119 (test . window-system))
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
120 ("pdf"
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
121 (viewer . "xpdf %s")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
122 (type . "application/pdf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
123 (test . (eq (mm-device-type) 'x)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 ("pdf"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (viewer . "acroread %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 (type . "application/pdf"))
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
127 ;;; XEmacs says `ns' device-type not implemented.
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
128 ;; ("postscript"
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
129 ;; (viewer . "open %s")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
130 ;; (type . "application/postscript")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
131 ;; (test . (eq (mm-device-type) 'ns)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 ("postscript"
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
133 (viewer . "gv -safer %s")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
134 (type . "application/postscript")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
135 (test . window-system)
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
136 ("needsx11"))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 ("postscript"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (viewer . "ghostview -dSAFER %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 (type . "application/postscript")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 (test . (eq (mm-device-type) 'x))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 ("needsx11"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 ("postscript"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (viewer . "ps2ascii %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (type . "application/postscript")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (test . (not (getenv "DISPLAY")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 ("copiousoutput")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 ("audio"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 ("x-mpeg"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 (viewer . "maplay %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (type . "audio/x-mpeg"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 (".*"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 (viewer . "showaudio")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 (type . "audio/*")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 ("message"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 ("rfc-*822"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 (viewer . mm-view-message)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 (test . (and (featurep 'gnus)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 (gnus-alive-p)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 (type . "message/rfc822"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 ("rfc-*822"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 (viewer . vm-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 (test . (fboundp 'vm-mode))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 (type . "message/rfc822"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 ("rfc-*822"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 (viewer . w3-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 (test . (fboundp 'w3-mode))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 (type . "message/rfc822"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 ("rfc-*822"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 (viewer . view-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 (type . "message/rfc822")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 ("image"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 ("x-xwd"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 (viewer . "xwud -in %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 (type . "image/x-xwd")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 ("compose" . "xwd -frame > %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 (test . (eq (mm-device-type) 'x))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 ("needsx11"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 ("x11-dump"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 (viewer . "xwud -in %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 (type . "image/x-xwd")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 ("compose" . "xwd -frame > %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 (test . (eq (mm-device-type) 'x))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 ("needsx11"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 ("windowdump"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 (viewer . "xwud -in %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 (type . "image/x-xwd")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 ("compose" . "xwd -frame > %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 (test . (eq (mm-device-type) 'x))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 ("needsx11"))
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
190 ;;; XEmacs says `ns' device-type not implemented.
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
191 ;; (".*"
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
192 ;; (viewer . "aopen %s")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
193 ;; (type . "image/*")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
194 ;; (test . (eq (mm-device-type) 'ns)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 (".*"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 (viewer . "display %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 (type . "image/*")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 (test . (eq (mm-device-type) 'x))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 ("needsx11"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 (".*"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 (viewer . "ee %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (type . "image/*")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 (test . (eq (mm-device-type) 'x))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 ("needsx11")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 ("text"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 ("plain"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 (viewer . w3-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (test . (fboundp 'w3-mode))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (type . "text/plain"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 ("plain"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 (viewer . view-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 (test . (fboundp 'view-mode))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 (type . "text/plain"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 ("plain"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 (viewer . fundamental-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 (type . "text/plain"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 ("enriched"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 (viewer . enriched-decode-region)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 (test . (fboundp 'enriched-decode))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 (type . "text/enriched"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 ("html"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 (viewer . mm-w3-prepare-buffer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 (test . (fboundp 'w3-prepare-buffer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 (type . "text/html")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 ("video"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 ("mpeg"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 (viewer . "mpeg_play %s")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 (type . "video/mpeg")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 (test . (eq (mm-device-type) 'x))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 ("needsx11")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 ("x-world"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 ("x-vrml"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 (viewer . "webspace -remote %s -URL %u")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 (type . "x-world/x-vrml")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 ("description"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 "VRML document")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 ("archive"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 ("tar"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 (viewer . tar-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 (type . "archive/tar")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 (test . (fboundp 'tar-mode)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 "The mailcap structure is an assoc list of assoc lists.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 1st assoc list is keyed on the major content-type
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 2nd assoc list is keyed on the minor content-type (which can be a regexp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 Which looks like:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 -----------------
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 ((\"application\"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 (\"postscript\" . <info>))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 (\"text\"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 (\"plain\" . <info>)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 Where <info> is another assoc list of the various information
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
254 related to the mailcap RFC 1524. This is keyed on the lowercase
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 attribute name (viewer, test, etc). This looks like:
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
256 ((viewer . VIEWERINFO)
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
257 (test . TESTINFO)
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
258 (xxxx . \"STRING\")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
259 FLAG)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
261 Where VIEWERINFO specifies how the content-type is viewed. Can be
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 a string, in which case it is run through a shell, with
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 appropriate parameters, or a symbol, in which case the symbol is
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
264 `funcall'ed, with the buffer as an argument.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
266 TESTINFO is a test for the viewer's applicability, or nil. If nil, it
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
267 means the viewer is always valid. If it is a Lisp function, it is
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
268 called with a list of items from any extra fields from the
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
269 Content-Type header as argument to return a boolean value for the
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
270 validity. Otherwise, if it is a non-function Lisp symbol or list
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
271 whose car is a symbol, it is `eval'led to yield the validity. If it
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
272 is a string or list of strings, it represents a shell command to run
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
273 to return a true or false shell value for the validity.")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
275 (defcustom mailcap-download-directory nil
34330
8b1375dbcbc6 (mailcap-download-directory): Fix :type.
Dave Love <fx@gnu.org>
parents: 33821
diff changeset
276 "*Directory to which `mailcap-save-binary-file' downloads files by default.
42206
0f4506820432 Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents: 34330
diff changeset
277 nil means your home directory."
34330
8b1375dbcbc6 (mailcap-download-directory): Fix :type.
Dave Love <fx@gnu.org>
parents: 33821
diff changeset
278 :type '(choice (const :tag "Home directory" nil)
8b1375dbcbc6 (mailcap-download-directory): Fix :type.
Dave Love <fx@gnu.org>
parents: 33821
diff changeset
279 directory)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
280 :group 'mailcap)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 ;;; Utility functions
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (defun mailcap-save-binary-file ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 (unwind-protect
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (let ((file (read-file-name
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 "Filename to save as: "
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (or mailcap-download-directory "~/")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (require-final-newline nil))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (write-region (point-min) (point-max) file))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (kill-buffer (current-buffer))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 (defvar mailcap-maybe-eval-warning
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 "*** WARNING ***
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
299 This MIME part contains untrusted and possibly harmful content.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 If you evaluate the Emacs Lisp code contained in it, a lot of nasty
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 things can happen. Please examine the code very carefully before you
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 instruct Emacs to evaluate it. You can browse the buffer containing
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 the code using \\[scroll-other-window].
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 If you are unsure what to do, please answer \"no\"."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 "Text of warning message displayed by `mailcap-maybe-eval'.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 Make sure that this text consists only of few text lines. Otherwise,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 Gnus might fail to display all of it.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (defun mailcap-maybe-eval ()
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
311 "Maybe evaluate a buffer of Emacs Lisp code."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (let ((lisp-buffer (current-buffer)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (when
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (save-window-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (delete-other-windows)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (let ((buffer (get-buffer-create (generate-new-buffer-name
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 "*Warning*"))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 (unwind-protect
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (with-current-buffer buffer
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
321 (insert (substitute-command-keys
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 mailcap-maybe-eval-warning))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (display-buffer buffer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (yes-or-no-p "This is potentially dangerous emacs-lisp code, evaluate it? "))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (kill-buffer buffer))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 (eval-buffer (current-buffer)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 (when (buffer-live-p lisp-buffer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 (with-current-buffer lisp-buffer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 (emacs-lisp-mode)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 ;;; The mailcap parser
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (defun mailcap-replace-regexp (regexp to-string)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 ;; Quiet replace-regexp.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (while (re-search-forward regexp nil t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (replace-match to-string t nil)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (defvar mailcap-parsed-p nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (defun mailcap-parse-mailcaps (&optional path force)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 "Parse out all the mailcaps specified in a path string PATH.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 Components of PATH are separated by the `path-separator' character
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 appropriate for this system. If FORCE, re-parse even if already
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 parsed. If PATH is omitted, use the value of environment variable
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 MAILCAPS if set; otherwise (on Unix) use the path from RFC 1524, plus
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 /usr/local/etc/mailcap."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 (interactive (list nil t))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (when (or (not mailcap-parsed-p)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 force)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (path nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 ((getenv "MAILCAPS") (setq path (getenv "MAILCAPS")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 ((memq system-type '(ms-dos ms-windows windows-nt))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 (setq path '("~/.mailcap" "~/mail.cap" "~/etc/mail.cap")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 (t (setq path
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 ;; This is per RFC 1524, specifically
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 ;; with /usr before /usr/local.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 '("~/.mailcap" "/etc/mailcap" "/usr/etc/mailcap"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 "/usr/local/etc/mailcap"))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (let ((fnames (reverse
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (if (stringp path)
32989
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
367 (delete "" (split-string path path-separator))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 path)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 fname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 (while fnames
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (setq fname (car fnames))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (if (and (file-readable-p fname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 (file-regular-p fname))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 (mailcap-parse-mailcap fname))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 (setq fnames (cdr fnames))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (setq mailcap-parsed-p t)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (defun mailcap-parse-mailcap (fname)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
379 "Parse out the mailcap file specified by FNAME."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 (let (major ; The major mime type (image/audio/etc)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 minor ; The minor mime type (gif, basic, etc)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 save-pos ; Misc saved positions used in parsing
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 viewer ; How to view this mime type
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 info ; Misc info about this mime type
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 (with-temp-buffer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (insert-file-contents fname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (set-syntax-table mailcap-parse-args-syntax-table)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 (mailcap-replace-regexp "#.*" "") ; Remove all comments
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (mailcap-replace-regexp "\\\\[ \t]*\n" " ") ; And collapse spaces
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (mailcap-replace-regexp "\n+" "\n") ; And blank lines
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (goto-char (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (skip-chars-backward " \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (delete-region (point) (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (while (not (bobp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (skip-chars-backward " \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (beginning-of-line)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (setq save-pos (point)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 info nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (skip-chars-forward "^/; \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (downcase-region save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (setq major (buffer-substring save-pos (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (skip-chars-forward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (setq minor "")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (when (eq (char-after) ?/)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 (forward-char)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (skip-chars-forward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (setq save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (skip-chars-forward "^; \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (downcase-region save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (setq minor
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 ((eq ?* (or (char-after save-pos) 0)) ".*")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 ((= (point) save-pos) ".*")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 (t (regexp-quote (buffer-substring save-pos (point)))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 (skip-chars-forward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 ;;; Got the major/minor chunks, now for the viewers/etc
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 ;;; The first item _must_ be a viewer, according to the
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
419 ;;; RFC for mailcap files (#1524)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 (setq viewer "")
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
421 (when (eq (char-after) ?\;)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 (forward-char)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 (skip-chars-forward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 (setq save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (skip-chars-forward "^;\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 ;; skip \;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (while (eq (char-before) ?\\)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (backward-delete-char 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 (forward-char)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (skip-chars-forward "^;\n"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 (if (eq (or (char-after save-pos) 0) ?')
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (setq viewer (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 (narrow-to-region (1+ save-pos) (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 (prog1
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (read (current-buffer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (goto-char (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (widen))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (setq viewer (buffer-substring save-pos (point)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (setq save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (end-of-line)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
442 (unless (equal viewer "")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (setq info (nconc (list (cons 'viewer viewer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (cons 'type (concat major "/"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (if (string= minor ".*")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 "*" minor))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (mailcap-parse-mailcap-extras save-pos (point))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (mailcap-mailcap-entry-passes-test info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (mailcap-add-mailcap-entry major minor info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 (beginning-of-line)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 (defun mailcap-parse-mailcap-extras (st nd)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
453 "Grab all the extra stuff from a mailcap entry."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 (let (
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 name ; From name=
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 value ; its value
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 results ; Assoc list of results
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 name-pos ; Start of XXXX= position
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 val-pos ; Start of value position
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 done ; Found end of \'d ;s?
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 (narrow-to-region st nd)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (skip-chars-forward " \n\t;")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (while (not (eobp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (setq done nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (setq name-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 (skip-chars-forward "^ \n\t=;")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (downcase-region name-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (setq name (buffer-substring name-pos (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (skip-chars-forward " \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 (if (not (eq (char-after (point)) ?=)) ; There is no value
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (setq value t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (skip-chars-forward " \t\n=")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (setq val-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 (if (memq (char-after val-pos) '(?\" ?'))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 (setq val-pos (1+ val-pos))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 (condition-case nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (forward-sexp 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 (backward-char 1))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (error (goto-char (point-max)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (while (not done)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (skip-chars-forward "^;")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 (if (eq (char-after (1- (point))) ?\\ )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (subst-char-in-region (1- (point)) (point) ?\\ ? )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 (skip-chars-forward ";"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (setq done t))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (setq value (buffer-substring val-pos (point))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 (setq results (cons (cons name value) results))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 (skip-chars-forward " \";\n\t"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 results)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (defun mailcap-mailcap-entry-passes-test (info)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
498 "Return non-nil iff mailcap entry INFO passes its test clause.
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
499 Also return non-nil if no test clause is present."
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
500 (let ((test (assq 'test info)) ; The test clause
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
501 status)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 (setq status (and test (split-string (cdr test) " ")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (if (and (or (assoc "needsterm" info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (assoc "needsterminal" info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (assoc "needsx11" info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (not (getenv "DISPLAY")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (setq status nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 ((and (equal (nth 0 status) "test")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 (equal (nth 1 status) "-n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (or (equal (nth 2 status) "$DISPLAY")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 (equal (nth 2 status) "\"$DISPLAY\"")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 (setq status (if (getenv "DISPLAY") t nil)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 ((and (equal (nth 0 status) "test")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 (equal (nth 1 status) "-z")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 (or (equal (nth 2 status) "$DISPLAY")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (equal (nth 2 status) "\"$DISPLAY\"")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (setq status (if (getenv "DISPLAY") nil t)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 (test nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (t nil)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 (and test (listp test) (setcdr test status))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 ;;; The action routines.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (defun mailcap-possible-viewers (major minor)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
528 "Return a list of possible viewers from MAJOR for minor type MINOR."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 (let ((exact '())
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (wildcard '()))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 (while major
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 ((equal (car (car major)) minor)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (setq exact (cons (cdr (car major)) exact)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 ((and minor (string-match (car (car major)) minor))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 (setq wildcard (cons (cdr (car major)) wildcard))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 (setq major (cdr major)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (nconc exact wildcard)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 (defun mailcap-unescape-mime-test (test type-info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (let (save-pos save-chr subst)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 ((symbolp test) test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 ((and (listp test) (symbolp (car test))) test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 ((or (stringp test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (and (listp test) (stringp (car test))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (setq test (mapconcat 'identity test " "))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 (with-temp-buffer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 (insert test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 (while (not (eobp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (skip-chars-forward "^%")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (if (/= (- (point)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (progn (skip-chars-backward "\\\\")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 0) ; It is an escaped %
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (delete-char 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 (skip-chars-forward "%."))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 (setq save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 (skip-chars-forward "%")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (setq save-chr (char-after (point)))
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
563 ;; Escapes:
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
564 ;; %s: name of a file for the body data
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
565 ;; %t: content-type
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
566 ;; %{<parameter name}: value of parameter in mailcap entry
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
567 ;; %n: number of sub-parts for multipart content-type
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
568 ;; %F: a set of content-type/filename pairs for multiparts
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 ((null save-chr) nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 ((= save-chr ?t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 (delete-region save-pos (progn (forward-char 1) (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 (insert (or (cdr (assq 'type type-info)) "\"\"")))
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
574 ((memq save-chr '(?M ?n ?F))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 (delete-region save-pos (progn (forward-char 1) (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 (insert "\"\""))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 ((= save-chr ?{)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 (forward-char 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (skip-chars-forward "^}")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 (downcase-region (+ 2 save-pos) (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 (setq subst (buffer-substring (+ 2 save-pos) (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 (delete-region save-pos (1+ (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 (insert (or (cdr (assoc subst type-info)) "\"\"")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 (t nil))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 (buffer-string)))
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
586 (t (error "Bad value to mailcap-unescape-mime-test: %s" test)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 (defvar mailcap-viewer-test-cache nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 (defun mailcap-viewer-passes-test (viewer-info type-info)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
591 "Return non-nil iff viewer specified by VIEWER-INFO passes its test clause.
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
592 Also retun non-nil if it has no test clause. TYPE-INFO is an argument
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
593 to supply to the test."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 (let* ((test-info (assq 'test viewer-info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 (test (cdr test-info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 (otest test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 (viewer (cdr (assoc 'viewer viewer-info)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 (default-directory (expand-file-name "~/"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 status parsed-test cache result)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 (if (setq cache (assoc test mailcap-viewer-test-cache))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 (cadr cache)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 (setq
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603 result
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 ((not test-info) t) ; No test clause
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606 ((not test) nil) ; Already failed test
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 ((eq test t) t) ; Already passed test
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
608 ((functionp test) ; Lisp function as test
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
609 (funcall test type-info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610 ((and (symbolp test) ; Lisp variable as test
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611 (boundp test))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612 (symbol-value test))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613 ((and (listp test) ; List to be eval'd
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614 (symbolp (car test)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615 (eval test))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616 (t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617 (setq test (mailcap-unescape-mime-test test type-info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 test (list shell-file-name nil nil nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619 shell-command-switch test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620 status (apply 'call-process test))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621 (= 0 status))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622 (push (list otest result) mailcap-viewer-test-cache)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623 result)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 (defun mailcap-add-mailcap-entry (major minor info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
626 (let ((old-major (assoc major mailcap-mime-data)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 (if (null old-major) ; New major area
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 (setq mailcap-mime-data
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 (cons (cons major (list (cons minor info)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 mailcap-mime-data))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 (let ((cur-minor (assoc minor old-major)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 ((or (null cur-minor) ; New minor area, or
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 (assq 'test info)) ; Has a test, insert at beginning
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 (setcdr old-major (cons (cons minor info) (cdr old-major))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 ((and (not (assq 'test info)) ; No test info, replace completely
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 (not (assq 'test cur-minor))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 (equal (assq 'viewer info) ; Keep alternative viewer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 (assq 'viewer cur-minor)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
640 (setcdr cur-minor info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 (t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642 (setcdr old-major (cons (cons minor info) (cdr old-major))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
643 )))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 (defun mailcap-add (type viewer &optional test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646 "Add VIEWER as a handler for TYPE.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
647 If TEST is not given, it defaults to t."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
648 (let ((tl (split-string type "/")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
649 (when (or (not (car tl))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
650 (not (cadr tl)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651 (error "%s is not a valid MIME type" type))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
652 (mailcap-add-mailcap-entry
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
653 (car tl) (cadr tl)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654 `((viewer . ,viewer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
655 (test . ,(if test test t))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656 (type . ,type)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
657
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659 ;;; The main whabbo
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
662 (defun mailcap-viewer-lessp (x y)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
663 "Return t iff viewer X is more desirable than viewer Y."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
664 (let ((x-wild (string-match "[*?]" (or (cdr-safe (assq 'type x)) "")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
665 (y-wild (string-match "[*?]" (or (cdr-safe (assq 'type y)) "")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666 (x-lisp (not (stringp (or (cdr-safe (assq 'viewer x)) ""))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667 (y-lisp (not (stringp (or (cdr-safe (assq 'viewer y)) "")))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 ((and x-wild (not y-wild))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671 ((and (not x-wild) y-wild)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
672 t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673 ((and (not y-lisp) x-lisp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674 t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675 (t nil))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 (defun mailcap-mime-info (string &optional request)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678 "Get the MIME viewer command for STRING, return nil if none found.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679 Expects a complete content-type header line as its argument.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 Second argument REQUEST specifies what information to return. If it is
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 nil or the empty string, the viewer (second field of the mailcap
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 entry) will be returned. If it is a string, then the mailcap field
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
684 corresponding to that string will be returned (print, description,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 whatever). If a number, then all the information for this specific
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686 viewer is returned. If `all', then all possible viewers for
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 this type is returned."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
688 (let (
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
689 major ; Major encoding (text, etc)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 minor ; Minor encoding (html, etc)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
691 info ; Other info
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692 save-pos ; Misc. position during parse
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693 major-info ; (assoc major mailcap-mime-data)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
694 minor-info ; (assoc minor major-info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695 test ; current test proc.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696 viewers ; Possible viewers
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697 passed ; Viewers that passed the test
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698 viewer ; The one and only viewer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 ctl)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
700 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
701 (setq ctl (mail-header-parse-content-type (or string "text/plain")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
702 (setq major (split-string (car ctl) "/"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703 (setq minor (cadr major)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
704 major (car major))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
705 (when (setq major-info (cdr (assoc major mailcap-mime-data)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706 (when (setq viewers (mailcap-possible-viewers major-info minor))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707 (setq info (mapcar (lambda (a) (cons (symbol-name (car a))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 (cdr a)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 (cdr ctl)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710 (while viewers
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711 (if (mailcap-viewer-passes-test (car viewers) info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 (setq passed (cons (car viewers) passed)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713 (setq viewers (cdr viewers)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 (setq passed (sort passed 'mailcap-viewer-lessp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 (setq viewer (car passed))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
716 (when (and (stringp (cdr (assq 'viewer viewer)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
717 passed)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718 (setq viewer (car passed)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720 ((and (null viewer) (not (equal major "default")) request)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 (mailcap-mime-info "default" request))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722 ((or (null request) (equal request ""))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 (mailcap-unescape-mime-test (cdr (assq 'viewer viewer)) info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
724 ((stringp request)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
725 (if (or (eq request 'test) (eq request 'viewer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 (mailcap-unescape-mime-test
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727 (cdr-safe (assoc request viewer)) info)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728 ((eq request 'all)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 passed)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
730 (t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
731 ;; MUST make a copy *sigh*, else we modify mailcap-mime-data
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
732 (setq viewer (copy-sequence viewer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
733 (let ((view (assq 'viewer viewer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734 (test (assq 'test viewer)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 (if view (setcdr view (mailcap-unescape-mime-test (cdr view) info)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 (if test (setcdr test (mailcap-unescape-mime-test (cdr test) info))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 viewer)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740 ;;; Experimental MIME-types parsing
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
742
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743 (defvar mailcap-mime-extensions
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
744 '(("" . "text/plain")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
745 (".abs" . "audio/x-mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
746 (".aif" . "audio/aiff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
747 (".aifc" . "audio/aiff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
748 (".aiff" . "audio/aiff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
749 (".ano" . "application/x-annotator")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
750 (".au" . "audio/ulaw")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
751 (".avi" . "video/x-msvideo")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
752 (".bcpio" . "application/x-bcpio")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
753 (".bin" . "application/octet-stream")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
754 (".cdf" . "application/x-netcdr")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
755 (".cpio" . "application/x-cpio")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
756 (".csh" . "application/x-csh")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
757 (".css" . "text/css")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
758 (".dvi" . "application/x-dvi")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
759 (".diff" . "text/x-patch")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
760 (".el" . "application/emacs-lisp")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
761 (".eps" . "application/postscript")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
762 (".etx" . "text/x-setext")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
763 (".exe" . "application/octet-stream")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
764 (".fax" . "image/x-fax")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
765 (".gif" . "image/gif")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
766 (".hdf" . "application/x-hdf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
767 (".hqx" . "application/mac-binhex40")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
768 (".htm" . "text/html")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
769 (".html" . "text/html")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
770 (".icon" . "image/x-icon")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
771 (".ief" . "image/ief")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
772 (".jpg" . "image/jpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
773 (".macp" . "image/x-macpaint")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
774 (".man" . "application/x-troff-man")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
775 (".me" . "application/x-troff-me")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
776 (".mif" . "application/mif")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
777 (".mov" . "video/quicktime")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
778 (".movie" . "video/x-sgi-movie")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
779 (".mp2" . "audio/x-mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
780 (".mp3" . "audio/x-mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
781 (".mp2a" . "audio/x-mpeg2")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
782 (".mpa" . "audio/x-mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
783 (".mpa2" . "audio/x-mpeg2")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
784 (".mpe" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
785 (".mpeg" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
786 (".mpega" . "audio/x-mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
787 (".mpegv" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
788 (".mpg" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
789 (".mpv" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
790 (".ms" . "application/x-troff-ms")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
791 (".nc" . "application/x-netcdf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
792 (".nc" . "application/x-netcdf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
793 (".oda" . "application/oda")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
794 (".patch" . "text/x-patch")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
795 (".pbm" . "image/x-portable-bitmap")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
796 (".pdf" . "application/pdf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
797 (".pgm" . "image/portable-graymap")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
798 (".pict" . "image/pict")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
799 (".png" . "image/png")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
800 (".pnm" . "image/x-portable-anymap")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
801 (".ppm" . "image/portable-pixmap")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
802 (".ps" . "application/postscript")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
803 (".qt" . "video/quicktime")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
804 (".ras" . "image/x-raster")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
805 (".rgb" . "image/x-rgb")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
806 (".rtf" . "application/rtf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
807 (".rtx" . "text/richtext")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
808 (".sh" . "application/x-sh")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
809 (".sit" . "application/x-stuffit")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
810 (".snd" . "audio/basic")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
811 (".src" . "application/x-wais-source")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
812 (".tar" . "archive/tar")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
813 (".tcl" . "application/x-tcl")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
814 (".tex" . "application/x-tex")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
815 (".texi" . "application/texinfo")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
816 (".tga" . "image/x-targa")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
817 (".tif" . "image/tiff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
818 (".tiff" . "image/tiff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
819 (".tr" . "application/x-troff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
820 (".troff" . "application/x-troff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
821 (".tsv" . "text/tab-separated-values")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
822 (".txt" . "text/plain")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
823 (".vbs" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
824 (".vox" . "audio/basic")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
825 (".vrml" . "x-world/x-vrml")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
826 (".wav" . "audio/x-wav")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
827 (".wrl" . "x-world/x-vrml")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
828 (".xbm" . "image/xbm")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
829 (".xpm" . "image/xpm")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
830 (".xwd" . "image/windowdump")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
831 (".zip" . "application/zip")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
832 (".ai" . "application/postscript")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
833 (".jpe" . "image/jpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
834 (".jpeg" . "image/jpeg"))
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
835 "An alist of file extensions and corresponding MIME content-types.
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
836 This exists for you to customize the information in Lisp. It is
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
837 merged with values from mailcap files by `mailcap-parse-mimetypes'.")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
838
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
839 (defvar mailcap-mimetypes-parsed-p nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
840
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
841 (defun mailcap-parse-mimetypes (&optional path force)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
842 "Parse out all the mimetypes specified in a Unix-style path string PATH.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
843 Components of PATH are separated by the `path-separator' character
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
844 appropriate for this system. If PATH is omitted, use the value of
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
845 environment variable MIMETYPES if set; otherwise use a default path.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
846 If FORCE, re-parse even if already parsed."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
847 (interactive (list nil t))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
848 (when (or (not mailcap-mimetypes-parsed-p)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
849 force)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
850 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
851 (path nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
852 ((getenv "MIMETYPES") (setq path (getenv "MIMETYPES")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
853 ((memq system-type '(ms-dos ms-windows windows-nt))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
854 (setq path '("~/mime.typ" "~/etc/mime.typ")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
855 (t (setq path
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
856 ;; mime.types seems to be the normal name, definitely so
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
857 ;; on current GNUish systems. The search order follows
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858 ;; that for mailcap.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
859 '("~/.mime.types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
860 "/etc/mime.types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 "/usr/etc/mime.types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
862 "/usr/local/etc/mime.types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
863 "/usr/local/www/conf/mime.types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864 "~/.mime-types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
865 "/etc/mime-types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
866 "/usr/etc/mime-types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
867 "/usr/local/etc/mime-types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
868 "/usr/local/www/conf/mime-types"))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
869 (let ((fnames (reverse (if (stringp path)
32989
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
870 (delete "" (split-string path path-separator))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
871 path)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
872 fname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
873 (while fnames
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
874 (setq fname (car fnames))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
875 (if (and (file-readable-p fname))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
876 (mailcap-parse-mimetype-file fname))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
877 (setq fnames (cdr fnames))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878 (setq mailcap-mimetypes-parsed-p t)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
879
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
880 (defun mailcap-parse-mimetype-file (fname)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
881 "Parse out a mime-types file FNAME."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
882 (let (type ; The MIME type for this line
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
883 extns ; The extensions for this line
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
884 save-pos ; Misc. saved buffer positions
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
885 )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
886 (with-temp-buffer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
887 (insert-file-contents fname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
888 (mailcap-replace-regexp "#.*" "")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889 (mailcap-replace-regexp "\n+" "\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
890 (mailcap-replace-regexp "[ \t]+$" "")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
891 (goto-char (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
892 (skip-chars-backward " \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
893 (delete-region (point) (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
894 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
895 (while (not (eobp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
896 (skip-chars-forward " \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
897 (setq save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
898 (skip-chars-forward "^ \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
899 (downcase-region save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
900 (setq type (buffer-substring save-pos (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
901 (while (not (eolp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
902 (skip-chars-forward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
903 (setq save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
904 (skip-chars-forward "^ \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
905 (setq extns (cons (buffer-substring save-pos (point)) extns)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
906 (while extns
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
907 (setq mailcap-mime-extensions
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
908 (cons
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
909 (cons (if (= (string-to-char (car extns)) ?.)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
910 (car extns)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
911 (concat "." (car extns))) type)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
912 mailcap-mime-extensions)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
913 extns (cdr extns)))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
914
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
915 (defun mailcap-extension-to-mime (extn)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
916 "Return the MIME content type of the file extensions EXTN."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
917 (mailcap-parse-mimetypes)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
918 (if (and (stringp extn)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
919 (not (eq (string-to-char extn) ?.)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
920 (setq extn (concat "." extn)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
921 (cdr (assoc (downcase extn) mailcap-mime-extensions)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
922
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
923 ;; Unused?
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
924 (defalias 'mailcap-command-p 'executable-find)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
925
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
926 (defun mailcap-mime-types ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
927 "Return a list of MIME media types."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
928 (mailcap-parse-mimetypes)
32989
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
929 (mm-delete-duplicates
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
930 (nconc
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
931 (mapcar 'cdr mailcap-mime-extensions)
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
932 (apply
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
933 'nconc
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
934 (mapcar
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
935 (lambda (l)
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
936 (delq nil
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
937 (mapcar
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
938 (lambda (m)
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
939 (let ((type (cdr (assq 'type (cdr m)))))
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
940 (if (equal (cadr (split-string type "/"))
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
941 "*")
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
942 nil
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
943 type)))
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
944 (cdr l))))
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
945 mailcap-mime-data)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
946
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
947 (provide 'mailcap)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
948
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
949 ;;; mailcap.el ends here