annotate lisp/packages/mime-compose.el @ 88:821dec489c24 r20-0

Import from CVS: tag r20-0
author cvs
date Mon, 13 Aug 2007 09:09:59 +0200
parents 131b0175ea99
children 360340f9fd5f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; File: --- mime-compose.el ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Author: Marc Andreessen (marca@ncsa.uiuc.edu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Additional code: Keith Waclena (k-waclena@uchicago.edu).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; Christopher Davis (ckd@eff.org).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; Copyright (C) National Center for Supercomputing Applications, 1992.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; along with your copy of Emacs; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; -------------------------------- CONTENTS --------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; mime-compose: Utility routines for composing MIME-compliant mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; !Revision: 1.5 !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; !Date: 1994/03/24 00:00:47 !
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Canonical list of features:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Automatic MIME header construction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; Include GIF/JPEG image.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Include audio file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Include PostScript file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; Include MPEG animation sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Include raw binary/nonbinary file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; Include xwd window dump taken on the fly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; Include reference to anonymous/regular FTP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; Include audio snippet recorded on the fly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; Convert region to MIME richtext.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; Convert region to any ISO 8859 charset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; Optional conversion of plaintext bodyparts to quoted-printable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; with arbitrary charset when messages are sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; Deemphasizing/highlighting of MIME headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; Completion on content type and charset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; Automatic encoding in base64 and quoted-printable formats.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; Selective display hides raw data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; Works with mail-mode and mh.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;; ------------------------------ INSTRUCTIONS ------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; Use the normal Emacs mail composer (C-x m).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; (Or, use with Emacs mh-e by loading this file *after* loading mh-e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; But due to incestuous hookification, you can't require mime-compose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; inside mh-letter-mode-hook.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; Do nothing special to prepare a message to have MIME elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; included in it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; The basic commands to add MIME elements (images, audio, etc.) to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; message are as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; mail-mode (mh-e) function what happens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; ~~~~~~~~~ (~~~~~~~~~) ~~~~~~~~ ~~~~~~~~~~~~
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; C-c g (C-c C-m g) mime-include-gif Add a GIF file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; C-c j (C-c C-m j) mime-include-jpeg Add a JPEG file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; C-c a (C-c C-m a) mime-include-audio Add an audio file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; C-c p (C-c C-m p) mime-include-postscript Add a PostScript file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; C-c v (C-c C-m v) mime-include-mpeg Add an MPEG file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; (Note that mime-compose assumes you have the 'mmencode' program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;; installed on your system. See 'WHAT MIME IS' below for more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; information on mmencode and the metamail distribution.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; Some mime-compose commands create data themselves; these follow:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;; C-c x (C-c C-m x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;; mime-include-xwd-dump
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; Add the result of an X-window dump. The program named in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; mime-xwd-command will be run, and the resulting dump will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;; inserted into the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; C-c s (C-c C-m s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; mime-include-audio-snippet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;; Add an audio snippet, recorded on the fly. CURRENTLY THIS WORKS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; ONLY FOR SILICON GRAPHICS INDIGO AND 4D/35's. The Sun version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;; may also work; see the source code below. Recording begins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; immediately; press 'y' to end recording or 'n' to abort the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; whole process. The resulting audio file will be converted to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; standard mulaw format and incorporated into the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; If you have a raw binary file and MIME or mime-compose doesn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; have built-in support for its format (e.g. an Emacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; byte-compiled file), you can use:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; C-c r (C-c C-m r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; mime-include-raw-binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; Add a raw binary file. You will be prompted for both the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; filename and the content type of the file; if you do not give a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; content type, the default (application/octet-stream) will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; used, and the recipient will be able to have his/her MIME mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; handler extract the raw binary file from the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; Similarly, to include nonbinary (text) files using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; quoted-printable encoding, use:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; C-c n (C-c C-m n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; mime-include-raw-nonbinary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; Add a raw nonbinary (text) file. You will be prompted for both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;; the filename and the content type of the file (which defaults to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;; text/plain). With prefix arg, you will also be prompted for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;; character set (default is US-ASCII).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; You can also point to external elements: files that will not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; included in the document, but can be accessed by the recipient in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;; some other way (most commonly, via FTP). The following commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;; handle this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;; C-c e (C-c C-m e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;; mime-include-external-anonftp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;; Point to an external file (assumed to be accessable via
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;; anonymous FTP). You will be prompted for the name of the FTP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; site, the remote directory name, and remote filename, the remote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;; file's content type, and a description of the remote file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;; C-c f (C-c C-m f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;; mime-include-external-ftp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;; This is the same as 'C-c e', except that the file will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;; accessed via regular FTP rather than anonymous FTP -- a username
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;; and password will have to be provided by the recipient to gain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;; access to the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;; Note that whenever you are prompted for a content type, Emacs'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; completion feature is active: press TAB for a list of valid types.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;; You can also enter a type not in the completion list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;; If you type in text that belongs in a character set other than the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;; default (US-ASCII), you can use the following function to encode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;; the text and generate appropriate MIME headers:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;; C-c C-r i (C-c C-m C-r i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;; mime-region-to-charset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;;; Encode region in an alternate character set. (MIME only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;; sanctions the use of ISO charsets; thus, the command key for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;; this function is 'i'.) You will be prompted for a character set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;; (minibuffer completion is provided).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; MIME also defines a 'richtext' format; you can encode the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;; region as richtext with:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;; C-c C-r r (C-c C-m C-r r)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;; mime-region-to-richtext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;;; Encode region as richtext. With prefix arg, you will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;; prompted for a character set, else the default (US-ASCII) is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;; used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;; If you regularly use 8-bit characters in your messages, you will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;; probably want all of your plaintext bodyparts automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;; encoded in quoted-printable and labeled as belonging to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;; character set that you're using when a message is sent. To have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;;; this happen, set this variable:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;;; mime-encode-plaintext-on-send (variable, default NIL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;; If T, all text/plain bodyparts in the message will be encoded in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;; quoted-printable and labeled with charset mime-default-charset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;; (by default, US-ASCII) when a message is sent. If NIL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;; text/plain bodyparts will not be touched.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; ---------------------------- ADDITIONAL NOTES ----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;; mime-compose uses Emacs' selective-display feature: only the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;; line of any encoded data file will be displayed, followed by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;; ellipses (indicating that some data is not being shown). See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; variable 'mime-use-selective-display' below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;; If you are running XEmacs/Lucid Emacs, the mail-mode popup menu (attached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;; to the third mouse button) will include mime-compose entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;; If you are running XEmacs/Lucid Emacs or Epoch, highlighting will be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;; to deemphasize the various MIME headers (but emphasize the various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;; MIME content types). You can turn this feature off; see the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;; variable 'mime-use-highlighting'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;; After your message has been `mimified' (by including a MIME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;; element), it is best not to put trailing text outside the final
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; boundary at the end of the file -- such text will not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;; considered to be part of the message by MIME-compliant mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;; readers (although it will still be sent).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;; As you compose a complex MIME message, you may notice useless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;;; bodyparts accumulating: extra text/plain bodyparts, in particular,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;; containing no text. These bodyparts will be stripped from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;; message before the message is sent, so you (and I) won't look like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;; a moron to the recipient.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;; A command that usually isn't necessary, but is provided in case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;; you wish to send a plaintext message with the various MIME headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;; and boundaries, is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;; C-c m (C-c C-m m) mime-mimify-message Mimify a message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;; MIME messages can contain elements and structures not yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;; supported by mime-compose. If you have ideas or code for support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;; that should be provided by mime-compose, please send them to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;; author.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;; ------------------------ WHAT MIME-COMPOSE IS NOT ------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;; mime-compose is not a MIME message handler. It will not interpret
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;; MIME messages, display images, or anything similar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;; mime-compose is not intelligent enough (yet) to construct complex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;; MIME messages (with nested boundaries, parallel message elements,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;;; and so on).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;; mime-compose will not enforce correctness (MIME compliance) on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;;; your messages. mime-compose generates MIME-compliant message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;;; elements, but will sit quietly if you alter them or add your own
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;; incorrect elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;;; In particular, note that the MIME specification demands a blank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;;; line following the Content declarations for a bodypart.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;;; mime-compose will give you that blank line, but will not demand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;;; that you leave it blank; if you don't, your message will not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;;; happy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;;; ------------------------------ WHAT MIME IS ------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;;; MIME defines a format for email messages containing non-plaintext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;;; elements (images, audio, etc.). MIME is detailed in Internet RFC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;;; 1341, by N. Borenstein and N. Freed. You can FTP this RFC from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;;; many archive sites, including uxc.cso.uiuc.edu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;; Few mail readers handle MIME messages, yet. However, most popular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;;; mail readers can be easily patched to feed MIME messages to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;;; program called 'metamail', which can handle MIME messages. You
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;;; can FTP metamail from thumper.bellcore.com in /pub/nsb as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;; mm.tar.Z. Since mime-compose requires the existence of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;;; program 'mmencode' (from the metamail distribution) to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;;; binary and nonbinary files into messages, it is a Good Idea to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;;; have metamail installed on your system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;;; mime-compose|Marc Andreessen|marca@ncsa.uiuc.edu|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;;; MIME-compliant message generation utilities.|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;;; !Date: 1994/03/24 00:00:47 !|!Revision: 1.5 !|~/misc/mime-compose.el.Z|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (provide 'mime-compose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (defvar mime-running-mh-e (featurep 'mh-e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 "Non-nil if running under mh-e.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if (not mime-running-mh-e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (require 'sendmail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;;; ---------------------- User-customizable variables -----------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defvar mime-compose-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 "*Invoked exactly once by first invocation of mime-mimify-message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 before any processing is done.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (defvar mime-use-selective-display t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 "*Flag for using selective-display to hide bodies of MIME enclosures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 If non-NIL, selective-display will be used; if NIL, it will not be used.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (defvar mime-default-charset "US-ASCII"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 "*Default character set for MIME messages elements. According to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 MIME specification, this can be either US-ASCII or ISO-8859-x, where x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 must be between 1 and 9 inclusive.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (defvar mime-encode-plaintext-on-send nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "*Non-NIL if plaintext bodyparts should be encoded in quoted-printable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 and labeled with mime-default-charset when a message is sent; NIL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 otherwise.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (defvar mime-use-highlighting t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 "*Flag to use highlighting for MIME headers and content types in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 Epoch or XEmacs/Lucid Emacs; if non-NIL, highlighting will be used.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (defvar mime-deemphasize-color "grey80"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 "*Color for de-highlighting MIME headers in Epoch or XEmacs/Lucid Emacs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (defvar mime-emphasize-color "yellow"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "*Color for highlighting MIME content types in Epoch or XEmacs/Lucid Emacs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defvar mime-name-included-files t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 "*If non-NIL, use name attribute for included files.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (defvar mime-use-waiting-messages t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 "*If non-NIL, enable waiting messages feature.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (defvar mime-primary-boundary "mysteryboxofun"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 "*Word used as the primary MIME boundary.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (defvar mime-xwd-command "xwd -frame"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 "*Command used to do a window dump under the X Window System.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (defvar mime-encode-base64-command "mmencode"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 "*Command used to encode data in base64 format.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (defvar mime-encode-qp-command "mmencode -q"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 "*Command used to encode data in quoted-printable format.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (defvar mime-babbling-description "talking"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "*Adjective(s) (or gerunds; I never could tell them apart) applying to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 audio snippets.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (defvar mime-sgi-record-program "/usr/sbin/recordaiff"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 "*Full name of SGI audio record program.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (defvar mime-sun-record-program "/usr/demo/SOUND/record"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 "*Full name of Sun audio record program, patched with the context
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 diff found at the end of mime-compose.el.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;;; ---------------------------- Other variables -----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defvar mime-compose-hook-was-run nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "NIL implies we haven't yet run mime-compose-hook.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (defvar mime-valid-include-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 '(("image/gif" 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ("image/jpeg" 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ("application/postscript" 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ("application/andrew-inset" 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ("application/octet-stream" 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ("text/richtext" 6)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ("text/plain" 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ("audio/basic" 8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ("video/mpeg" 9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ("message/rfc822" 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; These aren't ``standard'', but are useful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ("application/x-emacs-lisp" 11)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ("application/x-unix-tar-z" 12)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ("application/x-dvi" 13)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ("image/x-xbm" 14)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ("image/x-xwd" 15)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ("image/x-tiff" 16)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ("audio/x-aiff" 17)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ("text/x-html" 18))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 "A list of valid content types for minibuffer completion.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (defvar mime-valid-charsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 '(("US-ASCII" 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ("ISO-8859-1" 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ("ISO-8859-2" 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ("ISO-8859-3" 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ("ISO-8859-4" 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ("ISO-8859-5" 6)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ("ISO-8859-6" 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ("ISO-8859-7" 8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ("ISO-8859-8" 9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ("ISO-8859-9" 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 "A list of valid charset names for minibuffer completion.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (defvar mime-using-silicon-graphics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (or (eq system-type 'silicon-graphics-unix) (eq system-type 'irix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 "Flag to indicate use of Silicon Graphics platform. If T, Emacs is being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 run on a Silicon Graphics workstation; else it is not.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (defvar mime-running-lemacs (string-match "XEmacs\\|Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 "Non-nil if running XEmacs/Lucid Emacs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (defvar mime-running-epoch (boundp 'epoch::version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "Non-nil if running Epoch.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (if (and mime-running-epoch mime-use-highlighting)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defvar mime-deemphasize-style (make-style))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (set-style-foreground mime-deemphasize-style mime-deemphasize-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (defvar mime-emphasize-style (make-style))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (set-style-foreground mime-emphasize-style mime-emphasize-color)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (if (and mime-running-lemacs mime-use-highlighting)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defvar mime-deemphasize-style (make-face 'mime-deemphasize-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (set-face-foreground mime-deemphasize-style mime-deemphasize-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (defvar mime-emphasize-style (make-face 'mime-emphasize-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (set-face-foreground mime-emphasize-style mime-emphasize-color)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defvar mime-audio-file "/tmp/.fooblatz"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "Filename to store audio snippets recorded on the fly.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defvar mime-audio-tmp-file "/tmp/.fooblatz.aiff"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 "Filename to store audio snippets recorded on the fly.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (defconst mime-waiting-message-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 '("Mail mime-compose bug reports to marca@ncsa.uiuc.edu and pray for help."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 "For the daring: ftp.ncsa.uiuc.edu:/outgoing/marca/mime-compose.el"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "Feature requests? Fervent wishes? Unfulfilled desires? Write code!"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 "mime-compose.el: the Kitchen Sink(tm) of mail composers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 "Q: How many Elisp hackers does it take to change a light bulb?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "A: None -- we glow in the dark."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ".gnol oot yaw rof scamE gnisu neeb ev'uoy ,siht daer nac uoy fI"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "Macs? We don' need no steenkin Macs! We got MIME!"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "All hail MIME. All hail MIME. Yay. Yay. Woo. Woo.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 "List of stupid strings to display while waiting for more to do.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;;; --------------------------- Utility functions ----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (defun mime-primary-boundary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 "Return the current primary boundary. Note that in the current version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 of mime-compose.el, there is no support for secondary boundaries (for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 parallel or alternate bodyparts, etc.). In the future, there may be."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 mime-primary-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (defun mime-hide-region (from to hideflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 "Hides or shows lines from FROM to TO, according to HIDEFLAG:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 If T, region is hidden, else if NIL, region is shown."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (let ((old (if hideflag ?\n ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (new (if hideflag ?\^M ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (modp (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (unwind-protect (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (subst-char-in-region from to old new t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (set-buffer-modified-p modp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (defun mime-maybe-hide-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "Hide the current region if mime-use-selective-display is T."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (if mime-use-selective-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (mime-hide-region start end t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (defun mime-add-description (description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 "Add a description to the current MIME message element."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (interactive "sDescription: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (if (re-search-backward (concat "--" (mime-primary-boundary))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (point-min) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (next-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (insert "Content-Description: " description "\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (defun mime-display-waiting-messages ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 "Display cute messages until input arrives. Shamelessly stolen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 from VM, the Kitchen Sink(tm) of mail readers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (if mime-use-waiting-messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (if (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (let ((lines mime-waiting-message-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 "mime-compose.el !Revision: 1.5 !, by marca@ncsa.uiuc.edu")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (while (and (sit-for 4) lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (message (car lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (setq lines (cdr lines)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if (not (input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; TODO: Don't recurse; iterate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (if (not (input-pending-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (mime-display-waiting-messages)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;;; ------------------------------ Highlighting ------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if mime-use-highlighting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (if mime-running-lemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (defun mime-add-zone (start end style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 "Add a XEmacs/Lucid Emacs extent from START to END with STYLE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (let ((extent (make-extent start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (set-extent-face extent style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (set-extent-property extent 'mime-compose t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (if mime-running-epoch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (defun mime-add-zone (start end style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 "Add an Epoch zone from START to END with STYLE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (let ((zone (add-zone start end style)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (epoch::set-zone-data zone 'mime-compose))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (defun mime-maybe-highlight-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 "Maybe highlight a region of text. Region is from START to END."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (if (and (or mime-running-epoch mime-running-lemacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 mime-use-highlighting)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (mime-add-zone start end mime-deemphasize-style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (if (re-search-forward "Content-Type: " end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (let ((s (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (re-search-forward "[;\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (mime-add-zone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 s (- (match-end 0) 1) mime-emphasize-style)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;;; -------------------------- mime-mimify-message ---------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (defun mime-mimify-message ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 "Add MIME headers to a message. Add an initial informational message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 for mail readers that don't process MIME messages automatically. Add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 an initial area for plaintext. Add a closing boundary at the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 This function is safe to call more than once."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (if (not mime-compose-hook-was-run)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (setq mime-compose-hook-was-run t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (run-hooks 'mime-compose-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (let ((mail-header-separator (if (eq major-mode 'mh-letter-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 "\n\n\\|^-+$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 mail-header-separator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (re-search-forward "^Mime-Version: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (re-search-forward mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (let ((mime-virgin-message (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (next-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (looking-at mail-header-separator))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (if mime-virgin-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (re-search-forward mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (insert "Mime-Version: 1.0\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (insert "Content-Description: A MIME message created by mime-compose.el.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (insert "Content-Type: multipart/mixed; boundary=" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (mime-maybe-highlight-region (save-excursion (next-line -3) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (let ((start (point)) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (insert "> THIS IS A MESSAGE IN 'MIME' FORMAT.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 "> If you are reading this, your mail reader may not support MIME.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 "> Some parts of this message will be readable as plain text.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (mime-maybe-hide-region start (- end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (insert "--" (mime-primary-boundary) "--\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (mime-maybe-highlight-region (save-excursion (next-line -1) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (- (point) 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (re-search-forward mail-header-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ;; THIS HAS TO MATCH the number of lines of text included
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 ;; as a message ``header'' above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (if mime-use-selective-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (next-line 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (next-line 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (insert "--" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (insert "Content-Type: text/plain\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (mime-maybe-highlight-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (save-excursion (next-line -2) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (if mime-virgin-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (backward-delete-char 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (mime-display-waiting-messages)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (defun mime-open-text-bodypart ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 "At current point, just open up a new plaintext bodypart."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (mime-mimify-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (let ((start (point)) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (insert "--" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (insert "Content-Type: text/plain")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (mime-maybe-highlight-region start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 ;;; ---------------------------- file inclusions -----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (defun mime-include-file (filename content-type binary &optional charset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 "Include a file named by FILENAME and with MIME content type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 CONTENT-TYPE. If third argument BINARY is T, then the file is binary;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 else it's text. Optional fourth arg CHARSET names character set for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 data. Data will be encoded in base64 or quoted-printable format as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 appropriate."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (mime-mimify-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (insert "--" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (insert "Content-Type: " content-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (if charset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (insert "; charset=" charset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (if (and mime-name-included-files (not (string= filename mime-audio-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (insert "; name=\"" (file-name-nondirectory filename) "\""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (if (not (string= filename mime-audio-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (insert "Content-Description: " filename "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (if binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (insert "Content-Transfer-Encoding: base64\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (insert "Content-Transfer-Encoding: quoted-printable\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (mime-maybe-highlight-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (save-excursion (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (concat "--" (mime-primary-boundary))) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (let ((start (point)) end (seldisp selective-display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (next-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (insert-file filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq end (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (setq selective-display nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (if binary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (shell-command-on-region start end mime-encode-base64-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (shell-command-on-region start end mime-encode-qp-command t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (setq selective-display seldisp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (mime-maybe-hide-region start (- end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (insert "--" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (insert "Content-Type: text/plain\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (mime-maybe-highlight-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (save-excursion (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (concat "--" (mime-primary-boundary))) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (next-line -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (defun mime-include-binary-file (filename content-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 "Include a binary file named by FILENAME at point in a MIME message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 CONTENT-TYPE names MIME content type of file. Data will be encoded in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 base64 format."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (mime-include-file filename content-type t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (defun mime-include-nonbinary-file (filename content-type &optional charset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 "Include a nonbinary file named by FILENAME at point in a MIME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 message. CONTENT-TYPE names MIME content type of file; optional third
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 arg CHARSET names MIME character set. Data will be encoded in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 quoted-printable format."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (mime-include-file filename content-type nil charset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;;; -------------------------- external references ---------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (defun mime-include-external (site directory name content-type description
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 access-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 "Include an external pointer in a MIME message. Args are SITE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 DIRECTORY, NAME, CONTENT-TYPE, DESCRIPTION, and ACCESS-TYPE; these are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 all strings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (mime-mimify-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (insert "--" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (insert "Content-Type: message/external-body;\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (insert "\taccess-type=\"" access-type "\";\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (insert "\tsite=\"" site "\";\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (insert "\tdirectory=\"" directory "\";\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (insert "\tname=\"" name "\"\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (insert "Content-Description: " description "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (insert "Content-Type: " content-type "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (mime-maybe-highlight-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (save-excursion (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (concat "--" (mime-primary-boundary))) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (insert "--" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (insert "Content-Type: text/plain\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (mime-maybe-highlight-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (save-excursion (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (concat "--" (mime-primary-boundary))) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (defun mime-include-external-anonftp (site directory name description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 "Include an external pointer (anonymous FTP) in a MIME message. Args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 are SITE, DIRECTORY, NAME, and DESCRIPTION; these are all strings, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 if interactive, will be prompted for."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 "sFTP site: \nsRemote directory name: \nsRemote filename: \nsDescription: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (let ((content-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (completing-read "Content type: " mime-valid-include-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 nil nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;; Unadvertised default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (if (string= content-type "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (setq content-type "application/octet-stream"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (mime-include-external site directory name content-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 description "anon-ftp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (defun mime-include-external-ftp (site directory name description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 "Include an external pointer (regular FTP) in a MIME message. Args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 are SITE, DIRECTORY, NAME, and DESCRIPTION; these are all strings, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 if interactive, will be prompted for."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 "sFTP site: \nsRemote directory name: \nsRemote filename: \nsDescription: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (let ((content-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (completing-read "Content type: " mime-valid-include-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 nil nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 ;; Unadvertised default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (if (string= content-type "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (setq content-type "application/octet-stream"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (mime-include-external site directory name content-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 description "ftp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 ;;; ------------------------------ window dumps ------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (defun mime-include-xwd-dump ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 "Run program named by 'mime-xwd-command' and include the results in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 a MIME message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (mime-mimify-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (insert "--" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (insert "Content-Type: image/x-xwd\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (insert "Content-Description: Window dump from " (system-name) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (insert "Content-Transfer-Encoding: base64\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (mime-maybe-highlight-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (save-excursion (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (concat "--" (mime-primary-boundary))) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (let ((start (point)) end (seldisp selective-display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (next-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (message "When crosshair cursor appears, click on window...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (call-process "/bin/sh" nil t nil "-c" mime-xwd-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (sit-for 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (setq selective-display nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (shell-command-on-region start end mime-encode-base64-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (setq selective-display seldisp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (mime-maybe-hide-region start (- end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (insert "--" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (insert "Content-Type: text/plain\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (mime-maybe-highlight-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (save-excursion (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (concat "--" (mime-primary-boundary))) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (next-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 ;;; ----------------------------- audio snippets -----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (defun mime-sgi-grab-audio-snippet ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 "Grab an audio snippet into file named in 'mime-audio-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 This routine works on SGI Indigo's and 4D/35's."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (let (audio-process done-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (setq audio-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (start-process "snippet" "snippet"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 mime-sgi-record-program "-n" "1" "-s" "8" "-r" "8000"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 mime-audio-tmp-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ;; Quick hack to make Emacs sit until recording is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (setq done-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (y-or-n-p "Press y when done recording (n to abort): "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (interrupt-process "snippet")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 ;; Wait until recordaiff has written data to disk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (while (eq (process-status "snippet") 'run)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (message "Waiting...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (sleep-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (message "Done waiting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ;; Kill off recordaiff and our buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (delete-process "snippet")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (kill-buffer "snippet")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 ;; Remove the old mulaw file and do the conversion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (call-process "/bin/rm" nil nil nil "-f" mime-audio-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (if done-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (call-process "/usr/sbin/sfconvert" nil nil nil mime-audio-tmp-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 mime-audio-file "-o" "mulaw"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (call-process "/bin/rm" nil nil nil "-f" mime-audio-tmp-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 ;; Return done flag. If nil, mime-include-audio-snippet should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 ;; clean up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 done-flag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (defun mime-sun-grab-audio-snippet ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 "Grab an audio snippet into file named in 'mime-audio-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 This is the Sun version. I don't know how well it works. It also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 requires a patched version of /usr/demo/SOUND/record.c; see the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 context diff at the end of mime-compose.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 Courtesy Christopher Davis <ckd@eff.org>."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (let (audio-process done-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (setq audio-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (start-process "snippet" "snippet"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 mime-sun-record-program "-m" mime-audio-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 ;; Quick hack to make Emacs sit until recording is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (setq done-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (y-or-n-p "Press y when done recording (n to abort): "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (interrupt-process "snippet")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 ;; Wait until the record process is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (while (eq (process-status "snippet") 'run)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (message "Waiting...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (sleep-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (message "Done waiting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 ;; Kill off the record process and our buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (delete-process "snippet")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (kill-buffer "snippet")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ;; Return done flag. If nil, mime-include-audio-snippet should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ;; clean up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 done-flag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (defun mime-include-audio-snippet ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 "Record a snippet of audio in a MIME message. This should work on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 both Silicon Graphics and Sun platforms. Code contributions for other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 platforms are welcome."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (let ((mime-grab-audio-snippet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (if mime-using-silicon-graphics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 'mime-sgi-grab-audio-snippet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 'mime-sun-grab-audio-snippet)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (if (eq (funcall mime-grab-audio-snippet) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (mime-include-binary-file mime-audio-file "audio/basic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (next-line -4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (mime-add-description
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (concat (user-full-name) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 mime-babbling-description "."))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 ;;; ------------------------- Basic include commands -------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (defun mime-include-gif (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 "Include a GIF file named by FILENAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (interactive "fGIF image filename: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (mime-include-binary-file filename "image/gif")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (defun mime-include-jpeg (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 "Include a JPEG file named by FILENAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (interactive "fJPEG image filename: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (mime-include-binary-file filename "image/jpeg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (defun mime-include-audio (filename &optional prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 "Include an audio file named by FILENAME. Note that to match the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 MIME specification for audio/basic, this should be an 8-bit mulaw file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 With prefix arg, use AIFF format (unofficial MIME subtype audio/x-aiff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 instead of audio/basic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (interactive "fAudio filename: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (if prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (mime-include-binary-file filename "audio/x-aiff")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (mime-include-binary-file filename "audio/basic"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (defun mime-include-mpeg (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 "Include a MPEG file named by FILENAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (interactive "fMPEG animation filename: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (mime-include-binary-file filename "video/mpeg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (defun mime-include-postscript (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 "Include a PostScript file named by FILENAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (interactive "fPostScript filename: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (mime-include-nonbinary-file filename "application/postscript")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (defun mime-include-raw-binary (filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 "Include a raw binary file named by FILENAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (interactive "fRaw binary filename: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (let ((content-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (completing-read "Content type (RET for default): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 mime-valid-include-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 nil nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (if (string= content-type "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (setq content-type "application/octet-stream"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (mime-include-binary-file filename content-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (defun mime-include-raw-nonbinary (filename &optional prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 "Include a raw nonbinary file named by FILENAME. With prefix arg,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 prompt for character set."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (interactive "fRaw nonbinary filename: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (let ((charset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (if prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (completing-read "Character set: " mime-valid-charsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 nil nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 mime-default-charset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (content-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (completing-read "Content type (RET for default): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 mime-valid-include-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 nil nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (if (string= content-type "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (setq content-type "text/plain"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (if (string= charset "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (setq charset "asdfasdfdfsdafs"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (mime-include-nonbinary-file filename content-type charset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 ;;; ---------------------------- Region commands -----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (defun mime-encode-region (start end content-type charset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 "Encode a region specified by START and END. CONTENT-TYPE and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 CHARSET name the content type and character set of the data in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 ;; Start by encoding the region in quoted-printable. This will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 ;; move end, but not start.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (let ((seldisp selective-display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (setq selective-display nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (shell-command-on-region start end mime-encode-qp-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (setq selective-display seldisp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 ;; Now pick up the new end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 ;; Pop up to start and insert the header; this will also change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;; end, but with save-excursion we'll end up at the new end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (insert "--" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (insert "Content-Type: " content-type "; charset=" charset "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (insert "Content-Transfer-Encoding: quoted-printable\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (mime-maybe-highlight-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (save-excursion (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (concat "--" (mime-primary-boundary))) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ;; Pick up the new end again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ;; Insert the trailing boundary and the new text/plain header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (insert "--" (mime-primary-boundary) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (insert "Content-Type: text/plain\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (mime-maybe-highlight-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (save-excursion (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (concat "--" (mime-primary-boundary))) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (- (point) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;; Last but not least, add MIME headers if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (mime-mimify-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (defun mime-region-to-richtext (start end &optional prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 "Convert the current region to MIME richtext. MIME headers are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 added if necessary; a MIME boundary is added at the start of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 region to indicate richtext; the conversion (see below) is done; a new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 boundary is added for more text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 With prefix arg, prompt for character set; else use value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 mime-default-charset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 Currently no textual conversion is done, other than encoding in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 quoted-printable format. Instead, you use directives such as <bold>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 and </bold> in the text, as described in the MIME RFC. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 alternative would be to parse tilde sequences as is done in the mailto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 program. Let me know if you think the latter would be more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 appropriate for mime-compose.el."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (interactive "r\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (let ((charset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (if (not prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 mime-default-charset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (completing-read "Character set: " mime-valid-charsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 nil nil nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 ;; Unadvertised default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (if (string= charset "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (setq charset mime-default-charset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (mime-encode-region start end "text/richtext"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 charset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (defun mime-region-to-charset (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 "Convert the current region to plaintext in a non-default character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 set. You are prompted for a character set, and the text in the region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 is encoded in quoted-printable format and identified as being in that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 character set."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (let ((charset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (completing-read "Character set: " mime-valid-charsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 nil nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 ;; Unadvertised default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (if (string= charset "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (setq charset mime-default-charset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (mime-encode-region start end "text/plain" charset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (mime-display-waiting-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 ;;; -------------------------------- Keymaps ---------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 ;;; Add functions to MH letter mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (if mime-running-mh-e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ;; Running mh-e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (if (or (not (boundp 'mh-letter-mode-mime-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (not mh-letter-mode-mime-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (setq mh-letter-mode-mime-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (define-key mh-letter-mode-map "\C-c\C-m" mh-letter-mode-mime-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (define-key mh-letter-mode-mime-map "m" 'mime-mimify-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (define-key mh-letter-mode-mime-map "g" 'mime-include-gif)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (define-key mh-letter-mode-mime-map "j" 'mime-include-jpeg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (define-key mh-letter-mode-mime-map "a" 'mime-include-audio)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (define-key mh-letter-mode-mime-map "v" 'mime-include-mpeg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (define-key mh-letter-mode-mime-map "p" 'mime-include-postscript)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (define-key mh-letter-mode-mime-map "r" 'mime-include-raw-binary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (define-key mh-letter-mode-mime-map "n" 'mime-include-raw-nonbinary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (define-key mh-letter-mode-mime-map "x" 'mime-include-xwd-dump)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (define-key mh-letter-mode-mime-map "e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 'mime-include-external-anonftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (define-key mh-letter-mode-mime-map "f"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 'mime-include-external-ftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (define-key mh-letter-mode-mime-map "s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 'mime-include-audio-snippet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ;; Functions that operate on regions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (defvar mime-region-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (define-key mh-letter-mode-mime-map "\C-r" mime-region-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (define-key mime-region-map "r" 'mime-region-to-richtext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (define-key mime-region-map "i" 'mime-region-to-charset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 ;; Not running mh-e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (define-key mail-mode-map "\C-cm" 'mime-mimify-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (define-key mail-mode-map "\C-cg" 'mime-include-gif)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (define-key mail-mode-map "\C-cj" 'mime-include-jpeg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (define-key mail-mode-map "\C-ca" 'mime-include-audio)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (define-key mail-mode-map "\C-cp" 'mime-include-postscript)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (define-key mail-mode-map "\C-cr" 'mime-include-raw-binary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (define-key mail-mode-map "\C-cn" 'mime-include-raw-nonbinary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (define-key mail-mode-map "\C-cx" 'mime-include-xwd-dump)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (define-key mail-mode-map "\C-ce" 'mime-include-external-anonftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (define-key mail-mode-map "\C-cf" 'mime-include-external-ftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (define-key mail-mode-map "\C-cs" 'mime-include-audio-snippet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (define-key mail-mode-map "\C-cv" 'mime-include-mpeg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 ;; Functions that operate on regions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (defvar mime-region-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (define-key mail-mode-map "\C-c\C-r" mime-region-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (define-key mime-region-map "r" 'mime-region-to-richtext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (define-key mime-region-map "i" 'mime-region-to-charset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 ;;; -------------------------------- Menubar ---------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (defvar mime-compose-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 "MIME Inclusions:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 ["Include GIF File" mime-include-gif t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 ["Include JPEG File" mime-include-jpeg t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 ["Include MPEG File" mime-include-mpeg t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 ["Include Audio File" mime-include-audio t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 ["Include PostScript File" mime-include-postscript t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ["Include XWD Dump" mime-include-xwd-dump t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 ["Include Audio Snippet" mime-include-audio-snippet t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 ["Include Raw Binary File" mime-include-raw-binary t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 ["Include Raw Nonbinary File" mime-include-raw-nonbinary t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 ["Include External AnonFTP" mime-include-external-anonftp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 ["Include External FTP" mime-include-external-ftp t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 "Popup menu for MIME Compose.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 ;; Attach menu to mail-mode-menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (and mime-running-lemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (setq mail-menubar-menu (append mail-menubar-menu '("---") mime-compose-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (setq mail-popup-menu (append mail-popup-menu '("---") mime-compose-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 ;; Arrange to attach to VM's mail mode menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (defun mime-compose-attach-to-mode-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (if (boundp 'vm-menu-mail-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (setq vm-menu-mail-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (nconc vm-menu-mail-menu (list "----") mime-compose-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (remove-hook 'vm-mail-mode-hook 'mime-compose-attach-to-mode-menu))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (add-hook 'vm-mail-mode-hook 'mime-compose-attach-to-mode-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 ;;; ----------------------------- New mail-send ------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 ;; If we're not running XEmacs, pop in a new mail-send routine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (if (not mime-running-lemacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (defun mail-send ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 "Send the message in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 If mail-interactive is non-nil, wait for success indication
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 or error messages, and inform user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 Otherwise any failure is reported in a message back to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 the user from the mailer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (message "Sending...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (run-hooks 'mail-send-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (funcall send-mail-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (delete-auto-save-file-if-necessary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (message "Sending...done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 ;;; --------------------------------- Hooks ----------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 ;; Author: Daniel LaLiberte (liberte@cs.uiuc.edu).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (defun mime-postpend-unique-hook (hook-var hook-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 "Postpend HOOK-VAR with HOOK-FUNCTION, if it is not already an element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 hook-var's value may be a single function or a list of functions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (if (boundp hook-var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (let ((value (symbol-value hook-var)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (if (and (listp value) (not (eq (car value) 'lambda)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (and (not (memq hook-function value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (set hook-var (append value (list hook-function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (and (not (eq hook-function value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (set hook-var (append value (list hook-function))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (set hook-var (list hook-function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (defun mime-unfrob-selective-display ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 "Turn off selective display throughout this buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (if mime-use-selective-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (message "Unfrobbing selective-display...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (mime-hide-region (point-min) (point-max) nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (defun mime-strip-useless-bodyparts ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 "Strip useless (empty) bodyparts out of a message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (concat "^--" (mime-primary-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 "\nContent-Type: text.*[\n]*--" (mime-primary-boundary))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (replace-match (concat "--" (mime-primary-boundary)) t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 ;; Go all the way back up to start over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (goto-char (point-min)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (defun mime-encode-region-qp (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 "Encode a region specified by START and END in quoted-printable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 format. Return the new endpoint. Do not use save-excursion."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 ;; Start by encoding the region in quoted-printable. This will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 ;; move end, but not start.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (let ((seldisp selective-display))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (setq selective-display nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (shell-command-on-region start end mime-encode-qp-command t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (setq selective-display seldisp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (defun mime-encode-plaintext ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 "Encode all plaintext bodyparts in the message in quoted-printable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 and set the charset to mime-default-charset."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 ;; We're looking for text/plain bodyparts with no extra fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (concat "^--" (mime-primary-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 "\nContent-Type: text/plain\n") (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (let* ((head (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (start (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 ;; Assume there's a closing boundary; go find it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (end (save-excursion (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (concat "^--" (mime-primary-boundary)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (- (match-beginning 0) 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 ;; Maybe there's already a Content-Transfer-Encoding. If so,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 ;; never mind.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (or (re-search-forward "^Content-Transfer-Encoding: " end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (let ((new-end (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (mime-encode-region-qp start end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (goto-char head)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (let ((s (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (insert "; charset=" mime-default-charset "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (insert "Content-Transfer-Encoding: quoted-printable")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (mime-maybe-highlight-region s (point))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (defun mime-send-hook-function ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 "Function to be called from mail-send-hook. Unfrob selective
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 display if active, strip out empty (useless) bodyparts, and optionally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 encode plaintext bodyparts in quoted-printable with a given charset."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (mime-unfrob-selective-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (mime-strip-useless-bodyparts)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (and mime-encode-plaintext-on-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (mime-encode-plaintext)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 ;; Before the message is sent, remove the selective display crap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (if mime-running-mh-e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (mime-postpend-unique-hook 'mh-before-send-letter-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 'mime-send-hook-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (mime-postpend-unique-hook 'mail-send-hook 'mime-send-hook-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (defun mime-setup-hook-function ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (if mime-use-selective-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (setq selective-display t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;; During mail setup, activate selective-display if necessary. We use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 ;; mail-mode-hook rather than mail-setup-hook because if a message is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 ;; being composed and C-x m gets hit again, mail-mode will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 ;; reentered, causing selective-display to revert to nil and possibly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 ;; screwing up the display bigtime unless mail-mode-hook knows what to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ;; do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (if mime-running-mh-e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (mime-postpend-unique-hook 'mh-letter-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 'mime-setup-hook-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (mime-postpend-unique-hook 'mail-mode-hook 'mime-setup-hook-function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 ;;; ------------------------- END OF MIME-COMPOSE.EL -------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 ;;; ---------------------- PATCH FOR SUN RECORD PROGRAM ----------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 ;;; This patch must be applied to record.c as found in the Sun demo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ;;; directories in order to enable on-the-fly audio recording in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 ;;; mime-compose.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 ;; *** record.c.orig Wed Oct 23 13:56:38 1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 ;; --- record.c Sun Dec 6 22:50:06 1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 ;; ***************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 ;; *** 2,7 ****
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 ;; --- 2,9 ----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ;; static char sccsid[] = "@(#)record.c 1.2 90/01/02 Copyr 1989 Sun Micro";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ;; #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 ;; /* Copyright (c) 1989 by Sun Microsystems, Inc. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 ;; + /* 921206: modifications to not output audio header (ckd@eff.org) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 ;; + /* yes, I know it's ugly code... sorry... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;; #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 ;; #include <errno.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 ;; ***************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 ;; *** 30,36 ****
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 ;; /* Local variables */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 ;; char *prog;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 ;; char prog_desc[] = "Record an audio file";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 ;; ! char prog_opts[] = "aft:v:d:i:?"; /* getopt() flags */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 ;; char *Stdout = "stdout";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 ;; --- 32,38 ----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 ;; /* Local variables */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 ;; char *prog;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 ;; char prog_desc[] = "Record an audio file";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 ;; ! char prog_opts[] = "aft:v:d:i:?m"; /* getopt() flags */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 ;; char *Stdout = "stdout";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 ;; ***************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 ;; *** 69,76 ****
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 ;; usage()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 ;; {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 ;; Error(stderr, "%s -- usage:\n\t%s ", prog_desc, prog);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 ;; ! Error(stderr, "\t[-a] [-v #] [-t #] [-i msg] [-d dev] [file]\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 ;; Error(stderr, "where:\n\t-a\tAppend to output file\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 ;; Error(stderr, "\t-f\tIgnore sample rate differences on append\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 ;; Error(stderr, "\t-v #\tSet record volume (0 - %d)\n", MAX_GAIN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 ;; Error(stderr, "\t-t #\tSpecify record time (hh:mm:ss.dd)\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 ;; --- 71,79 ----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 ;; usage()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 ;; {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 ;; Error(stderr, "%s -- usage:\n\t%s ", prog_desc, prog);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ;; ! Error(stderr, "\t[-a] [-m] [-v #] [-t #] [-i msg] [-d dev] [file]\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 ;; Error(stderr, "where:\n\t-a\tAppend to output file\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 ;; + Error(stderr, "\t-m\tDon't add audio header (for MIME)\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 ;; Error(stderr, "\t-f\tIgnore sample rate differences on append\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 ;; Error(stderr, "\t-v #\tSet record volume (0 - %d)\n", MAX_GAIN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 ;; Error(stderr, "\t-t #\tSpecify record time (hh:mm:ss.dd)\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 ;; ***************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 ;; *** 112,117 ****
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 ;; --- 115,121 ----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 ;; int cnt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 ;; int err;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 ;; int ofd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 ;; + int addheader = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 ;; double vol;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 ;; struct stat st;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 ;; struct sigvec vec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 ;; ***************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 ;; *** 150,155 ****
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 ;; --- 154,162 ----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 ;; Info = optarg; /* set information string */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 ;; Ilen = strlen(Info);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ;; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 ;; + case 'm':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 ;; + addheader = 0; /* no header (for MIME) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 ;; + break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 ;; case '?':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 ;; usage();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 ;; /*NOTREACHED*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 ;; ***************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 ;; *** 288,293 ****
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 ;; --- 295,301 ----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;; exit(1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 ;; } else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 ;; + if (addheader) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 ;; if (audio_write_filehdr(ofd, &Dev_hdr, Info, Ilen) !=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 ;; AUDIO_SUCCESS) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 ;; Error(stderr, "%s: error writing header for \n", prog);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 ;; ***************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 ;; *** 294,299 ****
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 ;; --- 302,308 ----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 ;; perror(Ofile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 ;; exit(1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 ;; + }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 ;; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 ;; /* If -v flag, set the record volume now */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 ;;; ------------------------------ END OF PATCH ------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283