* basic.texi (Continuation Lines, Inserting Text): Mention
[bpt/emacs.git] / lisp / mh-e / mh-mime.el
CommitLineData
bdcfe844 1;;; mh-mime.el --- MH-E support for composing MIME messages
c26cf6c8 2
e495eaec 3;; Copyright (C) 1993, 1995,
af435184 4;; 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
a1b4049d
BW
5
6;; Author: Bill Wohler <wohler@newt.com>
7;; Maintainer: Bill Wohler <wohler@newt.com>
8;; Keywords: mail
9;; See: mh-e.el
c26cf6c8 10
60370d40 11;; This file is part of GNU Emacs.
c26cf6c8 12
9b7bc076 13;; GNU Emacs is free software; you can redistribute it and/or modify
c26cf6c8
RS
14;; it under the terms of the GNU General Public License as published by
15;; the Free Software Foundation; either version 2, or (at your option)
16;; any later version.
17
9b7bc076 18;; GNU Emacs is distributed in the hope that it will be useful,
c26cf6c8
RS
19;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;; GNU General Public License for more details.
22
23;; You should have received a copy of the GNU General Public License
b578f267 24;; along with GNU Emacs; see the file COPYING. If not, write to the
3a35cf56
LK
25;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26;; Boston, MA 02110-1301, USA.
c26cf6c8
RS
27
28;;; Commentary:
29
bdcfe844 30;; Internal support for MH-E package.
0c47b17c
BW
31;; Support for generating MH-style directives for mhn or mhbuild as well as
32;; MML (MIME Meta Language) tags. MH-style directives are supported by MH 6.8
33;; or later.
c26cf6c8 34
847b8219
KH
35;;; Change Log:
36
c26cf6c8
RS
37;;; Code:
38
30f24016 39;;(message "> mh-mime")
f0d73c14 40(eval-when-compile (require 'mh-acros))
a66894d8 41(mh-require-cl)
7094eefe 42
bdcfe844 43(require 'gnus-util)
9c2cf222 44(require 'mh-buffers)
7094eefe 45(require 'mh-comp)
a66894d8 46(require 'mh-gnus)
30f24016 47;;(message "< mh-mime")
bdcfe844 48
bdcfe844 49(autoload 'article-emphasize "gnus-art")
0c47b17c 50(autoload 'gnus-article-goto-header "gnus-art")
bdcfe844 51(autoload 'gnus-eval-format "gnus-spec")
0c47b17c 52(autoload 'gnus-get-buffer-create "gnus")
bdcfe844 53(autoload 'message-options-set-recipient "message")
1bea9ec4 54(autoload 'mm-uu-dissect "mm-uu")
0c47b17c 55(autoload 'mml-unsecure-message "mml-sec")
924df208 56(autoload 'rfc2047-decode-region "rfc2047")
0c47b17c 57(autoload 'widget-convert-button "wid-edit")
bdcfe844 58
c3d9274a 59;;;###mh-autoload
bdcfe844 60(defun mh-compose-insertion (&optional inline)
0c47b17c 61 "Add tag to include a file such as an image or sound.
0c47b17c 62
2dcf34f9
BW
63You are prompted for the filename containing the object, the
64media type if it cannot be determined automatically, and a
65content description. If you're using MH-style directives, you
66will also be prompted for additional attributes.
67
68The option `mh-compose-insertion' controls what type of tags are
69inserted. Optional argument INLINE means make it an inline
70attachment."
bdcfe844 71 (interactive "P")
0c47b17c 72 (if (equal mh-compose-insertion 'mml)
bdcfe844
BW
73 (if inline
74 (mh-mml-attach-file "inline")
75 (mh-mml-attach-file))
0c47b17c 76 (call-interactively 'mh-mh-attach-file)))
bdcfe844 77
c3d9274a 78;;;###mh-autoload
c2134792 79(defun mh-compose-forward (&optional description folder range)
0c47b17c 80 "Add tag to forward a message.
2dcf34f9
BW
81
82You are prompted for a content DESCRIPTION, the name of the
c2134792
BW
83FOLDER in which the messages to forward are located, and a RANGE
84of messages, which defaults to the current message in that
85folder. Check the documentation of `mh-interactive-range' to see
86how RANGE is read in interactive use.
0c47b17c
BW
87
88The option `mh-compose-insertion' controls what type of tags are inserted."
c2134792
BW
89 (interactive
90 (let* ((description
91 (mml-minibuffer-read-description))
92 (folder
93 (mh-prompt-for-folder "Message from"
94 mh-sent-from-folder nil))
95 (default
96 (if (and (equal folder mh-sent-from-folder)
97 (numberp mh-sent-from-msg))
98 mh-sent-from-msg
99 (nth 0 (mh-translate-range folder "cur"))))
100 (range
101 (mh-read-range "Forward" folder
102 (or (and default
103 (number-to-string default))
104 t)
105 t t)))
106 (list description folder range)))
107 (let ((messages (mapconcat 'identity (mh-list-to-string range) " ")))
108 (dolist (message (mh-translate-range folder messages))
0c47b17c 109 (if (equal mh-compose-insertion 'mml)
23847cd6
BW
110 (mh-mml-forward-message description folder (format "%s" message))
111 (mh-mh-forward-message description folder (format "%s" message))))))
c26cf6c8 112
c26cf6c8
RS
113;; To do:
114;; paragraph code should not fill # lines if MIME enabled.
0c47b17c
BW
115;; implement mh-auto-mh-to-mime (if non-nil, \\[mh-send-letter]
116;; invokes mh-mh-to-mime automatically before sending.)
117;; actually, instead of mh-auto-mh-to-mime,
c26cf6c8
RS
118;; should read automhnproc from profile
119;; MIME option to mh-forward
120;; command to move to content-description insertion point
121
0c47b17c
BW
122(defvar mh-mh-to-mime-args nil
123 "Extra arguments for \\[mh-mh-to-mime] to pass to the \"mhbuild\" command.
2dcf34f9
BW
124The arguments are passed to \"mhbuild\" if \\[mh-mh-to-mime] is
125given a prefix argument. Normally default arguments to
126\"mhbuild\" are specified in the MH profile.")
847b8219 127
bdcfe844
BW
128(defvar mh-media-type-regexp
129 (concat (regexp-opt '("text" "image" "audio" "video" "application"
130 "multipart" "message") t)
131 "/[-.+a-zA-Z0-9]+")
132 "Regexp matching valid media types used in MIME attachment compositions.")
133
7094eefe 134(defvar mh-have-file-command 'undefined
c2134792 135 "Cached value of function `mh-have-file-command'.
7094eefe
BW
136Do not reference this variable directly as it might not have been
137initialized. Always use the command `mh-have-file-command'.")
847b8219 138
f0d73c14 139;;;###mh-autoload
a1b4049d
BW
140(defun mh-have-file-command ()
141 "Return t if 'file' command is on the system.
142'file -i' is used to get MIME type of composition insertion."
7094eefe 143 (when (eq mh-have-file-command 'undefined)
a1b4049d
BW
144 (setq mh-have-file-command
145 (and (fboundp 'executable-find)
146 (executable-find "file") ; file command exists
147 ; and accepts -i and -b args.
148 (zerop (call-process "file" nil nil nil "-i" "-b"
149 (expand-file-name "inc" mh-progs))))))
150 mh-have-file-command)
151
bdcfe844
BW
152(defvar mh-file-mime-type-substitutions
153 '(("application/msword" "\.xls" "application/ms-excel")
f0d73c14
BW
154 ("application/msword" "\.ppt" "application/ms-powerpoint")
155 ("text/plain" "\.vcf" "text/x-vcard"))
bdcfe844
BW
156 "Substitutions to make for Content-Type returned from file command.
157The first element is the Content-Type returned by the file command.
2dcf34f9
BW
158The second element is a regexp matching the file name, usually the
159extension.
bdcfe844
BW
160The third element is the Content-Type to replace with.")
161
162(defun mh-file-mime-type-substitute (content-type filename)
163 "Return possibly changed CONTENT-TYPE on the FILENAME.
2dcf34f9
BW
164Substitutions are made from the `mh-file-mime-type-substitutions'
165variable."
bdcfe844
BW
166 (let ((subst mh-file-mime-type-substitutions)
167 (type) (match) (answer content-type)
168 (case-fold-search t))
169 (while subst
170 (setq type (car (car subst))
171 match (elt (car subst) 1))
172 (if (and (string-equal content-type type)
173 (string-match match filename))
174 (setq answer (elt (car subst) 2)
175 subst nil)
176 (setq subst (cdr subst))))
177 answer))
178
f0d73c14 179;;;###mh-autoload
a1b4049d
BW
180(defun mh-file-mime-type (filename)
181 "Return MIME type of FILENAME from file command.
182Returns nil if file command not on system."
183 (cond
184 ((not (mh-have-file-command))
7094eefe 185 nil) ;no file command, exit now
abb73857
BW
186 ((not (and (file-exists-p filename)
187 (file-readable-p filename)))
7094eefe 188 nil) ;no file or not readable, ditto
a1b4049d
BW
189 (t
190 (save-excursion
191 (let ((tmp-buffer (get-buffer-create mh-temp-buffer)))
192 (set-buffer tmp-buffer)
193 (unwind-protect
194 (progn
195 (call-process "file" nil '(t nil) nil "-b" "-i"
196 (expand-file-name filename))
197 (goto-char (point-min))
198 (if (not (re-search-forward mh-media-type-regexp nil t))
199 nil
bdcfe844 200 (mh-file-mime-type-substitute (match-string 0) filename)))
a1b4049d
BW
201 (kill-buffer tmp-buffer)))))))
202
0c47b17c
BW
203(defun mh-minibuffer-read-type (filename &optional default)
204 "Return the content type associated with the given FILENAME.
2dcf34f9
BW
205If the \"file\" command exists and recognizes the given file,
206then its value is returned\; otherwise, the user is prompted for
207a type (see `mailcap-mime-types' and for Emacs 20,
208`mh-mime-content-types').
0c47b17c
BW
209Optional argument DEFAULT is returned if a type isn't entered."
210 (mailcap-parse-mimetypes)
211 (let* ((default (or default
23847cd6
BW
212 (mm-default-file-encoding filename)
213 "application/octet-stream"))
7094eefe 214 (probed-type (mh-file-mime-type filename))
23847cd6 215 (type (or (and (not (equal probed-type "application/octet-stream"))
7094eefe 216 probed-type)
0c47b17c
BW
217 (completing-read
218 (format "Content type (default %s): " default)
7094eefe 219 (mapcar 'list (mailcap-mime-types))))))
0c47b17c
BW
220 (if (not (equal type ""))
221 type
222 default)))
a1b4049d 223
f0d73c14
BW
224;; RFC 2045 - Multipurpose Internet Mail Extensions (MIME) Part One:
225;; Format of Internet Message Bodies.
226;; RFC 2046 - Multipurpose Internet Mail Extensions (MIME) Part Two:
227;; Media Types.
228;; RFC 2049 - Multipurpose Internet Mail Extensions (MIME) Part Five:
229;; Conformance Criteria and Examples.
230;; RFC 2017 - Definition of the URL MIME External-Body Access-Type
231;; RFC 1738 - Uniform Resource Locators (URL)
232(defvar mh-access-types
233 '(("anon-ftp") ; RFC2046 Anonymous File Transfer Protocol
234 ("file") ; RFC1738 Host-specific file names
235 ("ftp") ; RFC2046 File Transfer Protocol
236 ("gopher") ; RFC1738 The Gopher Protocol
237 ("http") ; RFC1738 Hypertext Transfer Protocol
238 ("local-file") ; RFC2046 Local file access
239 ("mail-server") ; RFC2046 mail-server Electronic mail address
240 ("mailto") ; RFC1738 Electronic mail address
241 ("news") ; RFC1738 Usenet news
242 ("nntp") ; RFC1738 Usenet news using NNTP access
243 ("propspero") ; RFC1738 Prospero Directory Service
244 ("telnet") ; RFC1738 Telnet
245 ("tftp") ; RFC2046 Trivial File Transfer Protocol
246 ("url") ; RFC2017 URL scheme MIME access-type Protocol
247 ("wais")) ; RFC1738 Wide Area Information Servers
88a34f43 248 "Valid MIME access-type values.")
f0d73c14 249
c3d9274a 250;;;###mh-autoload
0c47b17c
BW
251(defun mh-mh-attach-file (filename type description attributes)
252 "Add a tag to insert a MIME message part from a file.
2dcf34f9
BW
253You are prompted for the FILENAME containing the object, the
254media TYPE if it cannot be determined automatically, and a
255content DESCRIPTION. In addition, you are also prompted for
256additional ATTRIBUTES.
0c47b17c
BW
257
258See also \\[mh-mh-to-mime]."
259 (interactive (let ((filename (mml-minibuffer-read-file "Attach file: ")))
c3d9274a
BW
260 (list
261 filename
0c47b17c
BW
262 (mh-minibuffer-read-type filename)
263 (mml-minibuffer-read-description)
264 (read-string "Attributes: "
c3d9274a
BW
265 (concat "name=\""
266 (file-name-nondirectory filename)
267 "\"")))))
0c47b17c 268 (mh-mh-compose-type filename type description attributes))
c26cf6c8 269
0c47b17c 270(defun mh-mh-compose-type (filename type
c3d9274a 271 &optional description attributes comment)
0c47b17c 272 "Insert an MH-style directive to insert a file.
2dcf34f9
BW
273The file specified by FILENAME is encoded as TYPE. An optional
274DESCRIPTION is used as the Content-Description field, optional
275set of ATTRIBUTES and an optional COMMENT can also be included."
c26cf6c8
RS
276 (beginning-of-line)
277 (insert "#" type)
278 (and attributes
279 (insert "; " attributes))
280 (and comment
281 (insert " (" comment ")"))
282 (insert " [")
283 (and description
284 (insert description))
3fda54a2 285 (insert "] " (expand-file-name filename))
c26cf6c8
RS
286 (insert "\n"))
287
c3d9274a 288;;;###mh-autoload
0c47b17c
BW
289(defun mh-mh-compose-anon-ftp (host filename type description)
290 "Add tag to include anonymous ftp reference to a file.
af435184
BW
291
292You can have your message initiate an \"ftp\" transfer when the
293recipient reads the message. You are prompted for the remote HOST
294and FILENAME, the media TYPE, and the content DESCRIPTION.
bdcfe844 295
0c47b17c 296See also \\[mh-mh-to-mime]."
c26cf6c8 297 (interactive (list
c3d9274a
BW
298 (read-string "Remote host: ")
299 (read-string "Remote filename: ")
0c47b17c
BW
300 (mh-minibuffer-read-type "DUMMY-FILENAME")
301 (mml-minibuffer-read-description)))
302 (mh-mh-compose-external-type "anon-ftp" host filename
303 type description))
c26cf6c8 304
c3d9274a 305;;;###mh-autoload
0c47b17c
BW
306(defun mh-mh-compose-external-compressed-tar (host filename description)
307 "Add tag to include anonymous ftp reference to a compressed tar file.
af435184 308
2dcf34f9 309In addition to retrieving the file via anonymous \"ftp\" as per
af435184 310the command \\[mh-mh-compose-anon-ftp], the file will also be
2dcf34f9
BW
311uncompressed and untarred. You are prompted for the remote HOST
312and FILENAME and the content DESCRIPTION.
0c47b17c
BW
313
314See also \\[mh-mh-to-mime]."
c26cf6c8 315 (interactive (list
c3d9274a
BW
316 (read-string "Remote host: ")
317 (read-string "Remote filename: ")
0c47b17c
BW
318 (mml-minibuffer-read-description)))
319 (mh-mh-compose-external-type "anon-ftp" host filename
320 "application/octet-stream"
321 description
322 "type=tar; conversions=x-compress"
323 "mode=image"))
c26cf6c8 324
f0d73c14 325;;;###mh-autoload
0c47b17c
BW
326(defun mh-mh-compose-external-type (access-type host filename type
327 &optional description
328 attributes parameters
329 comment)
330 "Add tag to refer to a remote file.
af435184 331
2dcf34f9
BW
332This command is a general utility for referencing external files.
333In fact, all of the other commands that insert directives to
334access external files call this command. You are prompted for the
335ACCESS-TYPE, remote HOST and FILENAME, and content TYPE. If you
336provide a prefix argument, you are also prompted for a content
337DESCRIPTION, ATTRIBUTES, PARAMETERS, and a COMMENT.
0c47b17c
BW
338
339See also \\[mh-mh-to-mime]."
f0d73c14 340 (interactive (list
0c47b17c 341 (completing-read "Access type: " mh-access-types)
f0d73c14 342 (read-string "Remote host: ")
0c47b17c
BW
343 (read-string "Remote filename: ")
344 (mh-minibuffer-read-type "DUMMY-FILENAME")
345 (if current-prefix-arg (mml-minibuffer-read-description))
f0d73c14 346 (if current-prefix-arg (read-string "Attributes: "))
0c47b17c 347 (if current-prefix-arg (read-string "Parameters: "))
f0d73c14 348 (if current-prefix-arg (read-string "Comment: "))))
c26cf6c8
RS
349 (beginning-of-line)
350 (insert "#@" type)
351 (and attributes
352 (insert "; " attributes))
353 (and comment
354 (insert " (" comment ") "))
355 (insert " [")
356 (and description
357 (insert description))
358 (insert "] ")
359 (insert "access-type=" access-type "; ")
360 (insert "site=" host)
3fda54a2 361 (insert "; name=" (file-name-nondirectory filename))
f0d73c14
BW
362 (let ((directory (file-name-directory filename)))
363 (and directory
364 (insert "; directory=\"" directory "\"")))
0c47b17c
BW
365 (and parameters
366 (insert "; " parameters))
c26cf6c8
RS
367 (insert "\n"))
368
c3d9274a 369;;;###mh-autoload
0c47b17c
BW
370(defun mh-mh-forward-message (&optional description folder messages)
371 "Add tag to forward a message.
2dcf34f9
BW
372You are prompted for a content DESCRIPTION, the name of the
373FOLDER in which the messages to forward are located, and the
374MESSAGES' numbers.
bdcfe844 375
0c47b17c 376See also \\[mh-mh-to-mime]."
c26cf6c8 377 (interactive (list
0c47b17c 378 (mml-minibuffer-read-description)
c3d9274a 379 (mh-prompt-for-folder "Message from" mh-sent-from-folder nil)
d88a70a0 380 (read-string (concat "Messages"
f0d73c14 381 (if (numberp mh-sent-from-msg)
0c47b17c
BW
382 (format " (default %d): "
383 mh-sent-from-msg)
d88a70a0 384 ": ")))))
c26cf6c8
RS
385 (beginning-of-line)
386 (insert "#forw [")
387 (and description
388 (not (string= description ""))
389 (insert description))
390 (insert "]")
391 (and folder
392 (not (string= folder ""))
393 (insert " " folder))
847b8219 394 (if (and messages
c3d9274a 395 (not (string= messages "")))
c26cf6c8 396 (let ((start (point)))
c3d9274a
BW
397 (insert " " messages)
398 (subst-char-in-region start (point) ?, ? ))
f0d73c14 399 (if (numberp mh-sent-from-msg)
c3d9274a 400 (insert " " (int-to-string mh-sent-from-msg))))
c26cf6c8
RS
401 (insert "\n"))
402
c3d9274a 403;;;###mh-autoload
0c47b17c
BW
404(defun mh-mh-to-mime (&optional extra-args)
405 "Compose MIME message from MH-style directives.
d1699462 406
2dcf34f9
BW
407Typically, you send a message with attachments just like any other
408message. However, you may take a sneak preview of the MIME encoding if
409you wish by running this command.
0c47b17c 410
af435184
BW
411If you wish to pass additional arguments to \"mhbuild\" (\"mhn\")
412to affect how it builds your message, use the option
413`mh-mh-to-mime-args'. For example, you can build a consistency
414check into the message by setting `mh-mh-to-mime-args' to
415\"-check\". The recipient of your message can then run \"mhbuild
416-check\" on the message--\"mhbuild\" (\"mhn\") will complain if
417the message has been corrupted on the way. This command only
418consults this option when given a prefix argument EXTRA-ARGS.
0c47b17c 419
d1699462
BW
420The hook `mh-mh-to-mime-hook' is called after the message has been
421formatted.
0c47b17c 422
2dcf34f9
BW
423The effects of this command can be undone by running
424\\[mh-mh-to-mime-undo]."
847b8219 425 (interactive "*P")
0c47b17c 426 (mh-mh-quote-unescaped-sharp)
c26cf6c8 427 (save-buffer)
0c47b17c 428 (message "Running %s..." (if (mh-variant-p 'nmh) "mhbuild" "mhn"))
a1b4049d 429 (cond
f0d73c14 430 ((mh-variant-p 'nmh)
a1b4049d 431 (mh-exec-cmd-error nil
0c47b17c
BW
432 "mhbuild"
433 (if extra-args mh-mh-to-mime-args)
434 buffer-file-name))
a1b4049d
BW
435 (t
436 (mh-exec-cmd-error (format "mhdraft=%s" buffer-file-name)
0c47b17c
BW
437 "mhn"
438 (if extra-args mh-mh-to-mime-args)
439 buffer-file-name)))
c26cf6c8 440 (revert-buffer t t)
0c47b17c
BW
441 (message "Running %s...done" (if (mh-variant-p 'nmh) "mhbuild" "mhn"))
442 (run-hooks 'mh-mh-to-mime-hook))
c26cf6c8 443
0c47b17c 444(defun mh-mh-quote-unescaped-sharp ()
5a4aad03
BW
445 "Quote \"#\" characters that haven't been quoted for \"mhbuild\".
446If the \"#\" character is present in the first column, but it isn't
2dcf34f9
BW
447part of a MH-style directive then \"mhbuild\" gives an error.
448This function will quote all such characters."
f0d73c14
BW
449 (save-excursion
450 (goto-char (point-min))
451 (while (re-search-forward "^#" nil t)
452 (beginning-of-line)
0c47b17c 453 (unless (mh-mh-directive-present-p (point) (line-end-position))
f0d73c14
BW
454 (insert "#"))
455 (goto-char (line-end-position)))))
456
c3d9274a 457;;;###mh-autoload
0c47b17c
BW
458(defun mh-mh-to-mime-undo (noconfirm)
459 "Undo effects of \\[mh-mh-to-mime].
af435184
BW
460
461It does this by reverting to a backup file. You are prompted to
462confirm this action, but you can avoid the confirmation by adding
463a prefix argument NOCONFIRM."
c26cf6c8
RS
464 (interactive "*P")
465 (if (null buffer-file-name)
466 (error "Buffer does not seem to be associated with any file"))
467 (let ((backup-strings '("," "#"))
c3d9274a 468 backup-file)
c26cf6c8 469 (while (and backup-strings
c3d9274a
BW
470 (not (file-exists-p
471 (setq backup-file
472 (concat (file-name-directory buffer-file-name)
473 (car backup-strings)
474 (file-name-nondirectory buffer-file-name)
475 ".orig")))))
c26cf6c8
RS
476 (setq backup-strings (cdr backup-strings)))
477 (or backup-strings
f9c53c97 478 (error "Backup file for %s no longer exists" buffer-file-name))
c26cf6c8 479 (or noconfirm
c3d9274a
BW
480 (yes-or-no-p (format "Revert buffer from file %s? "
481 backup-file))
482 (error "Revert not confirmed"))
c26cf6c8
RS
483 (let ((buffer-read-only nil))
484 (erase-buffer)
485 (insert-file-contents backup-file))
486 (after-find-file nil)))
60370d40 487
924df208 488;;;###mh-autoload
0c47b17c
BW
489(defun mh-mh-directive-present-p (&optional begin end)
490 "Check if the text between BEGIN and END might be a MH-style directive.
2dcf34f9
BW
491The optional argument BEGIN defaults to the beginning of the
492buffer, while END defaults to the the end of the buffer."
f0d73c14
BW
493 (unless begin (setq begin (point-min)))
494 (unless end (setq end (point-max)))
924df208 495 (save-excursion
0c47b17c 496 (block 'search-for-mh-directive
f0d73c14
BW
497 (goto-char begin)
498 (while (re-search-forward "^#" end t)
924df208
BW
499 (let ((s (buffer-substring-no-properties (point) (line-end-position))))
500 (cond ((equal s ""))
501 ((string-match "^forw[ \t\n]+" s)
0c47b17c 502 (return-from 'search-for-mh-directive t))
924df208 503 (t (let ((first-token (car (split-string s "[ \t;@]"))))
f0d73c14
BW
504 (when (and first-token
505 (string-match mh-media-type-regexp
506 first-token))
0c47b17c 507 (return-from 'search-for-mh-directive t)))))))
924df208
BW
508 nil)))
509
bdcfe844
BW
510\f
511
512;;; MIME composition functions
513
c3d9274a 514;;;###mh-autoload
bdcfe844 515(defun mh-mml-to-mime ()
0c47b17c 516 "Compose MIME message from MML tags.
2dcf34f9
BW
517
518Typically, you send a message with attachments just like any
519other message. However, you may take a sneak preview of the MIME
520encoding if you wish by running this command.
0c47b17c
BW
521
522This action can be undone by running \\[undo]."
bdcfe844 523 (interactive)
a66894d8 524 (require 'message)
0c47b17c 525 (when mh-pgp-support-flag ;; This is only needed for PGP
bdcfe844 526 (message-options-set-recipient))
f0d73c14
BW
527 (let ((saved-text (buffer-string))
528 (buffer (current-buffer))
529 (modified-flag (buffer-modified-p)))
530 (condition-case err (mml-to-mime)
531 (error
532 (with-current-buffer buffer
533 (delete-region (point-min) (point-max))
534 (insert saved-text)
535 (set-buffer-modified-p modified-flag))
536 (error (error-message-string err))))))
bdcfe844 537
c3d9274a 538;;;###mh-autoload
bdcfe844
BW
539(defun mh-mml-forward-message (description folder message)
540 "Forward a message as attachment.
2dcf34f9
BW
541
542The function will prompt the user for a DESCRIPTION, a FOLDER and
543MESSAGE number."
f0d73c14 544 (let ((msg (if (and (equal message "") (numberp mh-sent-from-msg))
bdcfe844 545 mh-sent-from-msg
8d2aa237 546 (string-to-number message))))
bdcfe844
BW
547 (cond ((integerp msg)
548 (if (string= "" description)
549 ;; Rationale: mml-attach-file constructs a malformed composition
550 ;; if the description string is empty. This fixes SF #625168.
551 (mml-attach-file (format "%s%s/%d"
552 mh-user-path (substring folder 1) msg)
553 "message/rfc822")
554 (mml-attach-file (format "%s%s/%d"
555 mh-user-path (substring folder 1) msg)
556 "message/rfc822"
924df208 557 description)))
f9c53c97 558 (t (error "The message number, %s, is not a integer" msg)))))
bdcfe844 559
f0d73c14
BW
560(defvar mh-mml-cryptographic-method-history ())
561
562;;;###mh-autoload
563(defun mh-mml-query-cryptographic-method ()
564 "Read the cryptographic method to use."
565 (if current-prefix-arg
566 (let ((def (or (car mh-mml-cryptographic-method-history)
567 mh-mml-method-default)))
0c47b17c 568 (completing-read (format "Method (default %s): " def)
f0d73c14
BW
569 '(("pgp") ("pgpmime") ("smime"))
570 nil t nil 'mh-mml-cryptographic-method-history def))
571 mh-mml-method-default))
572
c3d9274a 573;;;###mh-autoload
bdcfe844 574(defun mh-mml-attach-file (&optional disposition)
0c47b17c 575 "Add a tag to insert a MIME message part from a file.
2dcf34f9
BW
576
577You are prompted for the filename containing the object, the
578media type if it cannot be determined automatically, a content
579description and the DISPOSITION of the attachment.
bdcfe844 580
0c47b17c 581This is basically `mml-attach-file' from Gnus, modified such that a prefix
5a4aad03 582argument yields an \"inline\" disposition and Content-Type is determined
bdcfe844
BW
583automatically."
584 (let* ((file (mml-minibuffer-read-file "Attach file: "))
0c47b17c 585 (type (mh-minibuffer-read-type file))
bdcfe844
BW
586 (description (mml-minibuffer-read-description))
587 (dispos (or disposition
0c47b17c 588 (mml-minibuffer-read-disposition type))))
bdcfe844 589 (mml-insert-empty-tag 'part 'type type 'filename file
924df208 590 'disposition dispos 'description description)))
bdcfe844 591
04f6a2d1
BW
592;; Shush compiler.
593(eval-when-compile (defvar mh-identity-pgg-default-user-id))
eccf9613 594
f0d73c14 595(defun mh-secure-message (method mode &optional identity)
0c47b17c 596 "Add tag to encrypt or sign message.
2dcf34f9 597
f0d73c14
BW
598METHOD should be one of: \"pgpmime\", \"pgp\", \"smime\".
599MODE should be one of: \"sign\", \"encrypt\", \"signencrypt\", \"none\".
600IDENTITY is optionally the default-user-id to use."
0c47b17c
BW
601 (if (not mh-pgp-support-flag)
602 (error "Your version of Gnus does not support PGP/GPG")
f0d73c14
BW
603 ;; Check the arguments
604 (let ((valid-methods (list "pgpmime" "pgp" "smime"))
605 (valid-modes (list "sign" "encrypt" "signencrypt" "none")))
606 (if (not (member method valid-methods))
f9c53c97 607 (error "Method %s is invalid" method))
f0d73c14 608 (if (not (member mode valid-modes))
f9c53c97 609 (error "Mode %s is invalid" mode))
f0d73c14
BW
610 (mml-unsecure-message)
611 (if (not (string= mode "none"))
612 (save-excursion
613 (goto-char (point-min))
614 (mh-goto-header-end 1)
615 (if mh-identity-pgg-default-user-id
616 (mml-insert-tag 'secure 'method method 'mode mode
617 'sender mh-identity-pgg-default-user-id)
618 (mml-insert-tag 'secure 'method method 'mode mode)))))))
bdcfe844 619
c3d9274a 620;;;###mh-autoload
285d1e0c
MB
621(defun mh-mml-unsecure-message ()
622 "Remove any secure message tags."
623 (interactive)
0c47b17c
BW
624 (if (not mh-pgp-support-flag)
625 (error "Your version of Gnus does not support PGP/GPG")
f0d73c14
BW
626 (mml-unsecure-message)))
627
628;;;###mh-autoload
629(defun mh-mml-secure-message-sign (method)
0c47b17c 630 "Add tag to sign the message.
2dcf34f9
BW
631
632A proper multipart message is created for you when you send the
af435184 633message. Use the command \\[mh-mml-unsecure-message] to remove
2dcf34f9 634this tag. Use a prefix argument METHOD to be prompted for one of
4023e353 635the possible security methods (see `mh-mml-method-default')."
f0d73c14
BW
636 (interactive (list (mh-mml-query-cryptographic-method)))
637 (mh-secure-message method "sign" mh-identity-pgg-default-user-id))
638
639;;;###mh-autoload
640(defun mh-mml-secure-message-encrypt (method)
0c47b17c 641 "Add tag to encrypt the message.
2dcf34f9
BW
642
643A proper multipart message is created for you when you send the
af435184 644message. Use the command \\[mh-mml-unsecure-message] to remove
2dcf34f9 645this tag. Use a prefix argument METHOD to be prompted for one of
4023e353 646the possible security methods (see `mh-mml-method-default')."
f0d73c14
BW
647 (interactive (list (mh-mml-query-cryptographic-method)))
648 (mh-secure-message method "encrypt" mh-identity-pgg-default-user-id))
649
650;;;###mh-autoload
651(defun mh-mml-secure-message-signencrypt (method)
0c47b17c 652 "Add tag to encrypt and sign the message.
2dcf34f9
BW
653
654A proper multipart message is created for you when you send the
af435184 655message. Use the command \\[mh-mml-unsecure-message] to remove
2dcf34f9 656this tag. Use a prefix argument METHOD to be prompted for one of
4023e353 657the possible security methods (see `mh-mml-method-default')."
f0d73c14
BW
658 (interactive (list (mh-mml-query-cryptographic-method)))
659 (mh-secure-message method "signencrypt" mh-identity-pgg-default-user-id))
924df208
BW
660
661;;;###mh-autoload
0c47b17c
BW
662(defun mh-mml-tag-present-p ()
663 "Check if the current buffer has text which may be a MML tag."
924df208
BW
664 (save-excursion
665 (goto-char (point-min))
666 (re-search-forward
98b7b7ed
BW
667 (concat
668 "\\(<#\\(mml\\|part\\)\\(.\\|\n\\)*>[ \n\t]*<#/\\(mml\\|part\\)>\\|"
669 "^<#secure.+>$\\)")
924df208 670 nil t)))
bdcfe844
BW
671
672\f
673
bdcfe844
BW
674;;; MIME cleanup
675
c3d9274a 676;;;###mh-autoload
bdcfe844
BW
677(defun mh-mime-cleanup ()
678 "Free the decoded MIME parts."
679 (let ((mime-data (gethash (current-buffer) mh-globals-hash)))
680 ;; This is for Emacs, what about XEmacs?
924df208 681 (mh-funcall-if-exists remove-images (point-min) (point-max))
bdcfe844
BW
682 (when mime-data
683 (mm-destroy-parts (mh-mime-handles mime-data))
684 (remhash (current-buffer) mh-globals-hash))))
685
c3d9274a 686;;;###mh-autoload
bdcfe844 687(defun mh-destroy-postponed-handles ()
0c47b17c 688 "Free MIME data for externally displayed MIME parts."
bdcfe844
BW
689 (let ((mime-data (mh-buffer-data)))
690 (when mime-data
691 (mm-destroy-parts (mh-mime-handles mime-data)))
692 (remhash (current-buffer) mh-globals-hash)))
693
694(defun mh-handle-set-external-undisplayer (folder handle function)
695 "Replacement for `mm-handle-set-external-undisplayer'.
2dcf34f9
BW
696
697This is only called in recent versions of Gnus. The MIME handles
698are stored in data structures corresponding to MH-E folder buffer
699FOLDER instead of in Gnus (as in the original). The MIME part,
700HANDLE is associated with the undisplayer FUNCTION."
bdcfe844
BW
701 (if (mm-keep-viewer-alive-p handle)
702 (let ((new-handle (copy-sequence handle)))
c3d9274a
BW
703 (mm-handle-set-undisplayer new-handle function)
704 (mm-handle-set-undisplayer handle nil)
bdcfe844
BW
705 (save-excursion
706 (set-buffer folder)
707 (push new-handle (mh-mime-handles (mh-buffer-data)))))
708 (mm-handle-set-undisplayer handle function)))
709
710\f
711
712;;; MIME transformations
c3d9274a 713(eval-when-compile (require 'font-lock))
bdcfe844 714
c3d9274a 715;;;###mh-autoload
bdcfe844
BW
716(defun mh-add-missing-mime-version-header ()
717 "Some mail programs don't put a MIME-Version header.
2dcf34f9
BW
718I have seen this only in spam, so maybe we shouldn't fix
719this ;-)"
bdcfe844
BW
720 (save-excursion
721 (goto-char (point-min))
a66894d8
BW
722 (re-search-forward "\n\n" nil t)
723 (save-restriction
724 (narrow-to-region (point-min) (point))
725 (when (and (message-fetch-field "content-type")
726 (not (message-fetch-field "mime-version")))
727 (goto-char (point-min))
bdcfe844
BW
728 (insert "MIME-Version: 1.0\n")))))
729
a66894d8
BW
730(defun mh-small-show-buffer-p ()
731 "Check if show buffer is small.
2dcf34f9
BW
732This is used to decide if smileys and graphical emphasis will be
733displayed."
a66894d8
BW
734 (let ((max nil))
735 (when (and (boundp 'font-lock-maximum-size) font-lock-maximum-size)
736 (cond ((numberp font-lock-maximum-size)
737 (setq max font-lock-maximum-size))
738 ((listp font-lock-maximum-size)
739 (setq max (cdr (or (assoc 'mh-show-mode font-lock-maximum-size)
740 (assoc t font-lock-maximum-size)))))))
741 (or (not (numberp max)) (>= (/ max 8) (buffer-size)))))
742
c3d9274a 743;;;###mh-autoload
bdcfe844 744(defun mh-display-smileys ()
0c47b17c 745 "Display smileys."
a66894d8
BW
746 (when (and mh-graphical-smileys-flag (mh-small-show-buffer-p))
747 (mh-funcall-if-exists smiley-region (point-min) (point-max))))
bdcfe844 748
c3d9274a 749;;;###mh-autoload
bdcfe844 750(defun mh-display-emphasis ()
0c47b17c 751 "Display graphical emphasis."
a66894d8 752 (when (and mh-graphical-emphasis-flag (mh-small-show-buffer-p))
c3d9274a 753 (flet ((article-goto-body ())) ; shadow this function to do nothing
bdcfe844
BW
754 (save-excursion
755 (goto-char (point-min))
756 (article-emphasize)))))
757
758;; Copied from gnus-art.el (should be checked for other cool things that can
759;; be added to the buttons)
760(defvar mh-mime-button-commands
761 '((mh-press-button "\r" "Toggle Display")))
762(defvar mh-mime-button-map
763 (let ((map (make-sparse-keymap)))
764 (unless (>= (string-to-number emacs-version) 21)
765 ;; XEmacs doesn't care.
766 (set-keymap-parent map mh-show-mode-map))
924df208
BW
767 (mh-do-in-gnu-emacs
768 (define-key map [mouse-2] 'mh-push-button))
769 (mh-do-in-xemacs
770 (define-key map '(button2) 'mh-push-button))
bdcfe844
BW
771 (dolist (c mh-mime-button-commands)
772 (define-key map (cadr c) (car c)))
773 map))
774(defvar mh-mime-button-line-format-alist
775 '((?T long-type ?s)
776 (?d description ?s)
777 (?p index ?s)
778 (?e dots ?s)))
779(defvar mh-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n")
780(defvar mh-mime-security-button-pressed nil)
781(defvar mh-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n")
782(defvar mh-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n")
783(defvar mh-mime-security-button-line-format-alist
784 '((?t type ?s)
785 (?i info ?s)
786 (?d details ?s)
787 (?D pressed-details ?s)))
788(defvar mh-mime-security-button-map
789 (let ((map (make-sparse-keymap)))
790 (unless (>= (string-to-number emacs-version) 21)
791 (set-keymap-parent map mh-show-mode-map))
792 (define-key map "\r" 'mh-press-button)
924df208
BW
793 (mh-do-in-gnu-emacs
794 (define-key map [mouse-2] 'mh-push-button))
795 (mh-do-in-xemacs
796 (define-key map '(button2) 'mh-push-button))
bdcfe844
BW
797 map))
798
799(defvar mh-mime-save-parts-directory nil
800 "Default to use for `mh-mime-save-parts-default-directory'.
801Set from last use.")
802
c3d9274a 803;;;###mh-autoload
553fb735
BW
804(defun mh-mime-save-parts (prompt)
805 "Save attachments.
806
2dcf34f9
BW
807You can save all of the attachments at once with this command.
808The attachments are saved in the directory specified by the
809option `mh-mime-save-parts-default-directory' unless you use a
810prefix argument PROMPT in which case you are prompted for the
811directory. These directories may be superseded by MH profile
812components, since this function calls on \"mhstore\" (\"mhn\") to
813do the work."
bdcfe844
BW
814 (interactive "P")
815 (let ((msg (if (eq major-mode 'mh-show-mode)
816 (mh-show-buffer-message-number)
817 (mh-get-msg-num t)))
818 (folder (if (eq major-mode 'mh-show-mode)
819 mh-show-folder-buffer
820 mh-current-folder))
f0d73c14 821 (command (if (mh-variant-p 'nmh) "mhstore" "mhn"))
bdcfe844
BW
822 (directory
823 (cond
553fb735 824 ((and (or prompt
bdcfe844
BW
825 (equal nil mh-mime-save-parts-default-directory)
826 (equal t mh-mime-save-parts-default-directory))
827 (not mh-mime-save-parts-directory))
f0d73c14 828 (read-file-name "Store in directory: " nil nil t nil))
553fb735 829 ((and (or prompt
bdcfe844
BW
830 (equal t mh-mime-save-parts-default-directory))
831 mh-mime-save-parts-directory)
832 (read-file-name (format
078cb314 833 "Store in directory (default %s): "
bdcfe844
BW
834 mh-mime-save-parts-directory)
835 "" mh-mime-save-parts-directory t ""))
836 ((stringp mh-mime-save-parts-default-directory)
837 mh-mime-save-parts-default-directory)
838 (t
839 mh-mime-save-parts-directory))))
840 (if (and (equal directory "") mh-mime-save-parts-directory)
841 (setq directory mh-mime-save-parts-directory))
842 (if (not (file-directory-p directory))
f0d73c14 843 (message "No directory specified")
bdcfe844
BW
844 (if (equal nil mh-mime-save-parts-default-directory)
845 (setq mh-mime-save-parts-directory directory))
846 (save-excursion
924df208 847 (set-buffer (get-buffer-create mh-log-buffer))
bdcfe844
BW
848 (cd directory)
849 (setq mh-mime-save-parts-directory directory)
924df208
BW
850 (let ((initial-size (mh-truncate-log-buffer)))
851 (apply 'call-process
852 (expand-file-name command mh-progs) nil t nil
853 (mh-list-to-string (list folder msg "-auto")))
854 (if (> (buffer-size) initial-size)
855 (save-window-excursion
856 (switch-to-buffer-other-window mh-log-buffer)
857 (sit-for 3))))))))
bdcfe844
BW
858
859;; Avoid errors if gnus-sum isn't loaded yet...
860(defvar gnus-newsgroup-charset nil)
861(defvar gnus-newsgroup-name nil)
862
924df208
BW
863(defun mh-decode-message-body ()
864 "Decode message based on charset.
865If message has been encoded for transfer take that into account."
a66894d8
BW
866 (let (ct charset cte)
867 (goto-char (point-min))
868 (re-search-forward "\n\n" nil t)
869 (save-restriction
870 (narrow-to-region (point-min) (point))
871 (setq ct (ignore-errors (mail-header-parse-content-type
872 (message-fetch-field "Content-Type" t)))
873 charset (mail-content-type-get ct 'charset)
874 cte (message-fetch-field "Content-Transfer-Encoding")))
924df208
BW
875 (when (stringp cte) (setq cte (mail-header-strip cte)))
876 (when (or (not ct) (equal (car ct) "text/plain"))
877 (save-restriction
878 (narrow-to-region (min (1+ (mh-mail-header-end)) (point-max))
879 (point-max))
880 (mm-decode-body charset
881 (and cte (intern (downcase
882 (gnus-strip-whitespace cte))))
883 (car ct))))))
884
d103d8b3
BW
885;;;###mh-autoload
886(defun mh-toggle-mh-decode-mime-flag ()
553fb735 887 "Toggle the value of `mh-decode-mime-flag'."
eccf9613 888 (interactive)
d103d8b3
BW
889 (setq mh-decode-mime-flag (not mh-decode-mime-flag))
890 (mh-show nil t)
553fb735
BW
891 (message "%s" (if mh-decode-mime-flag
892 "Processing attachments normally"
893 "Displaying raw message")))
d103d8b3 894
924df208
BW
895;;;###mh-autoload
896(defun mh-decode-message-header ()
897 "Decode RFC2047 encoded message header fields."
898 (when mh-decode-mime-flag
899 (let ((buffer-read-only nil))
900 (rfc2047-decode-region (point-min) (mh-mail-header-end)))))
901
c3d9274a 902;;;###mh-autoload
bdcfe844
BW
903(defun mh-mime-display (&optional pre-dissected-handles)
904 "Display (and possibly decode) MIME handles.
2dcf34f9
BW
905Optional argument, PRE-DISSECTED-HANDLES is a list of MIME
906handles. If present they are displayed otherwise the buffer is
907parsed and then displayed."
bdcfe844 908 (let ((handles ())
924df208
BW
909 (folder mh-show-folder-buffer)
910 (raw-message-data (buffer-string)))
c3d9274a
BW
911 (flet ((mm-handle-set-external-undisplayer
912 (handle function)
913 (mh-handle-set-external-undisplayer folder handle function)))
924df208
BW
914 (goto-char (point-min))
915 (unless (search-forward "\n\n" nil t)
916 (goto-char (point-max))
917 (insert "\n\n"))
918
919 (condition-case err
920 (progn
921 ;; If needed dissect the current buffer
922 (if pre-dissected-handles
923 (setq handles pre-dissected-handles)
9ac2e4e5
MB
924 (if (setq handles (mm-dissect-buffer nil))
925 (when (fboundp 'mm-uu-dissect-text-parts)
926 (mm-uu-dissect-text-parts handles))
927 (setq handles (mm-uu-dissect)))
924df208
BW
928 (setf (mh-mime-handles (mh-buffer-data))
929 (mm-merge-handles handles
930 (mh-mime-handles (mh-buffer-data))))
931 (unless handles (mh-decode-message-body)))
932
f0d73c14
BW
933 (cond ((and handles
934 (or (not (stringp (car handles))) (cdr handles)))
935 ;; Goto start of message body
936 (goto-char (point-min))
937 (or (search-forward "\n\n" nil t) (goto-char (point-max)))
bdcfe844 938
f0d73c14
BW
939 ;; Delete the body
940 (delete-region (point) (point-max))
bdcfe844 941
f0d73c14
BW
942 ;; Display the MIME handles
943 (mh-mime-display-part handles))
944 (t (mh-signature-highlight))))
924df208 945 (error
7094eefe 946 (message "Could not display body: %s" (error-message-string err))
924df208
BW
947 (delete-region (point-min) (point-max))
948 (insert raw-message-data))))))
bdcfe844
BW
949
950(defun mh-mime-display-part (handle)
951 "Decides the viewer to call based on the type of HANDLE."
952 (cond ((null handle) nil)
953 ((not (stringp (car handle)))
954 (mh-mime-display-single handle))
955 ((equal (car handle) "multipart/alternative")
956 (mh-mime-display-alternative (cdr handle)))
0c47b17c 957 ((and mh-pgp-support-flag
bdcfe844
BW
958 (or (equal (car handle) "multipart/signed")
959 (equal (car handle) "multipart/encrypted")))
960 (mh-mime-display-security handle))
961 (t (mh-mime-display-mixed (cdr handle)))))
962
963(defun mh-mime-display-alternative (handles)
964 "Choose among the alternatives, HANDLES the part that will be displayed.
965If no part is preferred then all the parts are displayed."
a66894d8
BW
966 (let* ((preferred (mm-preferred-alternative handles))
967 (others (loop for x in handles unless (eq x preferred) collect x)))
bdcfe844 968 (cond ((and preferred (stringp (car preferred)))
a66894d8
BW
969 (mh-mime-display-part preferred)
970 (mh-mime-maybe-display-alternatives others))
bdcfe844
BW
971 (preferred
972 (save-restriction
973 (narrow-to-region (point) (if (eobp) (point) (1+ (point))))
c3d9274a 974 (mh-mime-display-single preferred)
a66894d8 975 (mh-mime-maybe-display-alternatives others)
bdcfe844
BW
976 (goto-char (point-max))))
977 (t (mh-mime-display-mixed handles)))))
978
a66894d8
BW
979(defun mh-mime-maybe-display-alternatives (alternatives)
980 "Show buttons for ALTERNATIVES.
2dcf34f9
BW
981If `mh-mime-display-alternatives-flag' is non-nil then display
982buttons for alternative parts that are usually suppressed."
a66894d8
BW
983 (when (and mh-display-buttons-for-alternatives-flag alternatives)
984 (insert "\n----------------------------------------------------\n")
985 (insert "Alternatives:\n")
986 (dolist (x alternatives)
987 (insert "\n")
988 (mh-insert-mime-button x (mh-mime-part-index x) nil))
989 (insert "\n----------------------------------------------------\n")))
990
bdcfe844
BW
991(defun mh-mime-display-mixed (handles)
992 "Display the list of MIME parts, HANDLES recursively."
993 (mapcar #'mh-mime-display-part handles))
994
995(defun mh-mime-part-index (handle)
996 "Generate the button number for MIME part, HANDLE.
2dcf34f9
BW
997Notice that a hash table is used to display the same number when
998buttons need to be displayed multiple times (for instance when
999nested messages are opened)."
bdcfe844
BW
1000 (or (gethash handle (mh-mime-part-index-hash (mh-buffer-data)))
1001 (setf (gethash handle (mh-mime-part-index-hash (mh-buffer-data)))
1002 (incf (mh-mime-parts-count (mh-buffer-data))))))
1003
bdcfe844
BW
1004(defun mh-small-image-p (handle)
1005 "Decide whether HANDLE is a \"small\" image that can be displayed inline.
1006This is only useful if a Content-Disposition header is not present."
1007 (let ((media-test (caddr (assoc (car (mm-handle-type handle))
1008 mh-mm-inline-media-tests)))
1009 (mm-inline-large-images t))
1010 (and media-test
1011 (equal (mm-handle-media-supertype handle) "image")
c3d9274a
BW
1012 (funcall media-test handle) ; Since mm-inline-large-images is T,
1013 ; this only tells us if the image is
1014 ; something that emacs can display
bdcfe844 1015 (let* ((image (mm-get-image handle)))
a66894d8
BW
1016 (or (mh-do-in-xemacs
1017 (and (mh-funcall-if-exists glyphp image)
1018 (< (glyph-width image)
1019 (or mh-max-inline-image-width (window-pixel-width)))
1020 (< (glyph-height image)
1021 (or mh-max-inline-image-height
1022 (window-pixel-height)))))
1023 (mh-do-in-gnu-emacs
1024 (let ((size (mh-funcall-if-exists image-size image)))
1025 (and size
1026 (< (cdr size) (or mh-max-inline-image-height
1027 (1- (window-height))))
1028 (< (car size) (or mh-max-inline-image-width
1029 (window-width)))))))))))
bdcfe844 1030
c3d9274a
BW
1031(defun mh-inline-vcard-p (handle)
1032 "Decide if HANDLE is a vcard that must be displayed inline."
1033 (let ((type (mm-handle-type handle)))
924df208
BW
1034 (and (or (featurep 'vcard) (fboundp 'vcard-pretty-print))
1035 (consp type)
c3d9274a
BW
1036 (equal (car type) "text/x-vcard")
1037 (save-excursion
1038 (save-restriction
1039 (widen)
1040 (goto-char (point-min))
f0d73c14 1041 (not (mh-signature-separator-p)))))))
c3d9274a 1042
bdcfe844
BW
1043(defun mh-mime-display-single (handle)
1044 "Display a leaf node, HANDLE in the MIME tree."
1045 (let* ((type (mm-handle-media-type handle))
1046 (small-image-flag (mh-small-image-p handle))
1047 (attachmentp (equal (car (mm-handle-disposition handle))
1048 "attachment"))
1049 (inlinep (and (equal (car (mm-handle-disposition handle)) "inline")
1050 (mm-inlinable-p handle)
1051 (mm-inlined-p handle)))
c3d9274a
BW
1052 (displayp (or inlinep ; show if inline OR
1053 (mh-inline-vcard-p handle); inline vcard OR
1054 (and (not attachmentp) ; if not an attachment
1055 (or small-image-flag ; and small image
1056 ; and user wants inline
bdcfe844
BW
1057 (and (not (equal
1058 (mm-handle-media-supertype handle)
1059 "image"))
1060 (mm-inlinable-p handle)
1061 (mm-inlined-p handle)))))))
1062 (save-restriction
1063 (narrow-to-region (point) (if (eobp) (point) (1+ (point))))
0c47b17c 1064 (cond ((and mh-pgp-support-flag
bdcfe844 1065 (equal type "application/pgp-signature"))
c3d9274a 1066 nil) ; skip signatures as they are already handled...
bdcfe844
BW
1067 ((not displayp)
1068 (insert "\n")
1069 (mh-insert-mime-button handle (mh-mime-part-index handle) nil))
1070 ((and displayp (not mh-display-buttons-for-inline-parts-flag))
f0d73c14
BW
1071 (or (mm-display-part handle) (mm-display-part handle))
1072 (mh-signature-highlight handle))
bdcfe844
BW
1073 ((and displayp mh-display-buttons-for-inline-parts-flag)
1074 (insert "\n")
1075 (mh-insert-mime-button handle (mh-mime-part-index handle) nil)
1076 (forward-line -1)
1077 (mh-mm-display-part handle)))
1078 (goto-char (point-max)))))
1079
f0d73c14
BW
1080(defun mh-signature-highlight (&optional handle)
1081 "Highlight message signature in HANDLE.
2dcf34f9
BW
1082The optional argument, HANDLE is a MIME handle if the function is
1083being used to highlight the signature in a MIME part."
f0d73c14
BW
1084 (let ((regexp
1085 (cond ((not handle) "^-- $")
1086 ((not (and (equal (mm-handle-media-supertype handle) "text")
1087 (equal (mm-handle-media-subtype handle) "html")))
1088 "^-- $")
1089 ((eq (mh-mm-text-html-renderer) 'lynx) "^ --$")
1090 (t "^--$"))))
1091 (save-excursion
1092 (goto-char (point-max))
1093 (when (re-search-backward regexp nil t)
1094 (mh-do-in-gnu-emacs
1095 (let ((ov (make-overlay (point) (point-max))))
44d55491 1096 (overlay-put ov 'face 'mh-show-signature)
f0d73c14
BW
1097 (overlay-put ov 'evaporate t)))
1098 (mh-do-in-xemacs
1099 (set-extent-property (make-extent (point) (point-max))
44d55491 1100 'face 'mh-show-signature))))))
f0d73c14 1101
924df208
BW
1102(mh-do-in-xemacs
1103 (defvar dots)
1104 (defvar type))
1105
bdcfe844
BW
1106(defun mh-insert-mime-button (handle index displayed)
1107 "Insert MIME button for HANDLE.
2dcf34f9
BW
1108INDEX is the part number that will be DISPLAYED. It is also used
1109by commands like \"K v\" which operate on individual MIME parts."
bdcfe844
BW
1110 ;; The button could be displayed by a previous decode. In that case
1111 ;; undisplay it if we need a hidden button.
1112 (when (and (mm-handle-displayed-p handle) (not displayed))
1113 (mm-display-part handle))
1114 (let ((name (or (mail-content-type-get (mm-handle-type handle) 'name)
1115 (mail-content-type-get (mm-handle-disposition handle)
1116 'filename)
1117 (mail-content-type-get (mm-handle-type handle) 'url)
1118 ""))
1119 (type (mm-handle-media-type handle))
1120 (description (mail-decode-encoded-word-string
1121 (or (mm-handle-description handle) "")))
1122 (dots (if (or displayed (mm-handle-displayed-p handle)) " " "..."))
1123 long-type begin end)
1124 (if (string-match ".*/" name) (setq name (substring name (match-end 0))))
1125 (setq long-type (concat type (and (not (equal name ""))
1126 (concat "; " name))))
1127 (unless (equal description "")
1128 (setq long-type (concat " --- " long-type)))
1129 (unless (bolp) (insert "\n"))
1130 (setq begin (point))
1131 (gnus-eval-format
1132 mh-mime-button-line-format mh-mime-button-line-format-alist
1133 `(,@(gnus-local-map-property mh-mime-button-map)
c3d9274a
BW
1134 mh-callback mh-mm-display-part
1135 mh-part ,index
1136 mh-data ,handle))
bdcfe844
BW
1137 (setq end (point))
1138 (widget-convert-button
1139 'link begin end
1140 :mime-handle handle
1141 :action 'mh-widget-press-button
1142 :button-keymap mh-mime-button-map
1143 :help-echo
f0d73c14
BW
1144 "Mouse-2 click or press RET (in show buffer) to toggle display")
1145 (dolist (ov (mh-funcall-if-exists overlays-in begin end))
1146 (mh-funcall-if-exists overlay-put ov 'evaporate t))))
bdcfe844
BW
1147
1148;; There is a bug in Gnus inline image display due to which an extra line
1149;; gets inserted every time it is viewed. To work around that problem we are
1150;; using an extra property 'mh-region to remember the region that is added
1151;; when the button is clicked. The region is then deleted to make sure that
1152;; no extra lines get inserted.
1153(defun mh-mm-display-part (handle)
1154 "Toggle display of button for MIME part, HANDLE."
1155 (beginning-of-line)
1156 (let ((id (get-text-property (point) 'mh-part))
1157 (point (point))
1158 (window (selected-window))
1159 (mail-parse-charset 'nil)
1160 (mail-parse-ignored-charsets nil)
1161 region buffer-read-only)
1162 (save-excursion
1163 (unwind-protect
1164 (let ((win (get-buffer-window (current-buffer) t)))
1165 (when win
1166 (select-window win))
1167 (goto-char point)
1168
1169 (if (mm-handle-displayed-p handle)
1170 ;; This will remove the part.
1171 (progn
1172 ;; Delete the button and displayed part (if any)
1173 (let ((region (get-text-property point 'mh-region)))
a66894d8 1174 (when region
924df208
BW
1175 (mh-funcall-if-exists
1176 remove-images (car region) (cdr region)))
bdcfe844
BW
1177 (mm-display-part handle)
1178 (when region
1179 (delete-region (car region) (cdr region))))
1180 ;; Delete button (if it still remains). This happens for
1181 ;; externally displayed parts where the previous step does
1182 ;; nothing.
1183 (unless (eolp)
1184 (delete-region (point) (progn (forward-line) (point)))))
1185 (save-restriction
1186 (delete-region (point) (progn (forward-line 1) (point)))
1187 (narrow-to-region (point) (point))
1188 ;; Maybe we need another unwind-protect here.
1189 (when (equal (mm-handle-media-supertype handle) "image")
1190 (insert "\n"))
1191 (when (and (not (eq (ignore-errors (mm-display-part handle))
1192 'inline))
1193 (equal (mm-handle-media-supertype handle)
1194 "image"))
1195 (goto-char (point-min))
1196 (delete-char 1))
1197 (when (equal (mm-handle-media-supertype handle) "text")
553fb735 1198 (when (eq mh-highlight-citation-style 'gnus)
bdcfe844
BW
1199 (mh-gnus-article-highlight-citation))
1200 (mh-display-smileys)
f0d73c14
BW
1201 (mh-display-emphasis)
1202 (mh-signature-highlight handle))
bdcfe844
BW
1203 (setq region (cons (progn (goto-char (point-min))
1204 (point-marker))
1205 (progn (goto-char (point-max))
1206 (point-marker)))))))
1207 (when (window-live-p window)
1208 (select-window window))
1209 (goto-char point)
1210 (beginning-of-line)
1211 (mh-insert-mime-button handle id (mm-handle-displayed-p handle))
1212 (goto-char point)
1213 (when region
1214 (add-text-properties (line-beginning-position) (line-end-position)
1215 `(mh-region ,region)))))))
1216
c3d9274a 1217;;;###mh-autoload
bdcfe844 1218(defun mh-press-button ()
553fb735
BW
1219 "View contents of button.
1220
2dcf34f9
BW
1221This command is a toggle so if you use it again on the same
1222attachment, the attachment is hidden."
bdcfe844
BW
1223 (interactive)
1224 (let ((mm-inline-media-tests mh-mm-inline-media-tests)
1225 (data (get-text-property (point) 'mh-data))
1226 (function (get-text-property (point) 'mh-callback))
1227 (buffer-read-only nil)
1228 (folder mh-show-folder-buffer))
c3d9274a
BW
1229 (flet ((mm-handle-set-external-undisplayer
1230 (handle function)
1231 (mh-handle-set-external-undisplayer folder handle function)))
bdcfe844
BW
1232 (when (and function (eolp))
1233 (backward-char))
1234 (unwind-protect (and function (funcall function data))
1235 (set-buffer-modified-p nil)))))
1236
c3d9274a 1237;;;###mh-autoload
bdcfe844
BW
1238(defun mh-push-button (event)
1239 "Click MIME button for EVENT.
2dcf34f9
BW
1240
1241If the MIME part is visible then it is removed. Otherwise the
1242part is displayed. This function is called when the mouse is used
1243to click the MIME button."
bdcfe844 1244 (interactive "e")
a66894d8
BW
1245 (mh-do-at-event-location event
1246 (let ((folder mh-show-folder-buffer)
1247 (mm-inline-media-tests mh-mm-inline-media-tests)
1248 (data (get-text-property (point) 'mh-data))
1249 (function (get-text-property (point) 'mh-callback)))
1250 (flet ((mm-handle-set-external-undisplayer (handle func)
1251 (mh-handle-set-external-undisplayer folder handle func)))
1252 (and function (funcall function data))))))
bdcfe844 1253
c3d9274a 1254;;;###mh-autoload
bdcfe844
BW
1255(defun mh-mime-save-part ()
1256 "Save MIME part at point."
1257 (interactive)
1258 (let ((data (get-text-property (point) 'mh-data)))
1259 (when data
a66894d8
BW
1260 (let ((mm-default-directory
1261 (file-name-as-directory (or mh-mime-save-parts-directory
1262 default-directory))))
c3d9274a
BW
1263 (mh-mm-save-part data)
1264 (setq mh-mime-save-parts-directory mm-default-directory)))))
bdcfe844 1265
c3d9274a 1266;;;###mh-autoload
bdcfe844
BW
1267(defun mh-mime-inline-part ()
1268 "Toggle display of the raw MIME part."
1269 (interactive)
1270 (let* ((buffer-read-only nil)
1271 (data (get-text-property (point) 'mh-data))
1272 (inserted-flag (get-text-property (point) 'mh-mime-inserted))
1273 (displayed-flag (mm-handle-displayed-p data))
1274 (point (point))
1275 start end)
1276 (cond ((and data (not inserted-flag) (not displayed-flag))
1277 (let ((contents (mm-get-part data)))
1278 (add-text-properties (line-beginning-position) (line-end-position)
1279 '(mh-mime-inserted t))
1280 (setq start (point-marker))
1281 (forward-line 1)
1282 (mm-insert-inline data contents)
1283 (setq end (point-marker))
1284 (add-text-properties
1285 start (progn (goto-char start) (line-end-position))
1286 `(mh-region (,start . ,end)))))
1287 ((and data (or inserted-flag displayed-flag))
1288 (mh-press-button)
1289 (message "MIME part already inserted")))
1290 (goto-char point)
1291 (set-buffer-modified-p nil)))
1292
f0d73c14
BW
1293;;;###mh-autoload
1294(defun mh-display-with-external-viewer (part-index)
553fb735
BW
1295 "View attachment externally.
1296
2dcf34f9
BW
1297If Emacs does not know how to view an attachment, you could save
1298it into a file and then run some program to open it. It is
1299easier, however, to launch the program directly from MH-E with
1300this command. While you'll most likely use this to view
1301spreadsheets and documents, it is also useful to use your browser
1302to view HTML attachments with higher fidelity than what Emacs can
1303provide.
1304
1305This command displays the attachment associated with the button
1306under the cursor. If the cursor is not located over a button,
1307then the cursor first moves to the next button, wrapping to the
1308beginning of the message if necessary. You can provide a numeric
1309prefix argument PART-INDEX to view the attachment labeled with
1310that number.
1311
1312This command tries to provide a reasonable default for the viewer
1313by calling the Emacs function `mailcap-mime-info'. This function
1314usually reads the file \"/etc/mailcap\"."
f0d73c14
BW
1315 (interactive "P")
1316 (when (consp part-index) (setq part-index (car part-index)))
1317 (mh-folder-mime-action
1318 part-index
1319 #'(lambda ()
1320 (let* ((part (get-text-property (point) 'mh-data))
1321 (type (mm-handle-media-type part))
1322 (methods (mapcar (lambda (x) (list (cdr (assoc 'viewer x))))
1323 (mailcap-mime-info type 'all)))
1324 (def (caar methods))
553fb735
BW
1325 (prompt (format "Viewer%s: " (if def
1326 (format " (default %s)" def)
1327 "")))
f0d73c14
BW
1328 (method (completing-read prompt methods nil nil nil nil def))
1329 (folder mh-show-folder-buffer)
1330 (buffer-read-only nil))
1331 (when (string-match "^[^% \t]+$" method)
1332 (setq method (concat method " %s")))
1333 (flet ((mm-handle-set-external-undisplayer (handle function)
1334 (mh-handle-set-external-undisplayer folder handle function)))
1335 (unwind-protect (mm-display-external part method)
1336 (set-buffer-modified-p nil)))))
1337 nil))
1338
bdcfe844
BW
1339(defun mh-widget-press-button (widget el)
1340 "Callback for widget, WIDGET.
1341Parameter EL is unused."
1342 (goto-char (widget-get widget :from))
1343 (mh-press-button))
1344
1345(defun mh-mime-display-security (handle)
1346 "Display PGP encrypted/signed message, HANDLE."
bdcfe844
BW
1347 (save-restriction
1348 (narrow-to-region (point) (point))
f0d73c14 1349 (insert "\n")
bdcfe844
BW
1350 (mh-insert-mime-security-button handle)
1351 (mh-mime-display-mixed (cdr handle))
1352 (insert "\n")
1353 (let ((mh-mime-security-button-line-format
c3d9274a 1354 mh-mime-security-button-end-line-format))
bdcfe844
BW
1355 (mh-insert-mime-security-button handle))
1356 (mm-set-handle-multipart-parameter
f0d73c14 1357 handle 'mh-region (cons (point-min-marker) (point-max-marker)))))
bdcfe844 1358
cee9f5c6
BW
1359;; I rewrote the security part because Gnus doesn't seem to ever minimize
1360;; the button. That is once the mime-security button is pressed there seems
1361;; to be no way of getting rid of the inserted text.
bdcfe844
BW
1362(defun mh-mime-security-show-details (handle)
1363 "Toggle display of detailed security info for HANDLE."
1364 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
1365 (when details
1366 (let ((mh-mime-security-button-pressed
c3d9274a 1367 (not (get-text-property (point) 'mh-button-pressed)))
bdcfe844 1368 (mh-mime-security-button-line-format
c3d9274a 1369 (get-text-property (point) 'mh-line-format)))
bdcfe844
BW
1370 (forward-char -1)
1371 (while (eq (get-text-property (point) 'mh-line-format)
1372 mh-mime-security-button-line-format)
1373 (forward-char -1))
1374 (forward-char)
1375 (save-restriction
1376 (narrow-to-region (point) (point))
1377 (mh-insert-mime-security-button handle))
1378 (delete-region
1379 (point)
1380 (or (text-property-not-all
1381 (point) (point-max)
1382 'mh-line-format mh-mime-security-button-line-format)
1383 (point-max)))
1384 (forward-line -1)))))
1385
e495eaec
BW
1386(defun mh-mime-security-button-face (info)
1387 "Return the button face to use for encrypted/signed mail based on INFO."
1388 (cond ((string-match "OK" info) ;Decrypted mail
d49ed7d4 1389 'mh-show-pgg-good)
e495eaec 1390 ((string-match "Failed" info) ;Decryption failed or signature invalid
d49ed7d4 1391 'mh-show-pgg-bad)
e495eaec 1392 ((string-match "Undecided" info);Unprocessed mail
d49ed7d4 1393 'mh-show-pgg-unknown)
e495eaec 1394 ((string-match "Untrusted" info);Key not trusted
d49ed7d4
BW
1395 'mh-show-pgg-unknown)
1396 (t
1397 'mh-show-pgg-good)))
e495eaec 1398
bdcfe844
BW
1399(defun mh-mime-security-press-button (handle)
1400 "Callback from security button for part HANDLE."
f0d73c14
BW
1401 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
1402 (mh-mime-security-show-details handle)
1403 (let ((region (mm-handle-multipart-ctl-parameter handle 'mh-region))
1404 point)
1405 (setq point (point))
1406 (goto-char (car region))
1407 (delete-region (car region) (cdr region))
1408 (with-current-buffer (mm-handle-multipart-ctl-parameter handle 'buffer)
1409 (let* ((mm-verify-option 'known)
1410 (mm-decrypt-option 'known)
1411 (new (mm-possibly-verify-or-decrypt (cdr handle) handle)))
1412 (unless (eq new (cdr handle))
1413 (mm-destroy-parts (cdr handle))
1414 (setcdr handle new))))
1415 (mh-mime-display-security handle)
1416 (goto-char point))))
bdcfe844 1417
23847cd6 1418;; Shush compiler.
7094eefe
BW
1419(eval-when-compile
1420 (defvar mm-verify-function-alist nil)
1421 (defvar mm-decrypt-function-alist nil))
bdcfe844
BW
1422
1423(defvar pressed-details)
1424
1425(defun mh-insert-mime-security-button (handle)
1426 "Display buttons for PGP message, HANDLE."
1427 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
1428 (crypto-type (or (nth 2 (assoc protocol mm-verify-function-alist))
1429 (nth 2 (assoc protocol mm-decrypt-function-alist))
1430 "Unknown"))
1431 (type (concat crypto-type
1432 (if (equal (car handle) "multipart/signed")
1433 " Signed" " Encrypted")
1434 " Part"))
1435 (info (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
1436 "Undecided"))
1437 (details (mm-handle-multipart-ctl-parameter handle 'gnus-details))
e495eaec 1438 pressed-details begin end face)
bdcfe844
BW
1439 (setq details (if details (concat "\n" details) ""))
1440 (setq pressed-details (if mh-mime-security-button-pressed details ""))
e495eaec 1441 (setq face (mh-mime-security-button-face info))
bdcfe844
BW
1442 (unless (bolp) (insert "\n"))
1443 (setq begin (point))
1444 (gnus-eval-format
1445 mh-mime-security-button-line-format
1446 mh-mime-security-button-line-format-alist
1447 `(,@(gnus-local-map-property mh-mime-security-button-map)
c3d9274a
BW
1448 mh-button-pressed ,mh-mime-security-button-pressed
1449 mh-callback mh-mime-security-press-button
1450 mh-line-format ,mh-mime-security-button-line-format
1451 mh-data ,handle))
bdcfe844
BW
1452 (setq end (point))
1453 (widget-convert-button 'link begin end
1454 :mime-handle handle
1455 :action 'mh-widget-press-button
1456 :button-keymap mh-mime-security-button-map
e495eaec 1457 :button-face face
bdcfe844 1458 :help-echo "Mouse-2 click or press RET (in show buffer) to see security details.")
f0d73c14
BW
1459 (dolist (ov (mh-funcall-if-exists overlays-in begin end))
1460 (mh-funcall-if-exists overlay-put ov 'evaporate t))
bdcfe844
BW
1461 (when (equal info "Failed")
1462 (let* ((type (if (equal (car handle) "multipart/signed")
1463 "verification" "decryption"))
1464 (warning (if (equal type "decryption")
1465 "(passphrase may be incorrect)" "")))
1466 (message "%s %s failed %s" crypto-type type warning)))))
1467
1468(defun mh-mm-inline-message (handle)
1469 "Display message, HANDLE.
2dcf34f9
BW
1470The function decodes the message and displays it. It avoids
1471decoding the same message multiple times."
bdcfe844 1472 (let ((b (point))
bdcfe844 1473 (clean-message-header mh-clean-message-header-flag)
f0d73c14
BW
1474 (invisible-headers mh-invisible-header-fields-compiled)
1475 (visible-headers nil))
bdcfe844
BW
1476 (save-excursion
1477 (save-restriction
1478 (narrow-to-region b b)
1479 (mm-insert-part handle)
1480 (mh-mime-display
1481 (or (gethash handle (mh-mime-handles-cache (mh-buffer-data)))
1482 (setf (gethash handle (mh-mime-handles-cache (mh-buffer-data)))
9ac2e4e5
MB
1483 (let ((handles (mm-dissect-buffer nil)))
1484 (if handles
1485 (when (fboundp 'mm-uu-dissect-text-parts)
1486 (mm-uu-dissect-text-parts handles))
1487 (setq handles (mm-uu-dissect)))
bdcfe844
BW
1488 (setf (mh-mime-handles (mh-buffer-data))
1489 (mm-merge-handles
1490 handles (mh-mime-handles (mh-buffer-data))))
1491 handles))))
1492
1493 (goto-char (point-min))
924df208 1494 (mh-show-xface)
bdcfe844
BW
1495 (cond (clean-message-header
1496 (mh-clean-msg-header (point-min)
1497 invisible-headers
1498 visible-headers)
1499 (goto-char (point-min)))
1500 (t
1501 (mh-start-of-uncleaned-message)))
924df208 1502 (mh-decode-message-header)
bdcfe844
BW
1503 (mh-show-addr)
1504 ;; The other highlighting types don't need anything special
553fb735 1505 (when (eq mh-highlight-citation-style 'gnus)
bdcfe844
BW
1506 (mh-gnus-article-highlight-citation))
1507 (goto-char (point-min))
1508 (insert "\n------- Forwarded Message\n\n")
1509 (mh-display-smileys)
1510 (mh-display-emphasis)
1511 (mm-handle-set-undisplayer
1512 handle
1513 `(lambda ()
1514 (let (buffer-read-only)
1515 (if (fboundp 'remove-specifier)
1516 ;; This is only valid on XEmacs.
1517 (mapcar (lambda (prop)
1518 (remove-specifier
1519 (face-property 'default prop) (current-buffer)))
1520 '(background background-pixmap foreground)))
1521 (delete-region ,(point-min-marker) ,(point-max-marker)))))))))
1522
1523(provide 'mh-mime)
1524
cee9f5c6
BW
1525;; Local Variables:
1526;; indent-tabs-mode: nil
1527;; sentence-end-double-space: nil
1528;; End:
bdcfe844 1529
cee9f5c6 1530;; arch-tag: 0dd36518-1b64-4a84-8f4e-59f422d3f002
60370d40 1531;;; mh-mime.el ends here