annotate lisp/gnus/mailcap.el @ 84529:9b395ed6df4b

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