annotate lisp/mail/mh-mime.el @ 48770:208d298f6d14

*** empty log message ***
author Dave Love <fx@gnu.org>
date Mon, 09 Dec 2002 18:12:01 +0000
parents 8aaba207e44b
children 30c4902b654d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1 ;;; mh-mime.el --- MH-E support for composing MIME messages
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
2
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
3 ;; Copyright (C) 1993, 1995, 2001, 2002 Free Software Foundation, Inc.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
5 ;; Author: Bill Wohler <wohler@newt.com>
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
6 ;; Maintainer: Bill Wohler <wohler@newt.com>
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
7 ;; Keywords: mail
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
8 ;; See: mh-e.el
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 23305
diff changeset
10 ;; This file is part of GNU Emacs.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
11333
53174cfc29fa Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 11332
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; any later version.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
11333
53174cfc29fa Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 11332
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
25 ;; Boston, MA 02111-1307, USA.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
29 ;; Internal support for MH-E package.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
30 ;; Support for generating an mhn composition file.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13387
diff changeset
31 ;; MIME is supported only by MH 6.8 or later.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
33 ;;; Change Log:
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
34
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
35 ;; $Id: mh-mime.el,v 1.90 2002/11/22 20:00:48 satyaki Exp $
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
36
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;;; Code:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
39 (require 'cl)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (require 'mh-comp)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
41 (require 'mh-utils)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
42 (load "mm-decode" t t) ; Non-fatal dependency
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
43 (load "mm-uu" t t) ; Non-fatal dependency
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
44 (load "mailcap" t t) ; Non-fatal dependency
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
45 (load "smiley" t t) ; Non-fatal dependency
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
46 (require 'gnus-util)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
47
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
48 (autoload 'gnus-article-goto-header "gnus-art")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
49 (autoload 'article-emphasize "gnus-art")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
50 (autoload 'gnus-get-buffer-create "gnus")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
51 (autoload 'gnus-eval-format "gnus-spec")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
52 (autoload 'widget-convert-button "wid-edit")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
53 (autoload 'message-options-set-recipient "message")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
54 (autoload 'mml-secure-message-sign-pgpmime "mml-sec")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
55 (autoload 'mml-secure-message-encrypt-pgpmime "mml-sec")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
56 (autoload 'mml-minibuffer-read-file "mml")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
57 (autoload 'mml-minibuffer-read-description "mml")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
58 (autoload 'mml-insert-empty-tag "mml")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
59 (autoload 'mml-to-mime "mml")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
60 (autoload 'mml-attach-file "mml")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
61
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
62 ;;; Hooks
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
63 (defcustom mh-edit-mhn-hook nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
64 "Invoked on the formatted letter by \\<mh-letter-mode-map>\\[mh-edit-mhn]."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
65 :type 'hook
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
66 :group 'mh-hook)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
67
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
68 ;; Keeps assorted MIME data
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
69 (defstruct (mh-buffer-data (:conc-name mh-mime-)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
70 (:constructor mh-make-buffer-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
71 ;; Structure to keep track of MIME handles on a per buffer basis.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
72 (handles ()) ; List of MIME handles
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
73 (handles-cache (make-hash-table)) ; Cache to avoid multiple decodes of
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
74 ; nested messages
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
75 (parts-count 0) ; The button number is generated from
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
76 ; this number
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
77 (part-index-hash (make-hash-table))) ; Avoid incrementing the part number
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
78 ; for nested messages
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
79
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
80 ;;; This has to be a macro, since we do: (setf (mh-buffer-data) ...)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
81 (defmacro mh-buffer-data ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
82 "Convenience macro to get the MIME data structures of the current buffer."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
83 `(gethash (current-buffer) mh-globals-hash))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
84
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
85 (defun mh-compose-insertion (&optional inline)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
86 "Add a directive to insert a MIME part from a file, using mhn or gnus.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
87 If the variable `mh-compose-insertion' is set to 'mhn, then that will be used.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
88 If it is set to 'gnus, then that will be used instead.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
89 Optional argument INLINE means make it an inline attachment."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
90 (interactive "P")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
91 (if (equal mh-compose-insertion 'gnus)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
92 (if inline
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
93 (mh-mml-attach-file "inline")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
94 (mh-mml-attach-file))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
95 (call-interactively 'mh-mhn-compose-insertion)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
96
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
97 (defun mh-compose-forward (&optional description folder message)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
98 "Add a MIME directive to forward a message, using mhn or gnus.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
99 If the variable `mh-compose-insertion' is set to 'mhn, then that will be used.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
100 If it is set to 'gnus, then that will be used instead.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
101 Optional argument DESCRIPTION is a description of the attachment.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
102 Optional argument FOLDER is the folder from which the forwarded message should
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
103 come.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
104 Optional argument MESSAGE is the message to forward.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
105 If any of the optional arguments are absent, they are prompted for."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
106 (interactive (list
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
107 (read-string "Forw Content-description: ")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
108 (mh-prompt-for-folder "Message from" mh-sent-from-folder nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
109 (read-string (format "Messages%s: "
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
110 (if mh-sent-from-msg
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
111 (format " [%d]" mh-sent-from-msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
112 "")))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
113 (if (equal mh-compose-insertion 'gnus)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
114 (mh-mml-forward-message description folder message)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
115 (mh-mhn-compose-forw description folder message)))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; To do:
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;; paragraph code should not fill # lines if MIME enabled.
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;; implement mh-auto-edit-mhn (if non-nil, \\[mh-send-letter]
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;; invokes mh-edit-mhn automatically before sending.)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;; actually, instead of mh-auto-edit-mhn,
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; should read automhnproc from profile
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;; MIME option to mh-forward
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; command to move to content-description insertion point
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
126 (defvar mh-mhn-args nil
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
127 "Extra arguments to have \\[mh-edit-mhn] pass to the \"mhn\" command.
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
128 The arguments are passed to mhn if \\[mh-edit-mhn] is given a
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
129 prefix argument. Normally default arguments to mhn are specified in the
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
130 MH profile.")
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
131
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
132 (defvar mh-media-type-regexp
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
133 (concat (regexp-opt '("text" "image" "audio" "video" "application"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
134 "multipart" "message") t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
135 "/[-.+a-zA-Z0-9]+")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
136 "Regexp matching valid media types used in MIME attachment compositions.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
137
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
138 ;; Just defvar the variable to avoid compiler warning... This doesn't bind
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
139 ;; the variable, so things should work exactly as before.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
140 (defvar mh-have-file-command)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
141
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
142 (defun mh-have-file-command ()
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
143 "Return t if 'file' command is on the system.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
144 'file -i' is used to get MIME type of composition insertion."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
145 (when (not (boundp 'mh-have-file-command))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
146 (load "executable" t t) ; executable-find not autoloaded in emacs20
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
147 (setq mh-have-file-command
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
148 (and (fboundp 'executable-find)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
149 (executable-find "file") ; file command exists
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
150 ; and accepts -i and -b args.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
151 (zerop (call-process "file" nil nil nil "-i" "-b"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
152 (expand-file-name "inc" mh-progs))))))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
153 mh-have-file-command)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
154
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
155 (defvar mh-file-mime-type-substitutions
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
156 '(("application/msword" "\.xls" "application/ms-excel")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
157 ("application/msword" "\.ppt" "application/ms-powerpoint"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
158 "Substitutions to make for Content-Type returned from file command.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
159 The first element is the Content-Type returned by the file command.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
160 The second element is a regexp matching the file name, usually the extension.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
161 The third element is the Content-Type to replace with.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
162
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
163 (defun mh-file-mime-type-substitute (content-type filename)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
164 "Return possibly changed CONTENT-TYPE on the FILENAME.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
165 Substitutions are made from the `mh-file-mime-type-substitutions' variable."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
166 (let ((subst mh-file-mime-type-substitutions)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
167 (type) (match) (answer content-type)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
168 (case-fold-search t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
169 (while subst
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
170 (setq type (car (car subst))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
171 match (elt (car subst) 1))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
172 (if (and (string-equal content-type type)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
173 (string-match match filename))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
174 (setq answer (elt (car subst) 2)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
175 subst nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
176 (setq subst (cdr subst))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
177 answer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
178
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
179 (defun mh-file-mime-type (filename)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
180 "Return MIME type of FILENAME from file command.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
181 Returns nil if file command not on system."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
182 (cond
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
183 ((not (mh-have-file-command))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
184 nil) ;No file command, exit now.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
185 ((not (and (file-exists-p filename)(file-readable-p filename)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
186 nil)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
187 (t
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
188 (save-excursion
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
189 (let ((tmp-buffer (get-buffer-create mh-temp-buffer)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
190 (set-buffer tmp-buffer)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
191 (unwind-protect
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
192 (progn
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
193 (call-process "file" nil '(t nil) nil "-b" "-i"
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
194 (expand-file-name filename))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
195 (goto-char (point-min))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
196 (if (not (re-search-forward mh-media-type-regexp nil t))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
197 nil
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
198 (mh-file-mime-type-substitute (match-string 0) filename)))
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
199 (kill-buffer tmp-buffer)))))))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
200
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
201 ;;; This is needed for Emacs20 which doesn't have mailcap-mime-types.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (defvar mh-mime-content-types
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
203 '(("application/mac-binhex40") ("application/msword")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
204 ("application/octet-stream") ("application/pdf") ("application/pgp-keys")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
205 ("application/pgp-signature") ("application/pkcs7-signature")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
206 ("application/postscript") ("application/rtf")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
207 ("application/vnd.ms-excel") ("application/vnd.ms-powerpoint")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
208 ("application/vnd.ms-project") ("application/vnd.ms-tnef")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
209 ("application/wordperfect5.1") ("application/wordperfect6.0")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
210 ("application/zip")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
211
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
212 ("audio/basic") ("audio/mpeg")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
213
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
214 ("image/gif") ("image/jpeg") ("image/png")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
215
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
216 ("message/delivery-status")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
217 ("message/external-body") ("message/partial") ("message/rfc822")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
218
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
219 ("text/enriched") ("text/html") ("text/plain") ("text/rfc822-headers")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
220 ("text/richtext") ("text/xml")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
221
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
222 ("video/mpeg") ("video/quicktime"))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
223 "Legal MIME content types.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
224 See documentation for \\[mh-edit-mhn].")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
225
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
226 (defun mh-mhn-compose-insertion (filename type description attributes)
11506
5e44b1839ed4 Update some MIME doc strings.
Karl Heuer <kwzh@gnu.org>
parents: 11333
diff changeset
227 "Add a directive to insert a MIME message part from a file.
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
228 This is the typical way to insert non-text parts in a message.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
229
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
230 Arguments are FILENAME, which tells where to find the file, TYPE, the MIME
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
231 content type, DESCRIPTION, a line of text for the Content-Description field.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
232 ATTRIBUTES is a comma separated list of name=value pairs that is appended to
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
233 the Content-Type field of the attachment.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
234
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
235 See also \\[mh-edit-mhn]."
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
236 (interactive (let ((filename (read-file-name "Insert contents of: ")))
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
237 (list
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
238 filename
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
239 (or (mh-file-mime-type filename)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
240 (completing-read "Content-Type: "
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
241 (if (fboundp 'mailcap-mime-types)
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
242 (mapcar 'list (mailcap-mime-types))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
243 mh-mime-content-types)))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
244 (read-string "Content-Description: ")
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
245 (read-string "Content-Attributes: "
23305
61483b4c169c (mh-mhn-compose-insertion): Use quotes.
Karl Heuer <kwzh@gnu.org>
parents: 16862
diff changeset
246 (concat "name=\""
61483b4c169c (mh-mhn-compose-insertion): Use quotes.
Karl Heuer <kwzh@gnu.org>
parents: 16862
diff changeset
247 (file-name-nondirectory filename)
61483b4c169c (mh-mhn-compose-insertion): Use quotes.
Karl Heuer <kwzh@gnu.org>
parents: 16862
diff changeset
248 "\"")))))
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
249 (mh-mhn-compose-type filename type description attributes ))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
251 (defun mh-mhn-compose-type (filename type
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 &optional description attributes comment)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
253 "Insert a mhn directive to insert a file.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
254
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
255 The file specified by FILENAME is encoded as TYPE. An optional DESCRIPTION is
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
256 used as the Content-Description field, optional set of ATTRIBUTES and an
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
257 optional COMMENT can also be included."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
258 (setq mh-mhn-compose-insert-flag t)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (beginning-of-line)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (insert "#" type)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (and attributes
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (insert "; " attributes))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (and comment
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (insert " (" comment ")"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (insert " [")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (and description
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (insert description))
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
268 (insert "] " (expand-file-name filename))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (insert "\n"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
272 (defun mh-mhn-compose-anon-ftp (host filename type description)
11506
5e44b1839ed4 Update some MIME doc strings.
Karl Heuer <kwzh@gnu.org>
parents: 11333
diff changeset
273 "Add a directive for a MIME anonymous ftp external body part.
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
274 This directive tells MH to include a reference to a message/external-body part
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
275 retrievable by anonymous FTP.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
276
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
277 Arguments are HOST and FILENAME, which tell where to find the file, TYPE, the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
278 MIME content type, and DESCRIPTION, a line of text for the Content-description
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
279 header.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
280
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
281 See also \\[mh-edit-mhn]."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (interactive (list
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (read-string "Remote host: ")
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
284 (read-string "Remote filename: ")
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
285 (completing-read "External Content-Type: "
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
286 (if (fboundp 'mailcap-mime-types)
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
287 (mapcar 'list (mailcap-mime-types))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
288 mh-mime-content-types))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
289 (read-string "External Content-Description: ")))
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
290 (mh-mhn-compose-external-type "anon-ftp" host filename
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 type description))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
293 (defun mh-mhn-compose-external-compressed-tar (host filename description)
11506
5e44b1839ed4 Update some MIME doc strings.
Karl Heuer <kwzh@gnu.org>
parents: 11333
diff changeset
294 "Add a directive to include a MIME reference to a compressed tar file.
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
295 The file should be available via anonymous ftp. This directive tells MH to
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
296 include a reference to a message/external-body part.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
297
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
298 Arguments are HOST and FILENAME, which tell where to find the file, and
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
299 DESCRIPTION, a line of text for the Content-description header.
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
300
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 See also \\[mh-edit-mhn]."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (interactive (list
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (read-string "Remote host: ")
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
304 (read-string "Remote filename: ")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (read-string "Tar file Content-description: ")))
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
306 (mh-mhn-compose-external-type "anon-ftp" host filename
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 "application/octet-stream"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 description
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 "type=tar; conversions=x-compress"
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 "mode=image"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
313 (defun mh-mhn-compose-external-type (access-type host filename type
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 &optional description
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 attributes extra-params comment)
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
316 "Add a directive to include a MIME reference to a remote file.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
317 The file should be available via anonymous ftp. This directive tells MH to
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
318 include a reference to a message/external-body part.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
319
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
320 Arguments are ACCESS-TYPE, HOST and FILENAME, which tell where to find the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
321 file and TYPE which is the MIME Content-Type. Optional arguments include
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
322 DESCRIPTION, a line of text for the Content-description header, ATTRIBUTES,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
323 EXTRA-PARAMS, and COMMENT.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
324
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
325 See also \\[mh-edit-mhn]."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
326 (setq mh-mhn-compose-insert-flag t)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (beginning-of-line)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (insert "#@" type)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (and attributes
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (insert "; " attributes))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (and comment
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (insert " (" comment ") "))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (insert " [")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (and description
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (insert description))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (insert "] ")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (insert "access-type=" access-type "; ")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (insert "site=" host)
16862
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
339 (insert "; name=" (file-name-nondirectory filename))
7417db9e3f61 Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
340 (insert "; directory=\"" (file-name-directory filename) "\"")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (and extra-params
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (insert "; " extra-params))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (insert "\n"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
345 (defun mh-mhn-compose-forw (&optional description folder messages)
11506
5e44b1839ed4 Update some MIME doc strings.
Karl Heuer <kwzh@gnu.org>
parents: 11333
diff changeset
346 "Add a forw directive to this message, to forward a message with MIME.
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 This directive tells MH to include the named messages in this one.
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
348
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 Arguments are DESCRIPTION, a line of text for the Content-description header,
11506
5e44b1839ed4 Update some MIME doc strings.
Karl Heuer <kwzh@gnu.org>
parents: 11333
diff changeset
350 and FOLDER and MESSAGES, which name the message(s) to be forwarded.
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
351
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 See also \\[mh-edit-mhn]."
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (interactive (list
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (read-string "Forw Content-description: ")
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
355 (mh-prompt-for-folder "Message from" mh-sent-from-folder nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (read-string (format "Messages%s: "
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (if mh-sent-from-msg
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (format " [%d]" mh-sent-from-msg)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
359 "")))))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
360 (setq mh-mhn-compose-insert-flag t)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (beginning-of-line)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (insert "#forw [")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 (and description
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (not (string= description ""))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (insert description))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (insert "]")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (and folder
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (not (string= folder ""))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (insert " " folder))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
370 (if (and messages
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
371 (not (string= messages "")))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (let ((start (point)))
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
373 (insert " " messages)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (subst-char-in-region start (point) ?, ? ))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (if mh-sent-from-msg
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (insert " " (int-to-string mh-sent-from-msg))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (insert "\n"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
379 (defun mh-edit-mhn (&optional extra-args)
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
380 "Format the current draft for MIME, expanding any mhn directives.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
381
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
382 Process the current draft with the mhn program, which, using directives
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
383 already inserted in the draft, fills in all the MIME components and header
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
384 fields.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
385
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 This step should be done last just before sending the message.
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
387
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
388 The `\\[mh-revert-mhn-edit]' command undoes this command. The arguments in the
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
389 list `mh-mhn-args' are passed to mhn if this function is passed an optional
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
390 prefix argument EXTRA-ARGS.
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
391
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
392 For assistance with creating mhn directives to insert various types of
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
393 components in a message, see \\[mh-mhn-compose-insertion] (generic insertion
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
394 from a file), \\[mh-mhn-compose-anon-ftp] (external reference to file via
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
395 anonymous ftp), \\[mh-mhn-compose-external-compressed-tar] \ \(reference to
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
396 compressed tar file via anonymous ftp), and \\[mh-mhn-compose-forw] (forward
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
397 message). If these helper functions are used, `mh-edit-mhn' is run
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
398 automatically when the draft is sent.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
399
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
400 The value of `mh-edit-mhn-hook' is a list of functions to be called, with no
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
401 arguments, after performing the conversion.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
402
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
403 The mhn program is part of MH version 6.8 or later."
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
404 (interactive "*P")
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (save-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (message "mhn editing...")
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
407 (cond
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
408 (mh-nmh-flag
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
409 (mh-exec-cmd-error nil
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
410 "mhbuild" (if extra-args mh-mhn-args) buffer-file-name))
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
411 (t
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
412 (mh-exec-cmd-error (format "mhdraft=%s" buffer-file-name)
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
413 "mhn" (if extra-args mh-mhn-args) buffer-file-name)))
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
414 (setq mh-mhn-compose-insert-flag nil)
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (revert-buffer t t)
11332
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
416 (message "mhn editing...done")
c9c652970786 New version from author.
Karl Heuer <kwzh@gnu.org>
parents: 6365
diff changeset
417 (run-hooks 'mh-edit-mhn-hook))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (defun mh-revert-mhn-edit (noconfirm)
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
420 "Undo the effect of \\[mh-edit-mhn] by reverting to the backup file.
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
421 Optional non-nil argument NOCONFIRM means don't ask for confirmation."
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (interactive "*P")
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (if (null buffer-file-name)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (error "Buffer does not seem to be associated with any file"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (let ((backup-strings '("," "#"))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 backup-file)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (while (and backup-strings
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (not (file-exists-p
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (setq backup-file
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (concat (file-name-directory buffer-file-name)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (car backup-strings)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (file-name-nondirectory buffer-file-name)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 ".orig")))))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (setq backup-strings (cdr backup-strings)))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (or backup-strings
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
436 (error "Backup file for %s no longer exists!" buffer-file-name))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (or noconfirm
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (yes-or-no-p (format "Revert buffer from file %s? "
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 backup-file))
47730
2568d5a27317 Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents: 38414
diff changeset
440 (error "Revert not confirmed"))
6365
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (let ((buffer-read-only nil))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (erase-buffer)
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (insert-file-contents backup-file))
a1b8926f7ece entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (after-find-file nil)))
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 23305
diff changeset
445
48595
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
446
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
447
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
448 ;;; MIME composition functions
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
449
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
450 (defun mh-mml-to-mime ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
451 "Compose MIME message from mml directives."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
452 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
453 (when mh-gnus-pgp-support-flag ;; This is only needed for PGP
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
454 (message-options-set-recipient))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
455 (mml-to-mime)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
456 (setq mh-mml-compose-insert-flag nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
457
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
458 (defun mh-mml-forward-message (description folder message)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
459 "Forward a message as attachment.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
460 The function will prompt the user for a DESCRIPTION, a FOLDER and MESSAGE
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
461 number."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
462 (let ((msg (if (equal message "")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
463 mh-sent-from-msg
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
464 (car (read-from-string message)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
465 (cond ((integerp msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
466 (if (string= "" description)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
467 ;; Rationale: mml-attach-file constructs a malformed composition
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
468 ;; if the description string is empty. This fixes SF #625168.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
469 (mml-attach-file (format "%s%s/%d"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
470 mh-user-path (substring folder 1) msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
471 "message/rfc822")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
472 (mml-attach-file (format "%s%s/%d"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
473 mh-user-path (substring folder 1) msg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
474 "message/rfc822"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
475 description))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
476 (setq mh-mml-compose-insert-flag t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
477 (t (error "The message number, %s is not a integer!" msg)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
478
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
479 (defun mh-mml-attach-file (&optional disposition)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
480 "Attach a file to the outgoing MIME message.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
481 The file is not inserted or encoded until you send the message with
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
482 `\\[mh-send-letter]'.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
483 Message disposition is \"inline\" or \"attachment\" and is prompted for if
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
484 DISPOSITION is nil.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
485
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
486 This is basically `mml-attach-file' from gnus, modified such that a prefix
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
487 argument yields an `inline' disposition and Content-Type is determined
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
488 automatically."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
489 (let* ((file (mml-minibuffer-read-file "Attach file: "))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
490 (type (or (mh-file-mime-type file)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
491 (completing-read "Content-Type: "
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
492 (if (fboundp 'mailcap-mime-types)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
493 (mapcar 'list (mailcap-mime-types))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
494 mh-mime-content-types))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
495 (description (mml-minibuffer-read-description))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
496 (dispos (or disposition
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
497 (completing-read "Disposition: [attachment] "
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
498 '(("attachment")("inline"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
499 nil t nil nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
500 "attachment"))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
501 (mml-insert-empty-tag 'part 'type type 'filename file
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
502 'disposition dispos 'description description)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
503 (setq mh-mml-compose-insert-flag t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
504
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
505 (defun mh-mml-secure-message-sign-pgpmime ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
506 "Add directive to encrypt/sign the entire message."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
507 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
508 (if (not mh-gnus-pgp-support-flag)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
509 (error "Sorry. Your version of gnus does not support PGP/GPG")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
510 (mml-secure-message-sign-pgpmime)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
511 (setq mh-mml-compose-insert-flag t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
512
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
513 (defun mh-mml-secure-message-encrypt-pgpmime (&optional dontsign)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
514 "Add directive to encrypt and sign the entire message.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
515 If called with a prefix argument DONTSIGN, only encrypt (do NOT sign)."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
516 (interactive "P")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
517 (if (not mh-gnus-pgp-support-flag)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
518 (error "Sorry. Your version of gnus does not support PGP/GPG")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
519 (mml-secure-message-encrypt-pgpmime dontsign)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
520 (setq mh-mml-compose-insert-flag t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
521
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
522
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
523
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
524 ;;; MIME decoding
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
525
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
526 (defcustom mh-graphical-smileys-flag t
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
527 "*Non-nil means graphical smileys are displayed.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
528 Non-nil means that small graphics will be used in the show buffer instead of
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
529 patterns like :-), ;-) etc. The setting only has effect if
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
530 `mh-decode-mime-flag' is non-nil."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
531 :type 'boolean
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
532 :group 'mh-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
533
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
534 (defcustom mh-graphical-emphasis-flag t
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
535 "*Non-nil means graphical emphasis is displayed.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
536 Non-nil means that _underline_ will be underlined, *bold* will appear in bold,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
537 /italic/ will appear in italic etc. See `gnus-emphasis-alist' for the whole
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
538 list. The setting only has effect if `mh-decode-mime-flag' is non-nil."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
539 :type 'boolean
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
540 :group 'mh-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
541
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
542 ;; Small image definition
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
543 (defcustom mh-max-inline-image-width nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
544 "*Maximum inline image width if Content-Disposition is not present.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
545 If nil, image will be displayed if its width is smaller than the width of the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
546 window."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
547 :type '(choice (const nil) integer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
548 :group 'mh-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
549
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
550 (defcustom mh-max-inline-image-height nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
551 "*Maximum inline image height if Content-Disposition is not present.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
552 If nil, image will be displayed if its height is smaller than the height of
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
553 the window."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
554 :type '(choice (const nil) integer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
555 :group 'mh-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
556
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
557 (defcustom mh-display-buttons-for-inline-parts-flag nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
558 "*Non-nil means display buttons for all inline MIME parts.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
559 If non-nil, buttons are displayed for all MIME parts. Inline parts start off
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
560 in displayed state but they can be hidden by clicking the button. If nil no
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
561 buttons are shown for inline parts."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
562 :type 'boolean
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
563 :group 'mh-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
564
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
565 (defcustom mh-mime-save-parts-default-directory t
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
566 "Default directory to use for `mh-mime-save-parts'.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
567 If nil, prompt and set for next time the command is used during same session.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
568 If t, prompt always"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
569 :type '(choice (const :tag "Prompt the first time" nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
570 (const :tag "Prompt always" t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
571 directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
572 :group 'mh)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
573
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
574 (defmacro mh-defun-compat (function arg-list &rest body)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
575 "This is a macro to define functions which are not defined.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
576 It is used for Gnus utility functions which were added recently. If FUNCTION
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
577 is not defined then it is defined to have argument list, ARG-LIST and body,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
578 BODY."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
579 (let ((defined-p (fboundp function)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
580 (unless defined-p
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
581 `(defun ,function ,arg-list ,@body))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
582
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
583 ;; Copy of original function from gnus-util.el
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
584 (mh-defun-compat gnus-local-map-property (map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
585 "Return a list suitable for a text property list specifying keymap MAP."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
586 (cond (mh-xemacs-flag (list 'keymap map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
587 ((>= emacs-major-version 21) (list 'keymap map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
588 (t (list 'local-map map))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
589
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
590 ;; Copy of original function from mm-decode.el
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
591 (mh-defun-compat mm-merge-handles (handles1 handles2)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
592 (append (if (listp (car handles1)) handles1 (list handles1))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
593 (if (listp (car handles2)) handles2 (list handles2))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
594
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
595 ;; Copy of function from mm-decode.el
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
596 (mh-defun-compat mm-set-handle-multipart-parameter (handle parameter value)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
597 ;; HANDLE could be a CTL.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
598 (if handle
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
599 (put-text-property 0 (length (car handle)) parameter value
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
600 (car handle))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
601
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
602 ;; Copy of original macro is in mm-decode.el
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
603 (mh-defun-compat mm-handle-multipart-ctl-parameter (handle parameter)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
604 (get-text-property 0 parameter (car handle)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
605
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
606 ;; Copy of original function in mm-decode.el
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
607 (mh-defun-compat mm-readable-p (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
608 "Say whether the content of HANDLE is readable."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
609 (and (< (with-current-buffer (mm-handle-buffer handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
610 (buffer-size)) 10000)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
611 (mm-with-unibyte-buffer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
612 (mm-insert-part handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
613 (and (eq (mm-body-7-or-8) '7bit)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
614 (not (mm-long-lines-p 76))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
615
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
616 ;; Copy of original function in mm-bodies.el
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
617 (mh-defun-compat mm-long-lines-p (length)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
618 "Say whether any of the lines in the buffer is longer than LINES."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
619 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
620 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
621 (end-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
622 (while (and (not (eobp))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
623 (not (> (current-column) length)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
624 (forward-line 1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
625 (end-of-line))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
626 (and (> (current-column) length)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
627 (current-column))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
628
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
629 (mh-defun-compat mm-keep-viewer-alive-p (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
630 ;; Released Gnus doesn't keep handles associated with externally displayed
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
631 ;; MIME parts. So this will always return nil.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
632 nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
633
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
634 (mh-defun-compat mm-destroy-parts (list)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
635 "Older emacs don't have this function."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
636 nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
637
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
638 ;;; This is mm-save-part from gnus 5.10 since that function in emacs21.2 is
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
639 ;;; buggy (the args to read-file-name are incorrect). When all supported
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
640 ;;; versions of Emacs come with at least Gnus 5.10, we can delete this
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
641 ;;; function and rename calls to mh-mm-save-part to mm-save-part.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
642 (defun mh-mm-save-part (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
643 "Write HANDLE to a file."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
644 (let ((name (mail-content-type-get (mm-handle-type handle) 'name))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
645 (filename (mail-content-type-get
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
646 (mm-handle-disposition handle) 'filename))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
647 file)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
648 (when filename
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
649 (setq filename (file-name-nondirectory filename)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
650 (setq file (read-file-name "Save MIME part to: "
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
651 (or mm-default-directory
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
652 default-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
653 nil nil (or filename name "")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
654 (setq mm-default-directory (file-name-directory file))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
655 (and (or (not (file-exists-p file))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
656 (yes-or-no-p (format "File %s already exists; overwrite? "
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
657 file)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
658 (mm-save-part-to-file handle file))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
659
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
660
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
661
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
662 ;;; MIME cleanup
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
663
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
664 (defun mh-mime-cleanup ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
665 "Free the decoded MIME parts."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
666 (let ((mime-data (gethash (current-buffer) mh-globals-hash)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
667 ;; This is for Emacs, what about XEmacs?
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
668 (cond ((fboundp 'remove-images)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
669 (remove-images (point-min) (point-max))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
670 (when mime-data
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
671 (mm-destroy-parts (mh-mime-handles mime-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
672 (remhash (current-buffer) mh-globals-hash))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
673
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
674 (defun mh-destroy-postponed-handles ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
675 "Free MIME data for externally displayed mime parts."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
676 (let ((mime-data (mh-buffer-data)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
677 (when mime-data
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
678 (mm-destroy-parts (mh-mime-handles mime-data)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
679 (remhash (current-buffer) mh-globals-hash)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
680
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
681 (defun mh-handle-set-external-undisplayer (folder handle function)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
682 "Replacement for `mm-handle-set-external-undisplayer'.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
683 This is only called in recent versions of Gnus. The MIME handles are stored
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
684 in data structures corresponding to MH-E folder buffer FOLDER instead of in
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
685 Gnus (as in the original). The MIME part, HANDLE is associated with the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
686 undisplayer FUNCTION."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
687 (if (mm-keep-viewer-alive-p handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
688 (let ((new-handle (copy-sequence handle)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
689 (mm-handle-set-undisplayer new-handle function)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
690 (mm-handle-set-undisplayer handle nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
691 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
692 (set-buffer folder)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
693 (push new-handle (mh-mime-handles (mh-buffer-data)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
694 (mm-handle-set-undisplayer handle function)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
695
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
696
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
697
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
698 ;;; MIME transformations
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
699
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
700 (defun mh-add-missing-mime-version-header ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
701 "Some mail programs don't put a MIME-Version header.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
702 I have seen this only in spam, so maybe we shouldn't fix this ;-)"
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
703 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
704 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
705 (when (and (message-fetch-field "content-type")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
706 (not (message-fetch-field "mime-version")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
707 (when (search-forward "\n\n" nil t)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
708 (forward-line -1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
709 (insert "MIME-Version: 1.0\n")))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
710
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
711 (defun mh-display-smileys ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
712 "Function to display smileys."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
713 (when (and mh-graphical-smileys-flag (fboundp 'smiley-region))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
714 (smiley-region (point-min) (point-max))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
715
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
716 (defun mh-display-emphasis ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
717 "Function to display graphical emphasis."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
718 (when mh-graphical-emphasis-flag
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
719 (flet ((article-goto-body ())) ; shadow this function to do nothing
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
720 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
721 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
722 (article-emphasize)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
723
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
724 ;; Copied from gnus-art.el (should be checked for other cool things that can
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
725 ;; be added to the buttons)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
726 (defvar mh-mime-button-commands
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
727 '((mh-press-button "\r" "Toggle Display")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
728 (defvar mh-mime-button-map
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
729 (let ((map (make-sparse-keymap)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
730 (unless (>= (string-to-number emacs-version) 21)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
731 ;; XEmacs doesn't care.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
732 (set-keymap-parent map mh-show-mode-map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
733 (define-key map [mouse-2] 'mh-push-button)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
734 (dolist (c mh-mime-button-commands)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
735 (define-key map (cadr c) (car c)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
736 map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
737 (defvar mh-mime-button-line-format-alist
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
738 '((?T long-type ?s)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
739 (?d description ?s)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
740 (?p index ?s)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
741 (?e dots ?s)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
742 (defvar mh-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
743 (defvar mh-mime-security-button-pressed nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
744 (defvar mh-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
745 (defvar mh-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
746 (defvar mh-mime-security-button-line-format-alist
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
747 '((?t type ?s)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
748 (?i info ?s)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
749 (?d details ?s)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
750 (?D pressed-details ?s)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
751 (defvar mh-mime-security-button-map
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
752 (let ((map (make-sparse-keymap)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
753 (unless (>= (string-to-number emacs-version) 21)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
754 (set-keymap-parent map mh-show-mode-map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
755 (define-key map "\r" 'mh-press-button)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
756 (define-key map [mouse-2] 'mh-push-button)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
757 map))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
758
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
759 (defvar mh-mime-save-parts-directory nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
760 "Default to use for `mh-mime-save-parts-default-directory'.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
761 Set from last use.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
762
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
763 (defun mh-mime-save-parts (arg)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
764 "Store the MIME parts of the current message.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
765 If ARG, prompt for directory, else use that specified by the variable
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
766 `mh-mime-save-parts-default-directory'. These directories may be superseded by
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
767 mh_profile directives, since this function calls on mhstore or mhn to do the
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
768 actual storing."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
769 (interactive "P")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
770 (let ((msg (if (eq major-mode 'mh-show-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
771 (mh-show-buffer-message-number)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
772 (mh-get-msg-num t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
773 (folder (if (eq major-mode 'mh-show-mode)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
774 mh-show-folder-buffer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
775 mh-current-folder))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
776 (command (if mh-nmh-flag "mhstore" "mhn"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
777 (directory
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
778 (cond
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
779 ((and (or arg
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
780 (equal nil mh-mime-save-parts-default-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
781 (equal t mh-mime-save-parts-default-directory))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
782 (not mh-mime-save-parts-directory))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
783 (read-file-name "Store in what directory? " nil nil t nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
784 ((and (or arg
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
785 (equal t mh-mime-save-parts-default-directory))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
786 mh-mime-save-parts-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
787 (read-file-name (format
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
788 "Store in what directory? [%s] "
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
789 mh-mime-save-parts-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
790 "" mh-mime-save-parts-directory t ""))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
791 ((stringp mh-mime-save-parts-default-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
792 mh-mime-save-parts-default-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
793 (t
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
794 mh-mime-save-parts-directory))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
795 (if (and (equal directory "") mh-mime-save-parts-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
796 (setq directory mh-mime-save-parts-directory))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
797 (if (not (file-directory-p directory))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
798 (message "No directory specified.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
799 (if (equal nil mh-mime-save-parts-default-directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
800 (setq mh-mime-save-parts-directory directory))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
801 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
802 (set-buffer (get-buffer-create " *mh-store*"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
803 (cd directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
804 (setq mh-mime-save-parts-directory directory)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
805 (erase-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
806 (apply 'call-process
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
807 (expand-file-name command mh-progs) nil t nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
808 (mh-list-to-string (list folder msg "-auto")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
809 (if (> (buffer-size) 0)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
810 (save-window-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
811 (switch-to-buffer-other-window " *mh-store*")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
812 (sit-for 3)))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
813
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
814 ;; Avoid errors if gnus-sum isn't loaded yet...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
815 (defvar gnus-newsgroup-charset nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
816 (defvar gnus-newsgroup-name nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
817
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
818 (defun mh-mime-display (&optional pre-dissected-handles)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
819 "Display (and possibly decode) MIME handles.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
820 Optional argument, PRE-DISSECTED-HANDLES is a list of MIME handles. If
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
821 present they are displayed otherwise the buffer is parsed and then
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
822 displayed."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
823 (let ((handles ())
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
824 (folder mh-show-folder-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
825 (flet ((mm-handle-set-external-undisplayer (handle function)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
826 (mh-handle-set-external-undisplayer folder handle function)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
827 ;; If needed dissect the current buffer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
828 (if pre-dissected-handles
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
829 (setq handles pre-dissected-handles)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
830 (setq handles (or (mm-dissect-buffer nil) (mm-uu-dissect)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
831 (setf (mh-mime-handles (mh-buffer-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
832 (mm-merge-handles handles (mh-mime-handles (mh-buffer-data)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
833
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
834 (when (and handles (or (not (stringp (car handles))) (cdr handles)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
835 ;; Goto start of message body
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
836 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
837 (or (search-forward "\n\n" nil t) (goto-char (point-max)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
838
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
839 ;; Delete the body
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
840 (delete-region (point) (point-max))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
841
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
842 ;; Display the MIME handles
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
843 (mh-mime-display-part handles)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
844
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
845 (defun mh-mime-display-part (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
846 "Decides the viewer to call based on the type of HANDLE."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
847 (cond ((null handle) nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
848 ((not (stringp (car handle)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
849 (mh-mime-display-single handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
850 ((equal (car handle) "multipart/alternative")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
851 (mh-mime-display-alternative (cdr handle)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
852 ((and mh-gnus-pgp-support-flag
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
853 (or (equal (car handle) "multipart/signed")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
854 (equal (car handle) "multipart/encrypted")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
855 (mh-mime-display-security handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
856 (t (mh-mime-display-mixed (cdr handle)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
857
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
858 (defun mh-mime-display-alternative (handles)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
859 "Choose among the alternatives, HANDLES the part that will be displayed.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
860 If no part is preferred then all the parts are displayed."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
861 (let ((preferred (mm-preferred-alternative handles)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
862 (cond ((and preferred (stringp (car preferred)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
863 (mh-mime-display-part preferred))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
864 (preferred
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
865 (save-restriction
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
866 (narrow-to-region (point) (if (eobp) (point) (1+ (point))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
867 (or (mm-display-part preferred) (mm-display-part preferred))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
868 (goto-char (point-max))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
869 (t (mh-mime-display-mixed handles)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
870
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
871 (defun mh-mime-display-mixed (handles)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
872 "Display the list of MIME parts, HANDLES recursively."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
873 (mapcar #'mh-mime-display-part handles))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
874
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
875 (defun mh-mime-part-index (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
876 "Generate the button number for MIME part, HANDLE.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
877 Notice that a hash table is used to display the same number when buttons need
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
878 to be displayed multiple times (for instance when nested messages are
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
879 opened)."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
880 (or (gethash handle (mh-mime-part-index-hash (mh-buffer-data)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
881 (setf (gethash handle (mh-mime-part-index-hash (mh-buffer-data)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
882 (incf (mh-mime-parts-count (mh-buffer-data))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
883
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
884 ;;; Avoid compiler warnings for XEmacs functions...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
885 (eval-when (compile)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
886 (loop for function in '(glyph-width window-pixel-width
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
887 glyph-height window-pixel-height)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
888 do (or (fboundp function) (defalias function 'ignore))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
889
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
890 (defun mh-small-image-p (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
891 "Decide whether HANDLE is a \"small\" image that can be displayed inline.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
892 This is only useful if a Content-Disposition header is not present."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
893 (let ((media-test (caddr (assoc (car (mm-handle-type handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
894 mh-mm-inline-media-tests)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
895 (mm-inline-large-images t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
896 (and media-test
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
897 (equal (mm-handle-media-supertype handle) "image")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
898 (funcall media-test handle) ; Since mm-inline-large-images is T,
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
899 ; this only tells us if the image is
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
900 ; something that emacs can display
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
901 (let* ((image (mm-get-image handle)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
902 (cond ((fboundp 'glyph-width)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
903 ;; XEmacs -- totally untested, copied from gnus
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
904 (and (< (glyph-width image)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
905 (or mh-max-inline-image-width
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
906 (window-pixel-width)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
907 (< (glyph-height image)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
908 (or mh-max-inline-image-height
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
909 (window-pixel-height)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
910 ((fboundp 'image-size)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
911 ;; Emacs21 -- copied from gnus
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
912 (let ((size (image-size image)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
913 (and (< (cdr size)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
914 (or mh-max-inline-image-height
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
915 (1- (window-height))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
916 (< (car size)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
917 (or mh-max-inline-image-width (window-width))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
918 (t
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
919 ;; Can't show image inline
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
920 nil))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
921
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
922 (defun mh-mime-display-single (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
923 "Display a leaf node, HANDLE in the MIME tree."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
924 (let* ((type (mm-handle-media-type handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
925 (small-image-flag (mh-small-image-p handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
926 (attachmentp (equal (car (mm-handle-disposition handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
927 "attachment"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
928 (inlinep (and (equal (car (mm-handle-disposition handle)) "inline")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
929 (mm-inlinable-p handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
930 (mm-inlined-p handle)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
931 (displayp (or inlinep ; display if inline
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
932 (and (not attachmentp) ; if it is not an attachment
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
933 (or small-image-flag ; display if small image
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
934 ; or if user wants inline.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
935 (and (not (equal
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
936 (mm-handle-media-supertype handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
937 "image"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
938 (mm-inlinable-p handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
939 (mm-inlined-p handle)))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
940 (save-restriction
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
941 (narrow-to-region (point) (if (eobp) (point) (1+ (point))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
942 (cond ((and mh-gnus-pgp-support-flag
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
943 (equal type "application/pgp-signature"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
944 nil) ; skip signatures as they are already handled...
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
945 ((not displayp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
946 (insert "\n")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
947 (mh-insert-mime-button handle (mh-mime-part-index handle) nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
948 ((and displayp (not mh-display-buttons-for-inline-parts-flag))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
949 (or (mm-display-part handle) (mm-display-part handle)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
950 ((and displayp mh-display-buttons-for-inline-parts-flag)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
951 (insert "\n")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
952 (mh-insert-mime-button handle (mh-mime-part-index handle) nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
953 (forward-line -1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
954 (mh-mm-display-part handle)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
955 (goto-char (point-max)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
956
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
957 (defun mh-insert-mime-button (handle index displayed)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
958 "Insert MIME button for HANDLE.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
959 INDEX is the part number that will be DISPLAYED. It is also used by commands
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
960 like \"K v\" which operate on individual MIME parts."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
961 ;; The button could be displayed by a previous decode. In that case
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
962 ;; undisplay it if we need a hidden button.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
963 (when (and (mm-handle-displayed-p handle) (not displayed))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
964 (mm-display-part handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
965 (let ((name (or (mail-content-type-get (mm-handle-type handle) 'name)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
966 (mail-content-type-get (mm-handle-disposition handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
967 'filename)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
968 (mail-content-type-get (mm-handle-type handle) 'url)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
969 ""))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
970 (type (mm-handle-media-type handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
971 (description (mail-decode-encoded-word-string
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
972 (or (mm-handle-description handle) "")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
973 (dots (if (or displayed (mm-handle-displayed-p handle)) " " "..."))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
974 long-type begin end)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
975 (if (string-match ".*/" name) (setq name (substring name (match-end 0))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
976 (setq long-type (concat type (and (not (equal name ""))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
977 (concat "; " name))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
978 (unless (equal description "")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
979 (setq long-type (concat " --- " long-type)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
980 (unless (bolp) (insert "\n"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
981 (setq begin (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
982 (gnus-eval-format
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
983 mh-mime-button-line-format mh-mime-button-line-format-alist
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
984 `(,@(gnus-local-map-property mh-mime-button-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
985 mh-callback mh-mm-display-part
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
986 mh-part ,index
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
987 mh-data ,handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
988 (setq end (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
989 (widget-convert-button
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
990 'link begin end
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
991 :mime-handle handle
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
992 :action 'mh-widget-press-button
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
993 :button-keymap mh-mime-button-map
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
994 :help-echo
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
995 "Mouse-2 click or press RET (in show buffer) to toggle display")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
996
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
997 ;; There is a bug in Gnus inline image display due to which an extra line
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
998 ;; gets inserted every time it is viewed. To work around that problem we are
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
999 ;; using an extra property 'mh-region to remember the region that is added
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1000 ;; when the button is clicked. The region is then deleted to make sure that
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1001 ;; no extra lines get inserted.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1002 (defun mh-mm-display-part (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1003 "Toggle display of button for MIME part, HANDLE."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1004 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1005 (let ((id (get-text-property (point) 'mh-part))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1006 (point (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1007 (window (selected-window))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1008 (mail-parse-charset 'nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1009 (mail-parse-ignored-charsets nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1010 region buffer-read-only)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1011 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1012 (unwind-protect
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1013 (let ((win (get-buffer-window (current-buffer) t)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1014 (when win
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1015 (select-window win))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1016 (goto-char point)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1017
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1018 (if (mm-handle-displayed-p handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1019 ;; This will remove the part.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1020 (progn
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1021 ;; Delete the button and displayed part (if any)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1022 (let ((region (get-text-property point 'mh-region)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1023 (when region
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1024 (when (fboundp 'remove-images)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1025 (remove-images (car region) (cdr region))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1026 (mm-display-part handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1027 (when region
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1028 (delete-region (car region) (cdr region))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1029 ;; Delete button (if it still remains). This happens for
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1030 ;; externally displayed parts where the previous step does
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1031 ;; nothing.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1032 (unless (eolp)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1033 (delete-region (point) (progn (forward-line) (point)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1034 (save-restriction
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1035 (delete-region (point) (progn (forward-line 1) (point)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1036 (narrow-to-region (point) (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1037 ;; Maybe we need another unwind-protect here.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1038 (when (equal (mm-handle-media-supertype handle) "image")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1039 (insert "\n"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1040 (when (and (not (eq (ignore-errors (mm-display-part handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1041 'inline))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1042 (equal (mm-handle-media-supertype handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1043 "image"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1044 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1045 (delete-char 1))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1046 (when (equal (mm-handle-media-supertype handle) "text")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1047 (when (eq mh-highlight-citation-p 'gnus)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1048 (mh-gnus-article-highlight-citation))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1049 (mh-display-smileys)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1050 (mh-display-emphasis))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1051 (setq region (cons (progn (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1052 (point-marker))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1053 (progn (goto-char (point-max))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1054 (point-marker)))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1055 (when (window-live-p window)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1056 (select-window window))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1057 (goto-char point)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1058 (beginning-of-line)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1059 (mh-insert-mime-button handle id (mm-handle-displayed-p handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1060 (goto-char point)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1061 (when region
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1062 (add-text-properties (line-beginning-position) (line-end-position)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1063 `(mh-region ,region)))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1064
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1065 (defun mh-press-button ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1066 "Press MIME button.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1067 If the MIME part is visible then it is removed. Otherwise the part is
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1068 displayed."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1069 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1070 (let ((mm-inline-media-tests mh-mm-inline-media-tests)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1071 (data (get-text-property (point) 'mh-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1072 (function (get-text-property (point) 'mh-callback))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1073 (buffer-read-only nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1074 (folder mh-show-folder-buffer))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1075 (flet ((mm-handle-set-external-undisplayer (handle function)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1076 (mh-handle-set-external-undisplayer folder handle function)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1077 (when (and function (eolp))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1078 (backward-char))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1079 (unwind-protect (and function (funcall function data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1080 (set-buffer-modified-p nil)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1081
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1082 (defun mh-push-button (event)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1083 "Click MIME button for EVENT.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1084 If the MIME part is visible then it is removed. Otherwise the part is
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1085 displayed. This function is called when the mouse is used to click the MIME
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1086 button."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1087 (interactive "e")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1088 (set-buffer (window-buffer (posn-window (event-start event))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1089 (select-window (posn-window (event-start event)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1090 (let* ((pos (posn-point (event-start event)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1091 (folder mh-show-folder-buffer)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1092 (mm-inline-media-tests mh-mm-inline-media-tests)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1093 (data (get-text-property pos 'mh-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1094 (function (get-text-property pos 'mh-callback))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1095 (buffer-read-only nil))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1096 (flet ((mm-handle-set-external-undisplayer (handle function)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1097 (mh-handle-set-external-undisplayer folder handle function)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1098 (goto-char pos)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1099 (unwind-protect (and function (funcall function data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1100 (set-buffer-modified-p nil)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1101
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1102 (defun mh-mime-save-part ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1103 "Save MIME part at point."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1104 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1105 (let ((data (get-text-property (point) 'mh-data)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1106 (when data
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1107 (let ((mm-default-directory mh-mime-save-parts-directory))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1108 (mh-mm-save-part data)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1109 (setq mh-mime-save-parts-directory mm-default-directory)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1110
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1111 (defun mh-mime-inline-part ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1112 "Toggle display of the raw MIME part."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1113 (interactive)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1114 (let* ((buffer-read-only nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1115 (data (get-text-property (point) 'mh-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1116 (inserted-flag (get-text-property (point) 'mh-mime-inserted))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1117 (displayed-flag (mm-handle-displayed-p data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1118 (point (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1119 start end)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1120 (cond ((and data (not inserted-flag) (not displayed-flag))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1121 (let ((contents (mm-get-part data)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1122 (add-text-properties (line-beginning-position) (line-end-position)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1123 '(mh-mime-inserted t))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1124 (setq start (point-marker))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1125 (forward-line 1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1126 (mm-insert-inline data contents)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1127 (setq end (point-marker))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1128 (add-text-properties
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1129 start (progn (goto-char start) (line-end-position))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1130 `(mh-region (,start . ,end)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1131 ((and data (or inserted-flag displayed-flag))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1132 (mh-press-button)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1133 (message "MIME part already inserted")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1134 (goto-char point)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1135 (set-buffer-modified-p nil)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1136
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1137 (defun mh-widget-press-button (widget el)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1138 "Callback for widget, WIDGET.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1139 Parameter EL is unused."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1140 (goto-char (widget-get widget :from))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1141 (mh-press-button))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1142
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1143 (defun mh-mime-display-security (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1144 "Display PGP encrypted/signed message, HANDLE."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1145 (insert "\n")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1146 (save-restriction
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1147 (narrow-to-region (point) (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1148 (mh-insert-mime-security-button handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1149 (mh-mime-display-mixed (cdr handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1150 (insert "\n")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1151 (let ((mh-mime-security-button-line-format
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1152 mh-mime-security-button-end-line-format))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1153 (mh-insert-mime-security-button handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1154 (mm-set-handle-multipart-parameter
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1155 handle 'mh-region
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1156 (cons (set-marker (make-marker) (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1157 (set-marker (make-marker) (point-max))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1158
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1159 ;;; I rewrote the security part because Gnus doesn't seem to ever minimize
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1160 ;;; the button. That is once the mime-security button is pressed there seems
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1161 ;;; to be no way of getting rid of the inserted text.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1162 (defun mh-mime-security-show-details (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1163 "Toggle display of detailed security info for HANDLE."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1164 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1165 (when details
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1166 (let ((mh-mime-security-button-pressed
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1167 (not (get-text-property (point) 'mh-button-pressed)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1168 (mh-mime-security-button-line-format
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1169 (get-text-property (point) 'mh-line-format)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1170 (forward-char -1)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1171 (while (eq (get-text-property (point) 'mh-line-format)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1172 mh-mime-security-button-line-format)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1173 (forward-char -1))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1174 (forward-char)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1175 (save-restriction
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1176 (narrow-to-region (point) (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1177 (mh-insert-mime-security-button handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1178 (delete-region
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1179 (point)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1180 (or (text-property-not-all
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1181 (point) (point-max)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1182 'mh-line-format mh-mime-security-button-line-format)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1183 (point-max)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1184 (forward-line -1)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1185
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1186 (defun mh-mime-security-press-button (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1187 "Callback from security button for part HANDLE."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1188 (when (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1189 (mh-mime-security-show-details handle)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1190
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1191 ;; These variables should already be initialized in mm-decode.el if we have a
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1192 ;; recent enough Gnus. The defvars are here to avoid compiler warnings.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1193 (defvar mm-verify-function-alist nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1194 (defvar mm-decrypt-function-alist nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1195
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1196 (defvar pressed-details)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1197
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1198 (defun mh-insert-mime-security-button (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1199 "Display buttons for PGP message, HANDLE."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1200 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1201 (crypto-type (or (nth 2 (assoc protocol mm-verify-function-alist))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1202 (nth 2 (assoc protocol mm-decrypt-function-alist))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1203 "Unknown"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1204 (type (concat crypto-type
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1205 (if (equal (car handle) "multipart/signed")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1206 " Signed" " Encrypted")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1207 " Part"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1208 (info (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1209 "Undecided"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1210 (details (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1211 pressed-details begin end)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1212 (setq details (if details (concat "\n" details) ""))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1213 (setq pressed-details (if mh-mime-security-button-pressed details ""))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1214 (unless (bolp) (insert "\n"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1215 (setq begin (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1216 (gnus-eval-format
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1217 mh-mime-security-button-line-format
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1218 mh-mime-security-button-line-format-alist
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1219 `(,@(gnus-local-map-property mh-mime-security-button-map)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1220 mh-button-pressed ,mh-mime-security-button-pressed
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1221 mh-callback mh-mime-security-press-button
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1222 mh-line-format ,mh-mime-security-button-line-format
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1223 mh-data ,handle))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1224 (setq end (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1225 (widget-convert-button 'link begin end
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1226 :mime-handle handle
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1227 :action 'mh-widget-press-button
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1228 :button-keymap mh-mime-security-button-map
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1229 :help-echo "Mouse-2 click or press RET (in show buffer) to see security details.")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1230 (when (equal info "Failed")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1231 (let* ((type (if (equal (car handle) "multipart/signed")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1232 "verification" "decryption"))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1233 (warning (if (equal type "decryption")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1234 "(passphrase may be incorrect)" "")))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1235 (message "%s %s failed %s" crypto-type type warning)))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1236
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1237 (defun mh-mm-inline-message (handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1238 "Display message, HANDLE.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1239 The function decodes the message and displays it. It avoids decoding the same
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1240 message multiple times."
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1241 (let ((b (point))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1242 (charset (mail-content-type-get (mm-handle-type handle) 'charset))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1243 (clean-message-header mh-clean-message-header-flag)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1244 (invisible-headers mh-invisible-headers)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1245 (visible-headers mh-visible-headers))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1246 (when (and charset (stringp charset))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1247 (setq charset (intern (downcase charset)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1248 (when (eq charset 'us-ascii)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1249 (setq charset nil)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1250 (save-excursion
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1251 (save-restriction
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1252 (narrow-to-region b b)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1253 (mm-insert-part handle)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1254 (mh-mime-display
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1255 (or (gethash handle (mh-mime-handles-cache (mh-buffer-data)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1256 (setf (gethash handle (mh-mime-handles-cache (mh-buffer-data)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1257 (let ((handles (or (mm-dissect-buffer nil)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1258 (mm-uu-dissect))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1259 (setf (mh-mime-handles (mh-buffer-data))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1260 (mm-merge-handles
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1261 handles (mh-mime-handles (mh-buffer-data))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1262 handles))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1263
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1264 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1265 (cond (clean-message-header
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1266 (mh-clean-msg-header (point-min)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1267 invisible-headers
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1268 visible-headers)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1269 (goto-char (point-min)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1270 (t
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1271 (mh-start-of-uncleaned-message)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1272 (mh-show-xface)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1273 (mh-show-addr)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1274 ;; The other highlighting types don't need anything special
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1275 (when (eq mh-highlight-citation-p 'gnus)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1276 (mh-gnus-article-highlight-citation))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1277 (goto-char (point-min))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1278 (insert "\n------- Forwarded Message\n\n")
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1279 (mh-display-smileys)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1280 (mh-display-emphasis)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1281 (mm-handle-set-undisplayer
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1282 handle
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1283 `(lambda ()
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1284 (let (buffer-read-only)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1285 (if (fboundp 'remove-specifier)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1286 ;; This is only valid on XEmacs.
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1287 (mapcar (lambda (prop)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1288 (remove-specifier
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1289 (face-property 'default prop) (current-buffer)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1290 '(background background-pixmap foreground)))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1291 (delete-region ,(point-min-marker) ,(point-max-marker)))))))))
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1292
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1293 (provide 'mh-mime)
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1294
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1295 ;;; Local Variables:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1296 ;;; sentence-end-double-space: nil
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1297 ;;; End:
8aaba207e44b Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents: 47730
diff changeset
1298
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 23305
diff changeset
1299 ;;; mh-mime.el ends here