comparison lisp/mail/mh-mime.el @ 11332:c9c652970786

New version from author.
author Karl Heuer <kwzh@gnu.org>
date Sun, 09 Apr 1995 22:31:08 +0000
parents a1b8926f7ece
children 53174cfc29fa
comparison
equal deleted inserted replaced
11331:730a7c669a73 11332:c9c652970786
1 ;;; mh-mime --- mh-e support for composing MIME messages 1 ;;; mh-mime --- mh-e support for composing MIME messages
2 ;; Time-stamp: <94/03/08 08:41:27 gildea> 2 ;; Time-stamp: <94/11/18 17:48:19 gildea>
3 3
4 ;; Copyright 1993 Free Software Foundation, Inc. 4 ;; Copyright (C) 1993, 1995 Free Software Foundation, Inc.
5 5
6 ;; This file is part of mh-e. 6 ;; This file is part of mh-e.
7 7
8 ;; mh-e is free software; you can redistribute it and/or modify 8 ;; mh-e is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by 9 ;; it under the terms of the GNU General Public License as published by
22 ;;; Commentary: 22 ;;; Commentary:
23 23
24 ;;; Internal support for mh-e package. 24 ;;; Internal support for mh-e package.
25 ;;; Support for generating an mhn composition file. 25 ;;; Support for generating an mhn composition file.
26 ;;; MIME is supported only by MH 6.8 or later. 26 ;;; MIME is supported only by MH 6.8 or later.
27
28 ;;; Change Log:
29
30 ;; $Id: mh-mime.el,v 1.5 94/12/27 22:38:10 gildea Exp $
27 31
28 ;;; Code: 32 ;;; Code:
29 33
30 (provide 'mh-mime) 34 (provide 'mh-mime)
31 (require 'mh-comp) 35 (require 'mh-comp)
37 ;; invokes mh-edit-mhn automatically before sending.) 41 ;; invokes mh-edit-mhn automatically before sending.)
38 ;; actually, instead of mh-auto-edit-mhn, 42 ;; actually, instead of mh-auto-edit-mhn,
39 ;; should read automhnproc from profile 43 ;; should read automhnproc from profile
40 ;; MIME option to mh-forward 44 ;; MIME option to mh-forward
41 ;; command to move to content-description insertion point 45 ;; command to move to content-description insertion point
46
47 (defvar mh-mhn-args nil
48 "Extra arguments to have \\[mh-edit-mhn] pass to the \"mhn\" command.
49 The arguments are passed to mhn if \\[mh-edit-mhn] is given a
50 prefix argument. Normally default arguments to mhn are specified in the
51 MH profile.")
52
53 (defvar mh-edit-mhn-hook nil
54 "Invoked on the formatted letter by \\<mh-letter-mode-map>\\[mh-edit-mhn].")
42 55
43 (defvar mh-mime-content-types 56 (defvar mh-mime-content-types
44 '(("text/plain") ("text/richtext") 57 '(("text/plain") ("text/richtext")
45 ("multipart/mixed") ("multipart/alternative") ("multipart/digest") 58 ("multipart/mixed") ("multipart/alternative") ("multipart/digest")
46 ("multipart/parallel") 59 ("multipart/parallel")
52 "Legal MIME content types.") 65 "Legal MIME content types.")
53 66
54 (defun mh-mhn-compose-insertion (pathname type description) 67 (defun mh-mhn-compose-insertion (pathname type description)
55 "Add a directive to insert a message part from a file. 68 "Add a directive to insert a message part from a file.
56 This is the typical way to insert non-text parts in a message. 69 This is the typical way to insert non-text parts in a message.
57 See also \\[mh-edit-mhn]." 70 Arguments are PATHNAME, which tells where to find the file, TYPE, the
71 MIME content type, and DESCRIPTION, a line of text for the
72 Content-description header. See also \\[mh-edit-mhn]."
58 (interactive (list 73 (interactive (list
59 (read-file-name "Insert contents of: ") 74 (read-file-name "Insert contents of: ")
60 (completing-read "Content-type: " 75 (completing-read "Content-type: "
61 mh-mime-content-types nil nil nil) 76 mh-mime-content-types nil nil nil)
62 (read-string "Content-description: "))) 77 (read-string "Content-description: ")))
77 (insert "\n")) 92 (insert "\n"))
78 93
79 94
80 (defun mh-mhn-compose-anon-ftp (host pathname type description) 95 (defun mh-mhn-compose-anon-ftp (host pathname type description)
81 "Add a directive for an anonymous ftp external body part. 96 "Add a directive for an anonymous ftp external body part.
82 This directive tells MH to include a reference to a message/external-body part 97 This directive tells MH to include a reference to a
83 retrievable by anonymous FTP. See also \\[mh-edit-mhn]." 98 message/external-body part retrievable by anonymous FTP. Arguments
99 are HOST and PATHNAME, which tell where to find the file, TYPE, the
100 MIME content type, and DESCRIPTION, a line of text for the
101 Content-description header. See also \\[mh-edit-mhn]."
84 (interactive (list 102 (interactive (list
85 (read-string "Remote host: ") 103 (read-string "Remote host: ")
86 (read-string "Remote pathname: ") 104 (read-string "Remote pathname: ")
87 (completing-read "External Content-type: " 105 (completing-read "External Content-type: "
88 mh-mime-content-types nil nil nil) 106 mh-mime-content-types nil nil nil)
90 (mh-mhn-compose-external-type "anon-ftp" host pathname 108 (mh-mhn-compose-external-type "anon-ftp" host pathname
91 type description)) 109 type description))
92 110
93 (defun mh-mhn-compose-external-compressed-tar (host pathname description) 111 (defun mh-mhn-compose-external-compressed-tar (host pathname description)
94 "Add a directive to include a reference to a compressed tar file. 112 "Add a directive to include a reference to a compressed tar file.
95 The file should be available via anonymous ftp. 113 The file should be available via anonymous ftp. This directive
96 This directive tells MH to include a reference to a message/external-body part. 114 tells MH to include a reference to a message/external-body part.
115 Arguments are HOST and PATHNAME, which tell where to find the file, and
116 DESCRIPTION, a line of text for the Content-description header.
97 See also \\[mh-edit-mhn]." 117 See also \\[mh-edit-mhn]."
98 (interactive (list 118 (interactive (list
99 (read-string "Remote host: ") 119 (read-string "Remote host: ")
100 (read-string "Remote pathname: ") 120 (read-string "Remote pathname: ")
101 (read-string "Tar file Content-description: "))) 121 (read-string "Tar file Content-description: ")))
125 (insert "; directory=\"" (file-name-directory pathname) "\"") 145 (insert "; directory=\"" (file-name-directory pathname) "\"")
126 (and extra-params 146 (and extra-params
127 (insert "; " extra-params)) 147 (insert "; " extra-params))
128 (insert "\n")) 148 (insert "\n"))
129 149
130 (defun mh-mhn-compose-forw (&optional description msgs folder) 150 (defun mh-mhn-compose-forw (&optional description folder messages)
131 "Add a forw directive to this message. 151 "Add a forw directive to this message.
132 This directive tells MH to include the named messages in this one. 152 This directive tells MH to include the named messages in this one.
133 Arguments are DESCRIPTION, a line of text for the Content-description header, 153 Arguments are DESCRIPTION, a line of text for the Content-description header,
134 MESSAGES and FOLDER, which name the message(s) to be forwarded. 154 FOLDER and MESSAGES, which name the message(s) to be forwarded.
135 See also \\[mh-edit-mhn]." 155 See also \\[mh-edit-mhn]."
136 (interactive (list 156 (interactive (list
137 (read-string "Forw Content-description: ") 157 (read-string "Forw Content-description: ")
158 (mh-prompt-for-folder "Message from" mh-sent-from-folder nil)
138 (read-string (format "Messages%s: " 159 (read-string (format "Messages%s: "
139 (if mh-sent-from-msg 160 (if mh-sent-from-msg
140 (format " [%d]" mh-sent-from-msg) 161 (format " [%d]" mh-sent-from-msg)
141 ""))) 162 "")))))
142 (mh-prompt-for-folder "Message from" mh-sent-from-folder nil)))
143 (beginning-of-line) 163 (beginning-of-line)
144 (insert "#forw [") 164 (insert "#forw [")
145 (and description 165 (and description
146 (not (string= description "")) 166 (not (string= description ""))
147 (insert description)) 167 (insert description))
148 (insert "]") 168 (insert "]")
149 (and folder 169 (and folder
150 (not (string= folder "")) 170 (not (string= folder ""))
151 (insert " " folder)) 171 (insert " " folder))
152 (if (and msgs 172 (if (and messages
153 (not (string= msgs ""))) 173 (not (string= messages "")))
154 (let ((start (point))) 174 (let ((start (point)))
155 (insert " " msgs) 175 (insert " " messages)
156 (subst-char-in-region start (point) ?, ? )) 176 (subst-char-in-region start (point) ?, ? ))
157 (if mh-sent-from-msg 177 (if mh-sent-from-msg
158 (insert " " (int-to-string mh-sent-from-msg)))) 178 (insert " " (int-to-string mh-sent-from-msg))))
159 (insert "\n")) 179 (insert "\n"))
160 180
161 (defun mh-edit-mhn () 181 (defun mh-edit-mhn (&optional extra-args)
162 "Filter the current draft through the mhn program for MIME formatting. 182 "Format the current draft for MIME, expanding any mhn directives.
163 Using directives already inserted in the draft, fills in 183 Process the current draft with the mhn program, which,
184 using directives already inserted in the draft, fills in
164 all the MIME components and header fields. 185 all the MIME components and header fields.
165 This step should be done last just before sending the message. 186 This step should be done last just before sending the message.
166 The mhn program is part of MH version 6.8 or later. 187 The mhn program is part of MH version 6.8 or later.
167 The `\\[mh-revert-mhn-edit]' command undoes this command. 188 The `\\[mh-revert-mhn-edit]' command undoes this command.
168 For assistance with creating MIME directives to insert 189 The arguments in the list `mh-mhn-args' are passed to mhn
190 if this function is passed an argument.
191
192 For assistance with creating mhn directives to insert
169 various types of components in a message, see 193 various types of components in a message, see
170 \\[mh-mhn-compose-insertion] (generic insertion from a file), 194 \\[mh-mhn-compose-insertion] (generic insertion from a file),
171 \\[mh-mhn-compose-anon-ftp] (external reference to file via anonymous ftp), 195 \\[mh-mhn-compose-anon-ftp] (external reference to file via anonymous ftp),
172 \\[mh-mhn-compose-external-compressed-tar] \ 196 \\[mh-mhn-compose-external-compressed-tar] \
173 \(reference to compressed tar file via anonymous ftp), and 197 \(reference to compressed tar file via anonymous ftp), and
174 \\[mh-mhn-compose-forw] (forward message)." 198 \\[mh-mhn-compose-forw] (forward message)."
175 (interactive "*") 199 (interactive "*P")
176 (save-buffer) 200 (save-buffer)
177 (message "mhn editing...") 201 (message "mhn editing...")
178 (mh-exec-cmd-error (format "mhdraft=%s" (buffer-file-name)) 202 (mh-exec-cmd-error (format "mhdraft=%s" buffer-file-name)
179 "mhn" (buffer-file-name)) 203 "mhn" (if extra-args mh-mhn-args) buffer-file-name)
180 (revert-buffer t t) 204 (revert-buffer t t)
181 (message "mhn editing...done")) 205 (message "mhn editing...done")
206 (run-hooks 'mh-edit-mhn-hook))
182 207
183 208
184 (defun mh-revert-mhn-edit (noconfirm) 209 (defun mh-revert-mhn-edit (noconfirm)
185 "Undoes the effect of \\[mh-edit-mhn] by reverting to the backup file. 210 "Undoes the effect of \\[mh-edit-mhn] by reverting to the backup file.
186 Argument (optional) non-nil means don't ask for confirmation." 211 Optional non-nil argument means don't ask for confirmation."
187 (interactive "*P") 212 (interactive "*P")
188 (if (null buffer-file-name) 213 (if (null buffer-file-name)
189 (error "Buffer does not seem to be associated with any file")) 214 (error "Buffer does not seem to be associated with any file"))
190 (let ((backup-strings '("," "#")) 215 (let ((backup-strings '("," "#"))
191 backup-file) 216 backup-file)