annotate lisp/gnus/mailcap.el @ 33853:eb4affa4abc6

(lface_from_face_name): Function comment fix.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 24 Nov 2000 13:17:42 +0000
parents 61905a6a0029
children 8b1375dbcbc6
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
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
276 "*Where downloaded files should go by default."
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
277 :type 'directory
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
278 :group 'mailcap)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 ;;; Utility functions
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
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 (defun mailcap-save-binary-file ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (unwind-protect
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (let ((file (read-file-name
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 "Filename to save as: "
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (or mailcap-download-directory "~/")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (require-final-newline nil))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (write-region (point-min) (point-max) file))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (kill-buffer (current-buffer))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (defvar mailcap-maybe-eval-warning
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 "*** WARNING ***
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
297 This MIME part contains untrusted and possibly harmful content.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 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
299 things can happen. Please examine the code very carefully before you
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 instruct Emacs to evaluate it. You can browse the buffer containing
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 the code using \\[scroll-other-window].
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 If you are unsure what to do, please answer \"no\"."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 "Text of warning message displayed by `mailcap-maybe-eval'.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 Make sure that this text consists only of few text lines. Otherwise,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 Gnus might fail to display all of it.")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (defun mailcap-maybe-eval ()
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
309 "Maybe evaluate a buffer of Emacs Lisp code."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (let ((lisp-buffer (current-buffer)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (when
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (save-window-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (delete-other-windows)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (let ((buffer (get-buffer-create (generate-new-buffer-name
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 "*Warning*"))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (unwind-protect
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (with-current-buffer buffer
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
319 (insert (substitute-command-keys
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 mailcap-maybe-eval-warning))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 (display-buffer buffer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (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
324 (kill-buffer buffer))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (eval-buffer (current-buffer)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (when (buffer-live-p lisp-buffer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 (with-current-buffer lisp-buffer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 (emacs-lisp-mode)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330
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 ;;; The mailcap parser
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
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (defun mailcap-replace-regexp (regexp to-string)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 ;; Quiet replace-regexp.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (while (re-search-forward regexp nil t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 (replace-match to-string t nil)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (defvar mailcap-parsed-p 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 (defun mailcap-parse-mailcaps (&optional path force)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 "Parse out all the mailcaps specified in a path string PATH.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 Components of PATH are separated by the `path-separator' character
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 appropriate for this system. If FORCE, re-parse even if already
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 parsed. If PATH is omitted, use the value of environment variable
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 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
349 /usr/local/etc/mailcap."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (interactive (list nil t))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (when (or (not mailcap-parsed-p)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 force)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (path nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 ((getenv "MAILCAPS") (setq path (getenv "MAILCAPS")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 ((memq system-type '(ms-dos ms-windows windows-nt))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (setq path '("~/.mailcap" "~/mail.cap" "~/etc/mail.cap")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 (t (setq path
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 ;; This is per RFC 1524, specifically
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 ;; with /usr before /usr/local.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 '("~/.mailcap" "/etc/mailcap" "/usr/etc/mailcap"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 "/usr/local/etc/mailcap"))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (let ((fnames (reverse
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (if (stringp path)
32989
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
365 (delete "" (split-string path path-separator))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 path)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 fname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (while fnames
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 (setq fname (car fnames))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 (if (and (file-readable-p fname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (file-regular-p fname))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (mailcap-parse-mailcap fname))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 (setq fnames (cdr fnames))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 (setq mailcap-parsed-p t)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (defun mailcap-parse-mailcap (fname)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
377 "Parse out the mailcap file specified by FNAME."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (let (major ; The major mime type (image/audio/etc)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 minor ; The minor mime type (gif, basic, etc)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 save-pos ; Misc saved positions used in parsing
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 viewer ; How to view this mime type
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 info ; Misc info about this mime type
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 (with-temp-buffer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (insert-file-contents fname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 (set-syntax-table mailcap-parse-args-syntax-table)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (mailcap-replace-regexp "#.*" "") ; Remove all comments
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (mailcap-replace-regexp "\\\\[ \t]*\n" " ") ; And collapse spaces
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 (mailcap-replace-regexp "\n+" "\n") ; And blank lines
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (goto-char (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (skip-chars-backward " \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (delete-region (point) (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (while (not (bobp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (skip-chars-backward " \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (beginning-of-line)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (setq save-pos (point)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 info nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (skip-chars-forward "^/; \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (downcase-region save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (setq major (buffer-substring save-pos (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (skip-chars-forward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (setq minor "")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (when (eq (char-after) ?/)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (forward-char)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (skip-chars-forward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 (setq save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (skip-chars-forward "^; \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (downcase-region save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (setq minor
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 ((eq ?* (or (char-after save-pos) 0)) ".*")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 ((= (point) save-pos) ".*")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 (t (regexp-quote (buffer-substring save-pos (point)))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (skip-chars-forward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 ;;; Got the major/minor chunks, now for the viewers/etc
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 ;;; The first item _must_ be a viewer, according to the
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
417 ;;; RFC for mailcap files (#1524)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (setq viewer "")
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
419 (when (eq (char-after) ?\;)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 (forward-char)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (skip-chars-forward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 (setq save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 (skip-chars-forward "^;\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 ;; skip \;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (while (eq (char-before) ?\\)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (backward-delete-char 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (forward-char)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (skip-chars-forward "^;\n"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 (if (eq (or (char-after save-pos) 0) ?')
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (setq viewer (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 (narrow-to-region (1+ save-pos) (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 (prog1
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 (read (current-buffer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 (goto-char (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 (widen))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (setq viewer (buffer-substring save-pos (point)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (setq save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (end-of-line)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
440 (unless (equal viewer "")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (setq info (nconc (list (cons 'viewer viewer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (cons 'type (concat major "/"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (if (string= minor ".*")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 "*" minor))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (mailcap-parse-mailcap-extras save-pos (point))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (mailcap-mailcap-entry-passes-test info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (mailcap-add-mailcap-entry major minor info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (beginning-of-line)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 (defun mailcap-parse-mailcap-extras (st nd)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
451 "Grab all the extra stuff from a mailcap entry."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 (let (
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 name ; From name=
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 value ; its value
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 results ; Assoc list of results
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 name-pos ; Start of XXXX= position
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 val-pos ; Start of value position
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 done ; Found end of \'d ;s?
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (narrow-to-region st nd)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 (skip-chars-forward " \n\t;")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (while (not (eobp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (setq done nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (setq name-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (skip-chars-forward "^ \n\t=;")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (downcase-region name-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 (setq name (buffer-substring name-pos (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (skip-chars-forward " \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (if (not (eq (char-after (point)) ?=)) ; There is no value
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (setq value t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 (skip-chars-forward " \t\n=")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (setq val-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (if (memq (char-after val-pos) '(?\" ?'))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 (setq val-pos (1+ val-pos))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (condition-case nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 (forward-sexp 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 (backward-char 1))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (error (goto-char (point-max)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 (while (not done)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (skip-chars-forward "^;")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (if (eq (char-after (1- (point))) ?\\ )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 (subst-char-in-region (1- (point)) (point) ?\\ ? )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (skip-chars-forward ";"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (setq done t))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 (setq value (buffer-substring val-pos (point))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (setq results (cons (cons name value) results))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (skip-chars-forward " \";\n\t"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 results)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 (defun mailcap-mailcap-entry-passes-test (info)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
496 "Return non-nil iff mailcap entry INFO passes its test clause.
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
497 Also return non-nil if no test clause is present."
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
498 (let ((test (assq 'test info)) ; The test clause
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
499 status)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (setq status (and test (split-string (cdr test) " ")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (if (and (or (assoc "needsterm" info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 (assoc "needsterminal" info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (assoc "needsx11" info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (not (getenv "DISPLAY")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (setq status nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 ((and (equal (nth 0 status) "test")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (equal (nth 1 status) "-n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (or (equal (nth 2 status) "$DISPLAY")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 (equal (nth 2 status) "\"$DISPLAY\"")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (setq status (if (getenv "DISPLAY") t nil)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 ((and (equal (nth 0 status) "test")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 (equal (nth 1 status) "-z")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 (or (equal (nth 2 status) "$DISPLAY")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 (equal (nth 2 status) "\"$DISPLAY\"")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 (setq status (if (getenv "DISPLAY") nil t)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (test nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (t nil)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 (and test (listp test) (setcdr test status))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 ;;; The action routines.
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
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (defun mailcap-possible-viewers (major minor)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
526 "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
527 (let ((exact '())
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 (wildcard '()))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 (while major
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 ((equal (car (car major)) minor)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (setq exact (cons (cdr (car major)) exact)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 ((and minor (string-match (car (car major)) minor))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (setq wildcard (cons (cdr (car major)) wildcard))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 (setq major (cdr major)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 (nconc exact wildcard)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (defun mailcap-unescape-mime-test (test type-info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (let (save-pos save-chr subst)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 ((symbolp test) test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 ((and (listp test) (symbolp (car test))) test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 ((or (stringp test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 (and (listp test) (stringp (car test))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 (setq test (mapconcat 'identity test " "))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (with-temp-buffer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (insert test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 (while (not (eobp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (skip-chars-forward "^%")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 (if (/= (- (point)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (progn (skip-chars-backward "\\\\")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 0) ; It is an escaped %
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 (progn
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 (delete-char 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (skip-chars-forward "%."))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (setq save-pos (point))
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-chr (char-after (point)))
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
561 ;; Escapes:
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
562 ;; %s: name of a file for the body data
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
563 ;; %t: content-type
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
564 ;; %{<parameter name}: value of parameter in mailcap entry
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
565 ;; %n: number of sub-parts for multipart content-type
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
566 ;; %F: a set of content-type/filename pairs for multiparts
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 ((null save-chr) nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 ((= save-chr ?t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 (delete-region save-pos (progn (forward-char 1) (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 (insert (or (cdr (assq 'type type-info)) "\"\"")))
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
572 ((memq save-chr '(?M ?n ?F))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 (delete-region save-pos (progn (forward-char 1) (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 (insert "\"\""))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 ((= save-chr ?{)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 (forward-char 1)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (skip-chars-forward "^}")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 (downcase-region (+ 2 save-pos) (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (setq subst (buffer-substring (+ 2 save-pos) (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 (delete-region save-pos (1+ (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 (insert (or (cdr (assoc subst type-info)) "\"\"")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 (t nil))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 (buffer-string)))
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
584 (t (error "Bad value to mailcap-unescape-mime-test: %s" test)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 (defvar mailcap-viewer-test-cache nil)
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 (defun mailcap-viewer-passes-test (viewer-info type-info)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
589 "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
590 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
591 to supply to the test."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 (let* ((test-info (assq 'test viewer-info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 (test (cdr test-info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 (otest test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 (viewer (cdr (assoc 'viewer viewer-info)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 (default-directory (expand-file-name "~/"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 status parsed-test cache result)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 (if (setq cache (assoc test mailcap-viewer-test-cache))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 (cadr cache)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 (setq
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 result
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603 ((not test-info) t) ; No test clause
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604 ((not test) nil) ; Already failed test
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 ((eq test t) t) ; Already passed test
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
606 ((functionp test) ; Lisp function as test
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 (funcall test type-info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608 ((and (symbolp test) ; Lisp variable as test
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
609 (boundp test))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610 (symbol-value test))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611 ((and (listp test) ; List to be eval'd
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612 (symbolp (car test)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613 (eval test))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614 (t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615 (setq test (mailcap-unescape-mime-test test type-info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616 test (list shell-file-name nil nil nil
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617 shell-command-switch test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 status (apply 'call-process test))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619 (= 0 status))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620 (push (list otest result) mailcap-viewer-test-cache)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621 result)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623 (defun mailcap-add-mailcap-entry (major minor info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624 (let ((old-major (assoc major mailcap-mime-data)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 (if (null old-major) ; New major area
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
626 (setq mailcap-mime-data
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 (cons (cons major (list (cons minor info)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 mailcap-mime-data))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 (let ((cur-minor (assoc minor old-major)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 ((or (null cur-minor) ; New minor area, or
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 (assq 'test info)) ; Has a test, insert at beginning
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 (setcdr old-major (cons (cons minor info) (cdr old-major))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 ((and (not (assq 'test info)) ; No test info, replace completely
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 (not (assq 'test cur-minor))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 (equal (assq 'viewer info) ; Keep alternative viewer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 (assq 'viewer cur-minor)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 (setcdr cur-minor info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 (t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
640 (setcdr old-major (cons (cons minor info) (cdr old-major))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 )))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
643 (defun mailcap-add (type viewer &optional test)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644 "Add VIEWER as a handler for TYPE.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 If TEST is not given, it defaults to t."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646 (let ((tl (split-string type "/")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
647 (when (or (not (car tl))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
648 (not (cadr tl)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
649 (error "%s is not a valid MIME type" type))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
650 (mailcap-add-mailcap-entry
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651 (car tl) (cadr tl)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
652 `((viewer . ,viewer)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
653 (test . ,(if test test t))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654 (type . ,type)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
655
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
657 ;;; The main whabbo
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
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660 (defun mailcap-viewer-lessp (x y)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
661 "Return t iff viewer X is more desirable than viewer Y."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
662 (let ((x-wild (string-match "[*?]" (or (cdr-safe (assq 'type x)) "")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663 (y-wild (string-match "[*?]" (or (cdr-safe (assq 'type y)) "")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
664 (x-lisp (not (stringp (or (cdr-safe (assq 'viewer x)) ""))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
665 (y-lisp (not (stringp (or (cdr-safe (assq 'viewer y)) "")))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667 ((and x-wild (not y-wild))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668 nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 ((and (not x-wild) y-wild)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 t)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671 ((and (not y-lisp) x-lisp)
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 (t nil))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675 (defun mailcap-mime-info (string &optional request)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 "Get the MIME viewer command for STRING, return nil if none found.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 Expects a complete content-type header line as its argument.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679 Second argument REQUEST specifies what information to return. If it is
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680 nil or the empty string, the viewer (second field of the mailcap
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 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
682 corresponding to that string will be returned (print, description,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 whatever). If a number, then all the information for this specific
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
684 viewer is returned. If `all', then all possible viewers for
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 this type is returned."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686 (let (
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 major ; Major encoding (text, etc)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
688 minor ; Minor encoding (html, etc)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
689 info ; Other info
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 save-pos ; Misc. position during parse
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
691 major-info ; (assoc major mailcap-mime-data)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692 minor-info ; (assoc minor major-info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693 test ; current test proc.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
694 viewers ; Possible viewers
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695 passed ; Viewers that passed the test
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696 viewer ; The one and only viewer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697 ctl)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 (setq ctl (mail-header-parse-content-type (or string "text/plain")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
700 (setq major (split-string (car ctl) "/"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
701 (setq minor (cadr major)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
702 major (car major))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703 (when (setq major-info (cdr (assoc major mailcap-mime-data)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
704 (when (setq viewers (mailcap-possible-viewers major-info minor))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
705 (setq info (mapcar (lambda (a) (cons (symbol-name (car a))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706 (cdr a)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707 (cdr ctl)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 (while viewers
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 (if (mailcap-viewer-passes-test (car viewers) info)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710 (setq passed (cons (car viewers) passed)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711 (setq viewers (cdr viewers)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 (setq passed (sort passed 'mailcap-viewer-lessp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713 (setq viewer (car passed))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 (when (and (stringp (cdr (assq 'viewer viewer)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 passed)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
716 (setq viewer (car passed)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
717 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718 ((and (null viewer) (not (equal major "default")) request)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 (mailcap-mime-info "default" request))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720 ((or (null request) (equal request ""))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 (mailcap-unescape-mime-test (cdr (assq 'viewer viewer)) info))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722 ((stringp request)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723 (if (or (eq request 'test) (eq request 'viewer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
724 (mailcap-unescape-mime-test
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
725 (cdr-safe (assoc request viewer)) info)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 ((eq request 'all)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727 passed)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728 (t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 ;; MUST make a copy *sigh*, else we modify mailcap-mime-data
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
730 (setq viewer (copy-sequence viewer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
731 (let ((view (assq 'viewer viewer))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
732 (test (assq 'test viewer)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
733 (if view (setcdr view (mailcap-unescape-mime-test (cdr view) info)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734 (if test (setcdr test (mailcap-unescape-mime-test (cdr test) info))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 viewer)))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738 ;;; Experimental MIME-types parsing
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
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741 (defvar mailcap-mime-extensions
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
742 '(("" . "text/plain")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
743 (".abs" . "audio/x-mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
744 (".aif" . "audio/aiff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
745 (".aifc" . "audio/aiff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
746 (".aiff" . "audio/aiff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
747 (".ano" . "application/x-annotator")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
748 (".au" . "audio/ulaw")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
749 (".avi" . "video/x-msvideo")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
750 (".bcpio" . "application/x-bcpio")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
751 (".bin" . "application/octet-stream")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
752 (".cdf" . "application/x-netcdr")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
753 (".cpio" . "application/x-cpio")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
754 (".csh" . "application/x-csh")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
755 (".css" . "text/css")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
756 (".dvi" . "application/x-dvi")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
757 (".diff" . "text/x-patch")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
758 (".el" . "application/emacs-lisp")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
759 (".eps" . "application/postscript")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
760 (".etx" . "text/x-setext")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
761 (".exe" . "application/octet-stream")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
762 (".fax" . "image/x-fax")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
763 (".gif" . "image/gif")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
764 (".hdf" . "application/x-hdf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
765 (".hqx" . "application/mac-binhex40")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
766 (".htm" . "text/html")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
767 (".html" . "text/html")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
768 (".icon" . "image/x-icon")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
769 (".ief" . "image/ief")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
770 (".jpg" . "image/jpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
771 (".macp" . "image/x-macpaint")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
772 (".man" . "application/x-troff-man")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
773 (".me" . "application/x-troff-me")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
774 (".mif" . "application/mif")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
775 (".mov" . "video/quicktime")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
776 (".movie" . "video/x-sgi-movie")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
777 (".mp2" . "audio/x-mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
778 (".mp3" . "audio/x-mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
779 (".mp2a" . "audio/x-mpeg2")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
780 (".mpa" . "audio/x-mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
781 (".mpa2" . "audio/x-mpeg2")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
782 (".mpe" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
783 (".mpeg" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
784 (".mpega" . "audio/x-mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
785 (".mpegv" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
786 (".mpg" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
787 (".mpv" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
788 (".ms" . "application/x-troff-ms")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
789 (".nc" . "application/x-netcdf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
790 (".nc" . "application/x-netcdf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
791 (".oda" . "application/oda")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
792 (".patch" . "text/x-patch")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
793 (".pbm" . "image/x-portable-bitmap")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
794 (".pdf" . "application/pdf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
795 (".pgm" . "image/portable-graymap")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
796 (".pict" . "image/pict")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
797 (".png" . "image/png")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
798 (".pnm" . "image/x-portable-anymap")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
799 (".ppm" . "image/portable-pixmap")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
800 (".ps" . "application/postscript")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
801 (".qt" . "video/quicktime")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
802 (".ras" . "image/x-raster")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
803 (".rgb" . "image/x-rgb")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
804 (".rtf" . "application/rtf")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
805 (".rtx" . "text/richtext")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
806 (".sh" . "application/x-sh")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
807 (".sit" . "application/x-stuffit")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
808 (".snd" . "audio/basic")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
809 (".src" . "application/x-wais-source")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
810 (".tar" . "archive/tar")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
811 (".tcl" . "application/x-tcl")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
812 (".tex" . "application/x-tex")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
813 (".texi" . "application/texinfo")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
814 (".tga" . "image/x-targa")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
815 (".tif" . "image/tiff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
816 (".tiff" . "image/tiff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
817 (".tr" . "application/x-troff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
818 (".troff" . "application/x-troff")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
819 (".tsv" . "text/tab-separated-values")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
820 (".txt" . "text/plain")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
821 (".vbs" . "video/mpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
822 (".vox" . "audio/basic")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
823 (".vrml" . "x-world/x-vrml")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
824 (".wav" . "audio/x-wav")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
825 (".wrl" . "x-world/x-vrml")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
826 (".xbm" . "image/xbm")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
827 (".xpm" . "image/xpm")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
828 (".xwd" . "image/windowdump")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
829 (".zip" . "application/zip")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
830 (".ai" . "application/postscript")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
831 (".jpe" . "image/jpeg")
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
832 (".jpeg" . "image/jpeg"))
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
833 "An alist of file extensions and corresponding MIME content-types.
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
834 This exists for you to customize the information in Lisp. It is
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
835 merged with values from mailcap files by `mailcap-parse-mimetypes'.")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
836
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
837 (defvar mailcap-mimetypes-parsed-p nil)
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 (defun mailcap-parse-mimetypes (&optional path force)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
840 "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
841 Components of PATH are separated by the `path-separator' character
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
842 appropriate for this system. If PATH is omitted, use the value of
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
843 environment variable MIMETYPES if set; otherwise use a default path.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
844 If FORCE, re-parse even if already parsed."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
845 (interactive (list nil t))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
846 (when (or (not mailcap-mimetypes-parsed-p)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
847 force)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
848 (cond
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
849 (path nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
850 ((getenv "MIMETYPES") (setq path (getenv "MIMETYPES")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
851 ((memq system-type '(ms-dos ms-windows windows-nt))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
852 (setq path '("~/mime.typ" "~/etc/mime.typ")))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
853 (t (setq path
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
854 ;; mime.types seems to be the normal name, definitely so
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
855 ;; on current GNUish systems. The search order follows
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
856 ;; that for mailcap.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
857 '("~/.mime.types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858 "/etc/mime.types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
859 "/usr/etc/mime.types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
860 "/usr/local/etc/mime.types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 "/usr/local/www/conf/mime.types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
862 "~/.mime-types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
863 "/etc/mime-types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864 "/usr/etc/mime-types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
865 "/usr/local/etc/mime-types"
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
866 "/usr/local/www/conf/mime-types"))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
867 (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
868 (delete "" (split-string path path-separator))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
869 path)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
870 fname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
871 (while fnames
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
872 (setq fname (car fnames))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
873 (if (and (file-readable-p fname))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
874 (mailcap-parse-mimetype-file fname))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
875 (setq fnames (cdr fnames))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
876 (setq mailcap-mimetypes-parsed-p t)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
877
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878 (defun mailcap-parse-mimetype-file (fname)
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
879 "Parse out a mime-types file FNAME."
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
880 (let (type ; The MIME type for this line
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
881 extns ; The extensions for this line
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
882 save-pos ; Misc. saved buffer positions
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
883 )
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
884 (with-temp-buffer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
885 (insert-file-contents fname)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
886 (mailcap-replace-regexp "#.*" "")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
887 (mailcap-replace-regexp "\n+" "\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
888 (mailcap-replace-regexp "[ \t]+$" "")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889 (goto-char (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
890 (skip-chars-backward " \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
891 (delete-region (point) (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
892 (goto-char (point-min))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
893 (while (not (eobp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
894 (skip-chars-forward " \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
895 (setq save-pos (point))
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 (downcase-region save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
898 (setq type (buffer-substring save-pos (point)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
899 (while (not (eolp))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
900 (skip-chars-forward " \t")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
901 (setq save-pos (point))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
902 (skip-chars-forward "^ \t\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
903 (setq extns (cons (buffer-substring save-pos (point)) extns)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
904 (while extns
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
905 (setq mailcap-mime-extensions
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
906 (cons
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
907 (cons (if (= (string-to-char (car extns)) ?.)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
908 (car extns)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
909 (concat "." (car extns))) type)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
910 mailcap-mime-extensions)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
911 extns (cdr extns)))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
912
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
913 (defun mailcap-extension-to-mime (extn)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
914 "Return the MIME content type of the file extensions EXTN."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
915 (mailcap-parse-mimetypes)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
916 (if (and (stringp extn)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
917 (not (eq (string-to-char extn) ?.)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
918 (setq extn (concat "." extn)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
919 (cdr (assoc (downcase extn) mailcap-mime-extensions)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
920
33821
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
921 ;; Unused?
61905a6a0029 Doc fixes.
Dave Love <fx@gnu.org>
parents: 33342
diff changeset
922 (defalias 'mailcap-command-p 'executable-find)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
923
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
924 (defun mailcap-mime-types ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
925 "Return a list of MIME media types."
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
926 (mailcap-parse-mimetypes)
32989
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
927 (mm-delete-duplicates
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
928 (nconc
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
929 (mapcar 'cdr mailcap-mime-extensions)
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
930 (apply
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
931 'nconc
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
932 (mapcar
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
933 (lambda (l)
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
934 (delq nil
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
935 (mapcar
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
936 (lambda (m)
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
937 (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
938 (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
939 "*")
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
940 nil
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
941 type)))
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
942 (cdr l))))
74484f2d629a 2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu>
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
943 mailcap-mime-data)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
944
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
945 (provide 'mailcap)
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 ;;; mailcap.el ends here