Mercurial > emacs
annotate lisp/mh-e/mh-mime.el @ 93383:92ec903498d4
(Fexpand_file_name): Convert the value of $HOME to a multibyte string.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 29 Mar 2008 13:52:13 +0000 |
parents | 3f6a9fe50cce |
children | c70e45a7acfd 90c9ebd43589 |
rev | line source |
---|---|
68465 | 1 ;;; mh-mime.el --- MH-E MIME support |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
2 |
62847
aa8c2e12ee24
Upgraded to MH-E version 7.84.
Bill Wohler <wohler@newt.com>
parents:
62465
diff
changeset
|
3 ;; Copyright (C) 1993, 1995, |
79713 | 4 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
5 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
6 ;; Author: Bill Wohler <wohler@newt.com> |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
7 ;; Maintainer: Bill Wohler <wohler@newt.com> |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
8 ;; Keywords: mail |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
9 ;; See: mh-e.el |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
10 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
11 ;; This file is part of GNU Emacs. |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
12 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
13 ;; GNU Emacs is free software; you can redistribute it and/or modify |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
14 ;; it under the terms of the GNU General Public License as published by |
78231
800dd75c042b
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77941
diff
changeset
|
15 ;; the Free Software Foundation; either version 3, or (at your option) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
16 ;; any later version. |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
17 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
18 ;; GNU Emacs is distributed in the hope that it will be useful, |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
21 ;; GNU General Public License for more details. |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
22 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
23 ;; You should have received a copy of the GNU General Public License |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
27 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
28 ;;; Commentary: |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
29 |
68465 | 30 ;; Message composition of MIME message is done with either MH-style |
31 ;; directives for mhn or mhbuild (MH 6.8 or later) or MML (MIME Meta | |
32 ;; Language) tags. | |
33 | |
34 ;; TODO: | |
35 ;; Paragraph code should not fill # lines if MIME enabled. | |
36 ;; Implement mh-auto-mh-to-mime (if non-nil, \\[mh-send-letter] | |
37 ;; invokes mh-mh-to-mime automatically before sending.) | |
38 ;; Actually, instead of mh-auto-mh-to-mime, | |
39 ;; should read automhnproc from profile. | |
40 ;; MIME option to mh-forward command to move to content-description | |
41 ;; insertion point. | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
42 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
43 ;;; Change Log: |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
44 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
45 ;;; Code: |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
46 |
68465 | 47 (require 'mh-e) |
48 (require 'mh-gnus) ;needed because mh-gnus.el not compiled | |
68096
57c4e7929f99
* mh-alias.el (mh-alias-gecos-name): Use replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68083
diff
changeset
|
49 |
68465 | 50 (require 'font-lock) |
68096
57c4e7929f99
* mh-alias.el (mh-alias-gecos-name): Use replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68083
diff
changeset
|
51 (require 'gnus-util) |
68465 | 52 (require 'mailcap) |
53 (require 'mm-decode) | |
54 (require 'mm-view) | |
55 (require 'mml) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
56 |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
57 (autoload 'article-emphasize "gnus-art") |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
58 (autoload 'gnus-eval-format "gnus-spec") |
68465 | 59 (autoload 'mail-content-type-get "mail-parse") |
60 (autoload 'mail-decode-encoded-word-string "mail-parse") | |
61 (autoload 'mail-header-parse-content-type "mail-parse") | |
62 (autoload 'mail-header-strip "mail-parse") | |
86974
d1d8b9ce5e70
(mail-strip-quoted-names): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
82493
diff
changeset
|
63 (autoload 'mail-strip-quoted-names "mail-utils") |
82487
c51f2772210a
* mh-mime.el (message-options-set): Add missing autoloads from my
Jeffrey C Honig <jch@bsdi.com>
parents:
82476
diff
changeset
|
64 (autoload 'message-options-get "message") |
c51f2772210a
* mh-mime.el (message-options-set): Add missing autoloads from my
Jeffrey C Honig <jch@bsdi.com>
parents:
82476
diff
changeset
|
65 (autoload 'message-options-set "message") |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
66 (autoload 'message-options-set-recipient "message") |
68465 | 67 (autoload 'mm-decode-body "mm-bodies") |
66358
9f52d5da9ca6
Autoload mm-uu for mm-uu-dissect to avoid compiler warning in Emacs
Bill Wohler <wohler@newt.com>
parents:
66354
diff
changeset
|
68 (autoload 'mm-uu-dissect "mm-uu") |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
69 (autoload 'mml-unsecure-message "mml-sec") |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
70 (autoload 'rfc2047-decode-region "rfc2047") |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
71 (autoload 'widget-convert-button "wid-edit") |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
72 |
68465 | 73 |
74 | |
75 ;;; Variables | |
76 | |
77 ;; This has to be a macro, since we do: (setf (mh-buffer-data) ...) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
78 ;;;###mh-autoload |
68465 | 79 (defmacro mh-buffer-data () |
80 "Convenience macro to get the MIME data structures of the current buffer." | |
81 `(gethash (current-buffer) mh-globals-hash)) | |
82 | |
83 ;; Structure to keep track of MIME handles on a per buffer basis. | |
84 (mh-defstruct (mh-buffer-data (:conc-name mh-mime-) | |
85 (:constructor mh-make-buffer-data)) | |
86 (handles ()) ; List of MIME handles | |
87 (handles-cache (make-hash-table)) ; Cache to avoid multiple decodes of | |
88 ; nested messages | |
89 (parts-count 0) ; The button number is generated from | |
90 ; this number | |
91 (part-index-hash (make-hash-table))) ; Avoid incrementing the part number | |
92 ; for nested messages | |
93 | |
94 (defvar mh-mm-inline-media-tests | |
95 `(("image/jpeg" | |
96 mm-inline-image | |
97 (lambda (handle) | |
98 (mm-valid-and-fit-image-p 'jpeg handle))) | |
99 ("image/png" | |
100 mm-inline-image | |
101 (lambda (handle) | |
102 (mm-valid-and-fit-image-p 'png handle))) | |
103 ("image/gif" | |
104 mm-inline-image | |
105 (lambda (handle) | |
106 (mm-valid-and-fit-image-p 'gif handle))) | |
107 ("image/tiff" | |
108 mm-inline-image | |
109 (lambda (handle) | |
110 (mm-valid-and-fit-image-p 'tiff handle)) ) | |
111 ("image/xbm" | |
112 mm-inline-image | |
113 (lambda (handle) | |
114 (mm-valid-and-fit-image-p 'xbm handle))) | |
115 ("image/x-xbitmap" | |
116 mm-inline-image | |
117 (lambda (handle) | |
118 (mm-valid-and-fit-image-p 'xbm handle))) | |
119 ("image/xpm" | |
120 mm-inline-image | |
121 (lambda (handle) | |
122 (mm-valid-and-fit-image-p 'xpm handle))) | |
123 ("image/x-pixmap" | |
124 mm-inline-image | |
125 (lambda (handle) | |
126 (mm-valid-and-fit-image-p 'xpm handle))) | |
127 ("image/bmp" | |
128 mm-inline-image | |
129 (lambda (handle) | |
130 (mm-valid-and-fit-image-p 'bmp handle))) | |
131 ("image/x-portable-bitmap" | |
132 mm-inline-image | |
133 (lambda (handle) | |
134 (mm-valid-and-fit-image-p 'pbm handle))) | |
135 ("text/plain" mm-inline-text identity) | |
136 ("text/enriched" mm-inline-text identity) | |
137 ("text/richtext" mm-inline-text identity) | |
138 ("text/x-patch" mm-display-patch-inline | |
139 (lambda (handle) | |
140 (locate-library "diff-mode"))) | |
141 ("application/emacs-lisp" mm-display-elisp-inline identity) | |
142 ("application/x-emacs-lisp" mm-display-elisp-inline identity) | |
143 ("text/html" | |
144 ,(if (fboundp 'mm-inline-text-html) 'mm-inline-text-html 'mm-inline-text) | |
145 (lambda (handle) | |
146 (or (and (boundp 'mm-inline-text-html-renderer) | |
147 mm-inline-text-html-renderer) | |
148 (and (boundp 'mm-text-html-renderer) mm-text-html-renderer)))) | |
149 ("text/x-vcard" | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
150 mh-mm-inline-text-vcard |
68465 | 151 (lambda (handle) |
152 (or (featurep 'vcard) | |
153 (locate-library "vcard")))) | |
154 ("message/delivery-status" mm-inline-text identity) | |
155 ("message/rfc822" mh-mm-inline-message identity) | |
156 ;;("message/partial" mm-inline-partial identity) | |
157 ;;("message/external-body" mm-inline-external-body identity) | |
158 ("text/.*" mm-inline-text identity) | |
159 ("audio/wav" mm-inline-audio | |
160 (lambda (handle) | |
161 (and (or (featurep 'nas-sound) (featurep 'native-sound)) | |
162 (device-sound-enabled-p)))) | |
163 ("audio/au" | |
164 mm-inline-audio | |
165 (lambda (handle) | |
166 (and (or (featurep 'nas-sound) (featurep 'native-sound)) | |
167 (device-sound-enabled-p)))) | |
168 ("application/pgp-signature" ignore identity) | |
169 ("application/x-pkcs7-signature" ignore identity) | |
170 ("application/pkcs7-signature" ignore identity) | |
171 ("application/x-pkcs7-mime" ignore identity) | |
172 ("application/pkcs7-mime" ignore identity) | |
173 ("multipart/alternative" ignore identity) | |
174 ("multipart/mixed" ignore identity) | |
175 ("multipart/related" ignore identity) | |
176 ;; Disable audio and image | |
177 ("audio/.*" ignore ignore) | |
178 ("image/.*" ignore ignore) | |
179 ;; Default to displaying as text | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
180 (".*" mm-inline-text mh-mm-readable-p)) |
68465 | 181 "Alist of media types/tests saying whether types can be displayed inline.") |
182 | |
183 (defvar mh-mime-save-parts-directory nil | |
184 "Default to use for `mh-mime-save-parts-default-directory'. | |
185 Set from last use.") | |
186 | |
187 ;; Copied from gnus-art.el (should be checked for other cool things that can | |
188 ;; be added to the buttons) | |
189 (defvar mh-mime-button-commands | |
190 '((mh-press-button "\r" "Toggle Display"))) | |
191 (defvar mh-mime-button-map | |
192 (let ((map (make-sparse-keymap))) | |
193 (unless (>= (string-to-number emacs-version) 21) | |
194 ;; XEmacs doesn't care. | |
195 (set-keymap-parent map mh-show-mode-map)) | |
196 (mh-do-in-gnu-emacs | |
197 (define-key map [mouse-2] 'mh-push-button)) | |
198 (mh-do-in-xemacs | |
199 (define-key map '(button2) 'mh-push-button)) | |
200 (dolist (c mh-mime-button-commands) | |
201 (define-key map (cadr c) (car c))) | |
202 map)) | |
203 (defvar mh-mime-button-line-format-alist | |
204 '((?T long-type ?s) | |
205 (?d description ?s) | |
206 (?p index ?s) | |
207 (?e dots ?s))) | |
208 (defvar mh-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n") | |
209 (defvar mh-mime-security-button-pressed nil) | |
210 (defvar mh-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n") | |
211 (defvar mh-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n") | |
212 (defvar mh-mime-security-button-line-format-alist | |
213 '((?t type ?s) | |
214 (?i info ?s) | |
215 (?d details ?s) | |
216 (?D pressed-details ?s))) | |
217 (defvar mh-mime-security-button-map | |
218 (let ((map (make-sparse-keymap))) | |
219 (unless (>= (string-to-number emacs-version) 21) | |
220 (set-keymap-parent map mh-show-mode-map)) | |
221 (define-key map "\r" 'mh-press-button) | |
222 (mh-do-in-gnu-emacs | |
223 (define-key map [mouse-2] 'mh-push-button)) | |
224 (mh-do-in-xemacs | |
225 (define-key map '(button2) 'mh-push-button)) | |
226 map)) | |
227 | |
228 | |
229 | |
230 ;;; MH-Folder Commands | |
231 | |
232 ;; Alphabetical. | |
233 | |
234 ;;;###mh-autoload | |
235 (defun mh-display-with-external-viewer (part-index) | |
236 "View attachment externally. | |
237 | |
238 If Emacs does not know how to view an attachment, you could save | |
239 it into a file and then run some program to open it. It is | |
240 easier, however, to launch the program directly from MH-E with | |
241 this command. While you'll most likely use this to view | |
242 spreadsheets and documents, it is also useful to use your browser | |
243 to view HTML attachments with higher fidelity than what Emacs can | |
244 provide. | |
245 | |
246 This command displays the attachment associated with the button | |
247 under the cursor. If the cursor is not located over a button, | |
248 then the cursor first moves to the next button, wrapping to the | |
249 beginning of the message if necessary. You can provide a numeric | |
250 prefix argument PART-INDEX to view the attachment labeled with | |
251 that number. | |
252 | |
253 This command tries to provide a reasonable default for the viewer | |
254 by calling the Emacs function `mailcap-mime-info'. This function | |
255 usually reads the file \"/etc/mailcap\"." | |
256 (interactive "P") | |
257 (when (consp part-index) (setq part-index (car part-index))) | |
258 (mh-folder-mime-action | |
259 part-index | |
260 #'(lambda () | |
261 (let* ((part (get-text-property (point) 'mh-data)) | |
262 (type (mm-handle-media-type part)) | |
263 (methods (mapcar (lambda (x) (list (cdr (assoc 'viewer x)))) | |
264 (mailcap-mime-info type 'all))) | |
265 (def (caar methods)) | |
266 (prompt (format "Viewer%s: " (if def | |
267 (format " (default %s)" def) | |
268 ""))) | |
269 (method (completing-read prompt methods nil nil nil nil def)) | |
270 (folder mh-show-folder-buffer) | |
271 (buffer-read-only nil)) | |
272 (when (string-match "^[^% \t]+$" method) | |
273 (setq method (concat method " %s"))) | |
274 (flet ((mm-handle-set-external-undisplayer (handle function) | |
275 (mh-handle-set-external-undisplayer folder handle function))) | |
276 (unwind-protect (mm-display-external part method) | |
277 (set-buffer-modified-p nil))))) | |
278 nil)) | |
279 | |
280 ;;;###mh-autoload | |
281 (defun mh-folder-inline-mime-part (part-index) | |
282 "Show attachment verbatim. | |
283 | |
284 You can view the raw contents of an attachment with this command. | |
285 This command displays (or hides) the contents of the attachment | |
286 associated with the button under the cursor verbatim. If the | |
287 cursor is not located over a button, then the cursor first moves | |
288 to the next button, wrapping to the beginning of the message if | |
289 necessary. | |
290 | |
291 You can also provide a numeric prefix argument PART-INDEX to view | |
292 the attachment labeled with that number." | |
293 (interactive "P") | |
294 (when (consp part-index) (setq part-index (car part-index))) | |
295 (mh-folder-mime-action part-index #'mh-mime-inline-part nil)) | |
296 | |
297 (defun mh-mime-inline-part () | |
298 "Toggle display of the raw MIME part." | |
299 (interactive) | |
300 (let* ((buffer-read-only nil) | |
301 (data (get-text-property (point) 'mh-data)) | |
302 (inserted-flag (get-text-property (point) 'mh-mime-inserted)) | |
303 (displayed-flag (mm-handle-displayed-p data)) | |
304 (point (point)) | |
305 start end) | |
306 (cond ((and data (not inserted-flag) (not displayed-flag)) | |
307 (let ((contents (mm-get-part data))) | |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
308 (add-text-properties (mh-line-beginning-position) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
309 (mh-line-end-position) '(mh-mime-inserted t)) |
68465 | 310 (setq start (point-marker)) |
311 (forward-line 1) | |
312 (mm-insert-inline data contents) | |
313 (setq end (point-marker)) | |
314 (add-text-properties | |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
315 start (progn (goto-char start) (mh-line-end-position)) |
68465 | 316 `(mh-region (,start . ,end))))) |
317 ((and data (or inserted-flag displayed-flag)) | |
318 (mh-press-button) | |
319 (message "MIME part already inserted"))) | |
320 (goto-char point) | |
321 (set-buffer-modified-p nil))) | |
322 | |
323 ;;;###mh-autoload | |
324 (defun mh-folder-save-mime-part (part-index) | |
325 "Save (output) attachment. | |
326 | |
327 This command saves the attachment associated with the button under the | |
328 cursor. If the cursor is not located over a button, then the cursor | |
329 first moves to the next button, wrapping to the beginning of the | |
330 message if necessary. | |
331 | |
332 You can also provide a numeric prefix argument PART-INDEX to save the | |
333 attachment labeled with that number. | |
334 | |
335 This command prompts you for a filename and suggests a specific name | |
336 if it is available." | |
337 (interactive "P") | |
338 (when (consp part-index) (setq part-index (car part-index))) | |
339 (mh-folder-mime-action part-index #'mh-mime-save-part nil)) | |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
340 |
68465 | 341 (defun mh-mime-save-part () |
342 "Save MIME part at point." | |
343 (interactive) | |
344 (let ((data (get-text-property (point) 'mh-data))) | |
345 (when data | |
346 (let ((mm-default-directory | |
347 (file-name-as-directory (or mh-mime-save-parts-directory | |
348 default-directory)))) | |
349 (mh-mm-save-part data) | |
350 (setq mh-mime-save-parts-directory mm-default-directory))))) | |
351 | |
352 ;;;###mh-autoload | |
353 (defun mh-folder-toggle-mime-part (part-index) | |
354 "View attachment. | |
355 | |
356 This command displays (or hides) the attachment associated with | |
357 the button under the cursor. If the cursor is not located over a | |
358 button, then the cursor first moves to the next button, wrapping | |
359 to the beginning of the message if necessary. This command has | |
360 the advantage over related commands of working from the MH-Folder | |
361 buffer. | |
362 | |
363 You can also provide a numeric prefix argument PART-INDEX to view | |
364 the attachment labeled with that number. If Emacs does not know | |
365 how to display the attachment, then Emacs offers to save the | |
366 attachment in a file." | |
367 (interactive "P") | |
368 (when (consp part-index) (setq part-index (car part-index))) | |
369 (mh-folder-mime-action part-index #'mh-press-button t)) | |
370 | |
371 ;;;###mh-autoload | |
372 (defun mh-mime-save-parts (prompt) | |
373 "Save attachments. | |
374 | |
375 You can save all of the attachments at once with this command. | |
376 The attachments are saved in the directory specified by the | |
377 option `mh-mime-save-parts-default-directory' unless you use a | |
378 prefix argument PROMPT in which case you are prompted for the | |
379 directory. These directories may be superseded by MH profile | |
380 components, since this function calls on \"mhstore\" (\"mhn\") to | |
381 do the work." | |
382 (interactive "P") | |
383 (let ((msg (if (eq major-mode 'mh-show-mode) | |
384 (mh-show-buffer-message-number) | |
385 (mh-get-msg-num t))) | |
386 (folder (if (eq major-mode 'mh-show-mode) | |
387 mh-show-folder-buffer | |
388 mh-current-folder)) | |
389 (command (if (mh-variant-p 'nmh) "mhstore" "mhn")) | |
390 (directory | |
391 (cond | |
392 ((and (or prompt | |
393 (equal nil mh-mime-save-parts-default-directory) | |
394 (equal t mh-mime-save-parts-default-directory)) | |
395 (not mh-mime-save-parts-directory)) | |
396 (read-file-name "Store in directory: " nil nil t nil)) | |
397 ((and (or prompt | |
398 (equal t mh-mime-save-parts-default-directory)) | |
399 mh-mime-save-parts-directory) | |
400 (read-file-name (format | |
401 "Store in directory (default %s): " | |
402 mh-mime-save-parts-directory) | |
403 "" mh-mime-save-parts-directory t "")) | |
404 ((stringp mh-mime-save-parts-default-directory) | |
405 mh-mime-save-parts-default-directory) | |
406 (t | |
407 mh-mime-save-parts-directory)))) | |
408 (if (and (equal directory "") mh-mime-save-parts-directory) | |
409 (setq directory mh-mime-save-parts-directory)) | |
410 (if (not (file-directory-p directory)) | |
411 (message "No directory specified") | |
412 (if (equal nil mh-mime-save-parts-default-directory) | |
413 (setq mh-mime-save-parts-directory directory)) | |
414 (save-excursion | |
415 (set-buffer (get-buffer-create mh-log-buffer)) | |
416 (cd directory) | |
417 (setq mh-mime-save-parts-directory directory) | |
418 (let ((initial-size (mh-truncate-log-buffer))) | |
419 (apply 'call-process | |
420 (expand-file-name command mh-progs) nil t nil | |
71528
113cbc14f25c
(mh-mime-save-parts): Add -store option to mhn (closes SF #1513140).
Bill Wohler <wohler@newt.com>
parents:
70028
diff
changeset
|
421 (mh-list-to-string (list folder msg "-auto" |
113cbc14f25c
(mh-mime-save-parts): Add -store option to mhn (closes SF #1513140).
Bill Wohler <wohler@newt.com>
parents:
70028
diff
changeset
|
422 (if (not (mh-variant-p 'nmh)) |
113cbc14f25c
(mh-mime-save-parts): Add -store option to mhn (closes SF #1513140).
Bill Wohler <wohler@newt.com>
parents:
70028
diff
changeset
|
423 "-store")))) |
68465 | 424 (if (> (buffer-size) initial-size) |
425 (save-window-excursion | |
426 (switch-to-buffer-other-window mh-log-buffer) | |
427 (sit-for 3)))))))) | |
428 | |
429 ;;;###mh-autoload | |
430 (defun mh-toggle-mh-decode-mime-flag () | |
431 "Toggle the value of `mh-decode-mime-flag'." | |
432 (interactive) | |
433 (setq mh-decode-mime-flag (not mh-decode-mime-flag)) | |
434 (mh-show nil t) | |
435 (message "%s" (if mh-decode-mime-flag | |
436 "Processing attachments normally" | |
437 "Displaying raw message"))) | |
438 | |
439 ;;;###mh-autoload | |
440 (defun mh-toggle-mime-buttons () | |
441 "Toggle option `mh-display-buttons-for-inline-parts-flag'." | |
442 (interactive) | |
443 (setq mh-display-buttons-for-inline-parts-flag | |
444 (not mh-display-buttons-for-inline-parts-flag)) | |
445 (mh-show nil t)) | |
446 | |
447 | |
448 | |
449 ;;; MIME Display Routines | |
450 | |
451 (defun mh-mm-inline-message (handle) | |
452 "Display message, HANDLE. | |
453 The function decodes the message and displays it. It avoids | |
454 decoding the same message multiple times." | |
455 (let ((b (point)) | |
456 (clean-message-header mh-clean-message-header-flag) | |
457 (invisible-headers mh-invisible-header-fields-compiled) | |
458 (visible-headers nil)) | |
459 (save-excursion | |
460 (save-restriction | |
461 (narrow-to-region b b) | |
462 (mm-insert-part handle) | |
463 (mh-mime-display | |
464 (or (gethash handle (mh-mime-handles-cache (mh-buffer-data))) | |
465 (setf (gethash handle (mh-mime-handles-cache (mh-buffer-data))) | |
466 (let ((handles (mm-dissect-buffer nil))) | |
467 (if handles | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
468 (mh-mm-uu-dissect-text-parts handles) |
68465 | 469 (setq handles (mm-uu-dissect))) |
470 (setf (mh-mime-handles (mh-buffer-data)) | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
471 (mh-mm-merge-handles |
68465 | 472 handles (mh-mime-handles (mh-buffer-data)))) |
473 handles)))) | |
474 | |
475 (goto-char (point-min)) | |
476 (mh-show-xface) | |
477 (cond (clean-message-header | |
478 (mh-clean-msg-header (point-min) | |
479 invisible-headers | |
480 visible-headers) | |
481 (goto-char (point-min))) | |
482 (t | |
483 (mh-start-of-uncleaned-message))) | |
484 (mh-decode-message-header) | |
485 (mh-show-addr) | |
486 ;; The other highlighting types don't need anything special | |
487 (when (eq mh-highlight-citation-style 'gnus) | |
488 (mh-gnus-article-highlight-citation)) | |
489 (goto-char (point-min)) | |
490 (insert "\n------- Forwarded Message\n\n") | |
491 (mh-display-smileys) | |
492 (mh-display-emphasis) | |
493 (mm-handle-set-undisplayer | |
494 handle | |
495 `(lambda () | |
496 (let (buffer-read-only) | |
497 (if (fboundp 'remove-specifier) | |
498 ;; This is only valid on XEmacs. | |
499 (mapcar (lambda (prop) | |
500 (remove-specifier | |
501 (face-property 'default prop) (current-buffer))) | |
502 '(background background-pixmap foreground))) | |
503 (delete-region ,(point-min-marker) ,(point-max-marker))))))))) | |
504 | |
505 ;;;###mh-autoload | |
506 (defun mh-decode-message-header () | |
507 "Decode RFC2047 encoded message header fields." | |
508 (when mh-decode-mime-flag | |
509 (let ((buffer-read-only nil)) | |
510 (rfc2047-decode-region (point-min) (mh-mail-header-end))))) | |
511 | |
512 ;;;###mh-autoload | |
513 (defun mh-mime-display (&optional pre-dissected-handles) | |
514 "Display (and possibly decode) MIME handles. | |
515 Optional argument, PRE-DISSECTED-HANDLES is a list of MIME | |
516 handles. If present they are displayed otherwise the buffer is | |
517 parsed and then displayed." | |
518 (let ((handles ()) | |
519 (folder mh-show-folder-buffer) | |
520 (raw-message-data (buffer-string))) | |
521 (flet ((mm-handle-set-external-undisplayer | |
522 (handle function) | |
523 (mh-handle-set-external-undisplayer folder handle function))) | |
524 (goto-char (point-min)) | |
525 (unless (search-forward "\n\n" nil t) | |
526 (goto-char (point-max)) | |
527 (insert "\n\n")) | |
528 | |
529 (condition-case err | |
530 (progn | |
531 ;; If needed dissect the current buffer | |
532 (if pre-dissected-handles | |
533 (setq handles pre-dissected-handles) | |
534 (if (setq handles (mm-dissect-buffer nil)) | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
535 (mh-mm-uu-dissect-text-parts handles) |
68465 | 536 (setq handles (mm-uu-dissect))) |
537 (setf (mh-mime-handles (mh-buffer-data)) | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
538 (mh-mm-merge-handles handles |
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
539 (mh-mime-handles (mh-buffer-data)))) |
68465 | 540 (unless handles |
541 (mh-decode-message-body))) | |
542 | |
543 (cond ((and handles | |
544 (or (not (stringp (car handles))) | |
545 (cdr handles))) | |
546 ;; Go to start of message body | |
547 (goto-char (point-min)) | |
548 (or (search-forward "\n\n" nil t) | |
549 (goto-char (point-max))) | |
550 | |
551 ;; Delete the body | |
552 (delete-region (point) (point-max)) | |
553 | |
554 ;; Display the MIME handles | |
555 (mh-mime-display-part handles)) | |
556 (t | |
557 (mh-signature-highlight)))) | |
558 (error | |
559 (message "Could not display body: %s" (error-message-string err)) | |
560 (delete-region (point-min) (point-max)) | |
561 (insert raw-message-data)))))) | |
562 | |
563 (defun mh-decode-message-body () | |
564 "Decode message based on charset. | |
565 If message has been encoded for transfer take that into account." | |
566 (let (ct charset cte) | |
567 (goto-char (point-min)) | |
568 (re-search-forward "\n\n" nil t) | |
569 (save-restriction | |
570 (narrow-to-region (point-min) (point)) | |
571 (setq ct (ignore-errors (mail-header-parse-content-type | |
572 (message-fetch-field "Content-Type" t))) | |
573 charset (mail-content-type-get ct 'charset) | |
574 cte (message-fetch-field "Content-Transfer-Encoding"))) | |
575 (when (stringp cte) (setq cte (mail-header-strip cte))) | |
576 (when (or (not ct) (equal (car ct) "text/plain")) | |
577 (save-restriction | |
578 (narrow-to-region (min (1+ (mh-mail-header-end)) (point-max)) | |
579 (point-max)) | |
580 (mm-decode-body charset | |
581 (and cte (intern (downcase | |
582 (gnus-strip-whitespace cte)))) | |
583 (car ct)))))) | |
584 | |
585 (defun mh-mime-display-part (handle) | |
586 "Decides the viewer to call based on the type of HANDLE." | |
587 (cond ((null handle) | |
588 nil) | |
589 ((not (stringp (car handle))) | |
590 (mh-mime-display-single handle)) | |
591 ((equal (car handle) "multipart/alternative") | |
592 (mh-mime-display-alternative (cdr handle))) | |
593 ((and mh-pgp-support-flag | |
594 (or (equal (car handle) "multipart/signed") | |
595 (equal (car handle) "multipart/encrypted"))) | |
596 (mh-mime-display-security handle)) | |
597 (t | |
598 (mh-mime-display-mixed (cdr handle))))) | |
599 | |
600 (defun mh-mime-display-mixed (handles) | |
601 "Display the list of MIME parts, HANDLES recursively." | |
602 (mapcar #'mh-mime-display-part handles)) | |
603 | |
604 (defun mh-mime-display-alternative (handles) | |
605 "Choose among the alternatives, HANDLES the part that will be displayed. | |
606 If no part is preferred then all the parts are displayed." | |
607 (let* ((preferred (mm-preferred-alternative handles)) | |
608 (others (loop for x in handles unless (eq x preferred) collect x))) | |
609 (cond ((and preferred | |
610 (stringp (car preferred))) | |
611 (mh-mime-display-part preferred) | |
612 (mh-mime-maybe-display-alternatives others)) | |
613 (preferred | |
614 (save-restriction | |
615 (narrow-to-region (point) (if (eobp) (point) (1+ (point)))) | |
616 (mh-mime-display-single preferred) | |
617 (mh-mime-maybe-display-alternatives others) | |
618 (goto-char (point-max)))) | |
619 (t | |
620 (mh-mime-display-mixed handles))))) | |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
621 |
68465 | 622 (defun mh-mime-maybe-display-alternatives (alternatives) |
623 "Show buttons for ALTERNATIVES. | |
624 If `mh-mime-display-alternatives-flag' is non-nil then display | |
625 buttons for alternative parts that are usually suppressed." | |
626 (when (and mh-display-buttons-for-alternatives-flag alternatives) | |
627 (insert "\n----------------------------------------------------\n") | |
628 (insert "Alternatives:\n") | |
629 (dolist (x alternatives) | |
630 (insert "\n") | |
631 (mh-insert-mime-button x (mh-mime-part-index x) nil)) | |
632 (insert "\n----------------------------------------------------\n"))) | |
633 | |
634 (defun mh-mime-display-security (handle) | |
635 "Display PGP encrypted/signed message, HANDLE." | |
636 (save-restriction | |
637 (narrow-to-region (point) (point)) | |
638 (insert "\n") | |
639 (mh-insert-mime-security-button handle) | |
640 (mh-mime-display-mixed (cdr handle)) | |
641 (insert "\n") | |
642 (let ((mh-mime-security-button-line-format | |
643 mh-mime-security-button-end-line-format)) | |
644 (mh-insert-mime-security-button handle)) | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
645 (mh-mm-set-handle-multipart-parameter |
68465 | 646 handle 'mh-region (cons (point-min-marker) (point-max-marker))))) |
647 | |
648 (defun mh-mime-display-single (handle) | |
649 "Display a leaf node, HANDLE in the MIME tree." | |
650 (let* ((type (mm-handle-media-type handle)) | |
651 (small-image-flag (mh-small-image-p handle)) | |
652 (attachmentp (equal (car (mm-handle-disposition handle)) | |
653 "attachment")) | |
654 (inlinep (and (equal (car (mm-handle-disposition handle)) "inline") | |
655 (mm-inlinable-p handle) | |
656 (mm-inlined-p handle))) | |
657 (displayp (or inlinep ; show if inline OR | |
658 (mh-inline-vcard-p handle); inline vcard OR | |
659 (and (not attachmentp) ; if not an attachment | |
660 (or small-image-flag ; and small image | |
661 ; and user wants inline | |
662 (and (not (equal | |
663 (mm-handle-media-supertype handle) | |
664 "image")) | |
665 (mm-inlinable-p handle) | |
666 (mm-inlined-p handle))))))) | |
667 (save-restriction | |
668 (narrow-to-region (point) (if (eobp) (point) (1+ (point)))) | |
669 (cond ((and mh-pgp-support-flag | |
670 (equal type "application/pgp-signature")) | |
671 nil) ; skip signatures as they are already handled... | |
672 ((not displayp) | |
673 (insert "\n") | |
674 (mh-insert-mime-button handle (mh-mime-part-index handle) nil)) | |
675 ((and displayp | |
676 (not mh-display-buttons-for-inline-parts-flag)) | |
677 (or (mm-display-part handle) | |
678 (mm-display-part handle)) | |
679 (mh-signature-highlight handle)) | |
680 ((and displayp | |
681 mh-display-buttons-for-inline-parts-flag) | |
682 (insert "\n") | |
683 (mh-insert-mime-button handle (mh-mime-part-index handle) nil) | |
684 (forward-line -1) | |
685 (mh-mm-display-part handle))) | |
686 (goto-char (point-max))))) | |
687 | |
688 ;; There is a bug in Gnus inline image display due to which an extra line | |
689 ;; gets inserted every time it is viewed. To work around that problem we are | |
690 ;; using an extra property 'mh-region to remember the region that is added | |
691 ;; when the button is clicked. The region is then deleted to make sure that | |
692 ;; no extra lines get inserted. | |
693 (defun mh-mm-display-part (handle) | |
694 "Toggle display of button for MIME part, HANDLE." | |
695 (beginning-of-line) | |
696 (let ((id (get-text-property (point) 'mh-part)) | |
697 (point (point)) | |
698 (window (selected-window)) | |
699 (mail-parse-charset 'nil) | |
700 (mail-parse-ignored-charsets nil) | |
701 region buffer-read-only) | |
702 (save-excursion | |
703 (unwind-protect | |
704 (let ((win (get-buffer-window (current-buffer) t))) | |
705 (when win | |
706 (select-window win)) | |
707 (goto-char point) | |
708 | |
709 (if (mm-handle-displayed-p handle) | |
710 ;; This will remove the part. | |
711 (progn | |
712 ;; Delete the button and displayed part (if any) | |
713 (let ((region (get-text-property point 'mh-region))) | |
714 (when region | |
715 (mh-funcall-if-exists | |
716 remove-images (car region) (cdr region))) | |
717 (mm-display-part handle) | |
718 (when region | |
719 (delete-region (car region) (cdr region)))) | |
720 ;; Delete button (if it still remains). This happens for | |
721 ;; externally displayed parts where the previous step does | |
722 ;; nothing. | |
723 (unless (eolp) | |
724 (delete-region (point) (progn (forward-line) (point))))) | |
725 (save-restriction | |
726 (delete-region (point) (progn (forward-line 1) (point))) | |
727 (narrow-to-region (point) (point)) | |
728 ;; Maybe we need another unwind-protect here. | |
729 (when (equal (mm-handle-media-supertype handle) "image") | |
730 (insert "\n")) | |
731 (when (and (not (eq (ignore-errors (mm-display-part handle)) | |
732 'inline)) | |
733 (equal (mm-handle-media-supertype handle) | |
734 "image")) | |
735 (goto-char (point-min)) | |
736 (delete-char 1)) | |
737 (when (equal (mm-handle-media-supertype handle) "text") | |
738 (when (eq mh-highlight-citation-style 'gnus) | |
739 (mh-gnus-article-highlight-citation)) | |
740 (mh-display-smileys) | |
741 (mh-display-emphasis) | |
742 (mh-signature-highlight handle)) | |
743 (setq region (cons (progn (goto-char (point-min)) | |
744 (point-marker)) | |
745 (progn (goto-char (point-max)) | |
746 (point-marker))))))) | |
747 (when (window-live-p window) | |
748 (select-window window)) | |
749 (goto-char point) | |
750 (beginning-of-line) | |
751 (mh-insert-mime-button handle id (mm-handle-displayed-p handle)) | |
752 (goto-char point) | |
753 (when region | |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
754 (add-text-properties (mh-line-beginning-position) |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
755 (mh-line-end-position) |
68465 | 756 `(mh-region ,region))))))) |
757 | |
758 (defun mh-mime-part-index (handle) | |
759 "Generate the button number for MIME part, HANDLE. | |
760 Notice that a hash table is used to display the same number when | |
761 buttons need to be displayed multiple times (for instance when | |
762 nested messages are opened)." | |
763 (or (gethash handle (mh-mime-part-index-hash (mh-buffer-data))) | |
764 (setf (gethash handle (mh-mime-part-index-hash (mh-buffer-data))) | |
765 (incf (mh-mime-parts-count (mh-buffer-data)))))) | |
766 | |
767 (defun mh-small-image-p (handle) | |
768 "Decide whether HANDLE is a \"small\" image that can be displayed inline. | |
769 This is only useful if a Content-Disposition header is not present." | |
770 (let ((media-test (caddr (assoc (car (mm-handle-type handle)) | |
771 mh-mm-inline-media-tests))) | |
772 (mm-inline-large-images t)) | |
773 (and media-test | |
774 (equal (mm-handle-media-supertype handle) "image") | |
775 (funcall media-test handle) ; Since mm-inline-large-images is T, | |
776 ; this only tells us if the image is | |
777 ; something that emacs can display | |
778 (let* ((image (mm-get-image handle))) | |
779 (or (mh-do-in-xemacs | |
780 (and (mh-funcall-if-exists glyphp image) | |
781 (< (glyph-width image) | |
782 (or mh-max-inline-image-width (window-pixel-width))) | |
783 (< (glyph-height image) | |
784 (or mh-max-inline-image-height | |
785 (window-pixel-height))))) | |
786 (mh-do-in-gnu-emacs | |
787 (let ((size (mh-funcall-if-exists image-size image))) | |
788 (and size | |
789 (< (cdr size) (or mh-max-inline-image-height | |
790 (1- (window-height)))) | |
791 (< (car size) (or mh-max-inline-image-width | |
792 (window-width))))))))))) | |
793 | |
794 (defun mh-inline-vcard-p (handle) | |
795 "Decide if HANDLE is a vcard that must be displayed inline." | |
796 (let ((type (mm-handle-type handle))) | |
797 (and (or (featurep 'vcard) (fboundp 'vcard-pretty-print)) | |
798 (consp type) | |
799 (equal (car type) "text/x-vcard") | |
800 (save-excursion | |
801 (save-restriction | |
802 (widen) | |
803 (goto-char (point-min)) | |
804 (not (mh-signature-separator-p))))))) | |
805 | |
806 (defun mh-signature-highlight (&optional handle) | |
807 "Highlight message signature in HANDLE. | |
808 The optional argument, HANDLE is a MIME handle if the function is | |
809 being used to highlight the signature in a MIME part." | |
810 (let ((regexp | |
811 (cond ((not handle) "^-- $") | |
812 ((not (and (equal (mm-handle-media-supertype handle) "text") | |
813 (equal (mm-handle-media-subtype handle) "html"))) | |
814 "^-- $") | |
815 ((eq (mh-mm-text-html-renderer) 'lynx) "^ --$") | |
816 (t "^--$")))) | |
817 (save-excursion | |
818 (goto-char (point-max)) | |
819 (when (re-search-backward regexp nil t) | |
820 (mh-do-in-gnu-emacs | |
821 (let ((ov (make-overlay (point) (point-max)))) | |
822 (overlay-put ov 'face 'mh-show-signature) | |
823 (overlay-put ov 'evaporate t))) | |
824 (mh-do-in-xemacs | |
825 (set-extent-property (make-extent (point) (point-max)) | |
826 'face 'mh-show-signature)))))) | |
827 | |
828 | |
829 | |
830 ;;; Button Display | |
831 | |
832 ;; Shush compiler. | |
70028
d81780942bb8
* mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
70027
diff
changeset
|
833 (defvar dots) ; XEmacs |
d81780942bb8
* mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
70027
diff
changeset
|
834 (defvar type) ; XEmacs |
d81780942bb8
* mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
70027
diff
changeset
|
835 (defvar ov) ; XEmacs |
68465 | 836 |
837 (defun mh-insert-mime-button (handle index displayed) | |
838 "Insert MIME button for HANDLE. | |
839 INDEX is the part number that will be DISPLAYED. It is also used | |
840 by commands like \"K v\" which operate on individual MIME parts." | |
841 ;; The button could be displayed by a previous decode. In that case | |
842 ;; undisplay it if we need a hidden button. | |
843 (when (and (mm-handle-displayed-p handle) (not displayed)) | |
844 (mm-display-part handle)) | |
845 (let ((name (or (mail-content-type-get (mm-handle-type handle) 'name) | |
846 (mail-content-type-get (mm-handle-disposition handle) | |
847 'filename) | |
848 (mail-content-type-get (mm-handle-type handle) 'url) | |
849 "")) | |
850 (type (mm-handle-media-type handle)) | |
851 (description (mail-decode-encoded-word-string | |
852 (or (mm-handle-description handle) ""))) | |
853 (dots (if (or displayed (mm-handle-displayed-p handle)) " " "...")) | |
854 long-type begin end) | |
855 (if (string-match ".*/" name) (setq name (substring name (match-end 0)))) | |
856 (setq long-type (concat type (and (not (equal name "")) | |
857 (concat "; " name)))) | |
858 (unless (equal description "") | |
859 (setq long-type (concat " --- " long-type))) | |
860 (unless (bolp) (insert "\n")) | |
861 (setq begin (point)) | |
862 (gnus-eval-format | |
863 mh-mime-button-line-format mh-mime-button-line-format-alist | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
864 `(,@(mh-gnus-local-map-property mh-mime-button-map) |
68465 | 865 mh-callback mh-mm-display-part |
866 mh-part ,index | |
867 mh-data ,handle)) | |
868 (setq end (point)) | |
869 (widget-convert-button | |
870 'link begin end | |
871 :mime-handle handle | |
872 :action 'mh-widget-press-button | |
873 :button-keymap mh-mime-button-map | |
874 :help-echo | |
875 "Mouse-2 click or press RET (in show buffer) to toggle display") | |
876 (dolist (ov (mh-funcall-if-exists overlays-in begin end)) | |
877 (mh-funcall-if-exists overlay-put ov 'evaporate t)))) | |
878 | |
879 ;; Shush compiler. | |
70028
d81780942bb8
* mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
70027
diff
changeset
|
880 (defvar mm-verify-function-alist) ; < Emacs 22 |
d81780942bb8
* mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
70027
diff
changeset
|
881 (defvar mm-decrypt-function-alist) ; < Emacs 22 |
d81780942bb8
* mh-acros.el (struct, x, y): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
70027
diff
changeset
|
882 (defvar pressed-details) ; XEmacs |
68465 | 883 |
884 (defun mh-insert-mime-security-button (handle) | |
885 "Display buttons for PGP message, HANDLE." | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
886 (let* ((protocol (mh-mm-handle-multipart-ctl-parameter handle 'protocol)) |
68465 | 887 (crypto-type (or (nth 2 (assoc protocol mm-verify-function-alist)) |
888 (nth 2 (assoc protocol mm-decrypt-function-alist)) | |
889 "Unknown")) | |
890 (type (concat crypto-type | |
891 (if (equal (car handle) "multipart/signed") | |
892 " Signed" " Encrypted") | |
893 " Part")) | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
894 (info (or (mh-mm-handle-multipart-ctl-parameter handle 'gnus-info) |
68465 | 895 "Undecided")) |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
896 (details (mh-mm-handle-multipart-ctl-parameter handle 'gnus-details)) |
68465 | 897 pressed-details begin end face) |
898 (setq details (if details (concat "\n" details) "")) | |
899 (setq pressed-details (if mh-mime-security-button-pressed details "")) | |
900 (setq face (mh-mime-security-button-face info)) | |
901 (unless (bolp) (insert "\n")) | |
902 (setq begin (point)) | |
903 (gnus-eval-format | |
904 mh-mime-security-button-line-format | |
905 mh-mime-security-button-line-format-alist | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
906 `(,@(mh-gnus-local-map-property mh-mime-security-button-map) |
68465 | 907 mh-button-pressed ,mh-mime-security-button-pressed |
908 mh-callback mh-mime-security-press-button | |
909 mh-line-format ,mh-mime-security-button-line-format | |
910 mh-data ,handle)) | |
911 (setq end (point)) | |
912 (widget-convert-button 'link begin end | |
913 :mime-handle handle | |
914 :action 'mh-widget-press-button | |
915 :button-keymap mh-mime-security-button-map | |
916 :button-face face | |
917 :help-echo "Mouse-2 click or press RET (in show buffer) to see security details.") | |
918 (dolist (ov (mh-funcall-if-exists overlays-in begin end)) | |
919 (mh-funcall-if-exists overlay-put ov 'evaporate t)) | |
920 (when (equal info "Failed") | |
921 (let* ((type (if (equal (car handle) "multipart/signed") | |
922 "verification" "decryption")) | |
923 (warning (if (equal type "decryption") | |
924 "(passphrase may be incorrect)" ""))) | |
925 (message "%s %s failed %s" crypto-type type warning))))) | |
926 | |
927 (defun mh-mime-security-button-face (info) | |
928 "Return the button face to use for encrypted/signed mail based on INFO." | |
929 (cond ((string-match "OK" info) ;Decrypted mail | |
930 'mh-show-pgg-good) | |
931 ((string-match "Failed" info) ;Decryption failed or signature invalid | |
932 'mh-show-pgg-bad) | |
933 ((string-match "Undecided" info);Unprocessed mail | |
934 'mh-show-pgg-unknown) | |
935 ((string-match "Untrusted" info);Key not trusted | |
936 'mh-show-pgg-unknown) | |
937 (t | |
938 'mh-show-pgg-good))) | |
939 | |
940 | |
941 | |
942 ;;; Button Handlers | |
943 | |
944 (defun mh-folder-mime-action (part-index action include-security-flag) | |
945 "Go to PART-INDEX and carry out ACTION. | |
946 | |
947 If PART-INDEX is nil then go to the next part in the buffer. The | |
948 search for the next buffer wraps around if end of buffer is reached. | |
949 If argument INCLUDE-SECURITY-FLAG is non-nil then include security | |
950 info buttons when searching for a suitable parts." | |
951 (unless mh-showing-mode | |
952 (mh-show)) | |
953 (mh-in-show-buffer (mh-show-buffer) | |
954 (let ((criterion | |
955 (cond (part-index | |
956 (lambda (p) | |
957 (let ((part (get-text-property p 'mh-part))) | |
958 (and (integerp part) (= part part-index))))) | |
959 (t (lambda (p) | |
960 (if include-security-flag | |
961 (get-text-property p 'mh-data) | |
962 (integerp (get-text-property p 'mh-part))))))) | |
963 (point (point))) | |
964 (cond ((and (get-text-property point 'mh-part) | |
965 (or (null part-index) | |
966 (= (get-text-property point 'mh-part) part-index))) | |
967 (funcall action)) | |
968 ((and (get-text-property point 'mh-data) | |
969 include-security-flag | |
970 (null part-index)) | |
971 (funcall action)) | |
972 (t | |
973 (mh-goto-next-button nil criterion) | |
974 (if (= (point) point) | |
975 (message "No matching MIME part found") | |
976 (funcall action))))))) | |
977 | |
978 ;;;###mh-autoload | |
979 (defun mh-goto-next-button (backward-flag &optional criterion) | |
980 "Search for next button satisfying criterion. | |
981 | |
982 If BACKWARD-FLAG is non-nil search backward in the buffer for a mime | |
983 button. | |
984 If CRITERION is a function or a symbol which has a function binding | |
985 then that function must return non-nil at the button we stop." | |
986 (unless (or (and (symbolp criterion) (fboundp criterion)) | |
987 (functionp criterion)) | |
988 (setq criterion (lambda (x) t))) | |
989 ;; Move to the next button in the buffer satisfying criterion | |
990 (goto-char (or (save-excursion | |
991 (beginning-of-line) | |
992 ;; Find point before current button | |
993 (let ((point-before-current-button | |
994 (save-excursion | |
995 (while (get-text-property (point) 'mh-data) | |
996 (unless (= (forward-line | |
997 (if backward-flag 1 -1)) | |
998 0) | |
999 (if backward-flag | |
1000 (goto-char (point-min)) | |
1001 (goto-char (point-max))))) | |
1002 (point)))) | |
1003 ;; Skip over current button | |
1004 (while (and (get-text-property (point) 'mh-data) | |
1005 (not (if backward-flag (bobp) (eobp)))) | |
1006 (forward-line (if backward-flag -1 1))) | |
1007 ;; Stop at next MIME button if any exists. | |
1008 (block loop | |
1009 (while (/= (progn | |
1010 (unless (= (forward-line | |
1011 (if backward-flag -1 1)) | |
1012 0) | |
1013 (if backward-flag | |
1014 (goto-char (point-max)) | |
1015 (goto-char (point-min))) | |
1016 (beginning-of-line)) | |
1017 (point)) | |
1018 point-before-current-button) | |
1019 (when (and (get-text-property (point) 'mh-data) | |
1020 (funcall criterion (point))) | |
1021 (return-from loop (point)))) | |
1022 nil))) | |
1023 (point)))) | |
1024 | |
1025 (defun mh-widget-press-button (widget el) | |
1026 "Callback for widget, WIDGET. | |
1027 Parameter EL is unused." | |
1028 (goto-char (widget-get widget :from)) | |
1029 (mh-press-button)) | |
1030 | |
1031 (defun mh-press-button () | |
1032 "View contents of button. | |
1033 | |
1034 This command is a toggle so if you use it again on the same | |
1035 attachment, the attachment is hidden." | |
1036 (interactive) | |
1037 (let ((mm-inline-media-tests mh-mm-inline-media-tests) | |
1038 (data (get-text-property (point) 'mh-data)) | |
1039 (function (get-text-property (point) 'mh-callback)) | |
1040 (buffer-read-only nil) | |
1041 (folder mh-show-folder-buffer)) | |
1042 (flet ((mm-handle-set-external-undisplayer | |
1043 (handle function) | |
1044 (mh-handle-set-external-undisplayer folder handle function))) | |
1045 (when (and function (eolp)) | |
1046 (backward-char)) | |
1047 (unwind-protect (and function (funcall function data)) | |
1048 (set-buffer-modified-p nil))))) | |
1049 | |
1050 (defun mh-push-button (event) | |
1051 "Click MIME button for EVENT. | |
1052 | |
1053 If the MIME part is visible then it is removed. Otherwise the | |
1054 part is displayed. This function is called when the mouse is used | |
1055 to click the MIME button." | |
1056 (interactive "e") | |
1057 (mh-do-at-event-location event | |
1058 (let ((folder mh-show-folder-buffer) | |
1059 (mm-inline-media-tests mh-mm-inline-media-tests) | |
1060 (data (get-text-property (point) 'mh-data)) | |
1061 (function (get-text-property (point) 'mh-callback))) | |
1062 (flet ((mm-handle-set-external-undisplayer (handle func) | |
1063 (mh-handle-set-external-undisplayer folder handle func))) | |
1064 (and function (funcall function data)))))) | |
1065 | |
1066 (defun mh-handle-set-external-undisplayer (folder handle function) | |
1067 "Replacement for `mm-handle-set-external-undisplayer'. | |
1068 | |
1069 This is only called in recent versions of Gnus. The MIME handles | |
1070 are stored in data structures corresponding to MH-E folder buffer | |
1071 FOLDER instead of in Gnus (as in the original). The MIME part, | |
1072 HANDLE is associated with the undisplayer FUNCTION." | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
1073 (if (mh-mm-keep-viewer-alive-p handle) |
68465 | 1074 (let ((new-handle (copy-sequence handle))) |
1075 (mm-handle-set-undisplayer new-handle function) | |
1076 (mm-handle-set-undisplayer handle nil) | |
1077 (save-excursion | |
1078 (set-buffer folder) | |
1079 (push new-handle (mh-mime-handles (mh-buffer-data))))) | |
1080 (mm-handle-set-undisplayer handle function))) | |
1081 | |
1082 (defun mh-mime-security-press-button (handle) | |
1083 "Callback from security button for part HANDLE." | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
1084 (if (mh-mm-handle-multipart-ctl-parameter handle 'gnus-info) |
68465 | 1085 (mh-mime-security-show-details handle) |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
1086 (let ((region (mh-mm-handle-multipart-ctl-parameter handle 'mh-region)) |
68465 | 1087 point) |
1088 (setq point (point)) | |
1089 (goto-char (car region)) | |
1090 (delete-region (car region) (cdr region)) | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
1091 (with-current-buffer (mh-mm-handle-multipart-ctl-parameter handle 'buffer) |
68465 | 1092 (let* ((mm-verify-option 'known) |
1093 (mm-decrypt-option 'known) | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
1094 (new (mh-mm-possibly-verify-or-decrypt (cdr handle) handle))) |
68465 | 1095 (unless (eq new (cdr handle)) |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
1096 (mh-mm-destroy-parts (cdr handle)) |
68465 | 1097 (setcdr handle new)))) |
1098 (mh-mime-display-security handle) | |
1099 (goto-char point)))) | |
1100 | |
1101 ;; I rewrote the security part because Gnus doesn't seem to ever minimize | |
1102 ;; the button. That is once the mime-security button is pressed there seems | |
1103 ;; to be no way of getting rid of the inserted text. | |
1104 (defun mh-mime-security-show-details (handle) | |
1105 "Toggle display of detailed security info for HANDLE." | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
1106 (let ((details (mh-mm-handle-multipart-ctl-parameter handle 'gnus-details))) |
68465 | 1107 (when details |
1108 (let ((mh-mime-security-button-pressed | |
1109 (not (get-text-property (point) 'mh-button-pressed))) | |
1110 (mh-mime-security-button-line-format | |
1111 (get-text-property (point) 'mh-line-format))) | |
1112 (forward-char -1) | |
1113 (while (eq (get-text-property (point) 'mh-line-format) | |
1114 mh-mime-security-button-line-format) | |
1115 (forward-char -1)) | |
1116 (forward-char) | |
1117 (save-restriction | |
1118 (narrow-to-region (point) (point)) | |
1119 (mh-insert-mime-security-button handle)) | |
1120 (delete-region | |
1121 (point) | |
1122 (or (text-property-not-all | |
1123 (point) (point-max) | |
1124 'mh-line-format mh-mime-security-button-line-format) | |
1125 (point-max))) | |
1126 (forward-line -1))))) | |
1127 | |
1128 | |
1129 | |
1130 ;;; Miscellaneous Article Washing | |
1131 | |
1132 ;;;###mh-autoload | |
1133 (defun mh-add-missing-mime-version-header () | |
1134 "Some mail programs don't put a MIME-Version header. | |
1135 I have seen this only in spam, so maybe we shouldn't fix | |
1136 this ;-)" | |
1137 (save-excursion | |
1138 (goto-char (point-min)) | |
1139 (re-search-forward "\n\n" nil t) | |
1140 (save-restriction | |
1141 (narrow-to-region (point-min) (point)) | |
1142 (when (and (message-fetch-field "content-type") | |
1143 (not (message-fetch-field "mime-version"))) | |
1144 (goto-char (point-min)) | |
1145 (insert "MIME-Version: 1.0\n"))))) | |
1146 | |
1147 ;;;###mh-autoload | |
1148 (defun mh-display-smileys () | |
1149 "Display smileys." | |
1150 (when (and mh-graphical-smileys-flag (mh-small-show-buffer-p)) | |
1151 (mh-funcall-if-exists smiley-region (point-min) (point-max)))) | |
1152 | |
1153 ;;;###mh-autoload | |
1154 (defun mh-display-emphasis () | |
1155 "Display graphical emphasis." | |
1156 (when (and mh-graphical-emphasis-flag (mh-small-show-buffer-p)) | |
1157 (flet ((article-goto-body ())) ; shadow this function to do nothing | |
1158 (save-excursion | |
1159 (goto-char (point-min)) | |
1160 (article-emphasize))))) | |
1161 | |
1162 (defun mh-small-show-buffer-p () | |
1163 "Check if show buffer is small. | |
1164 This is used to decide if smileys and graphical emphasis should be | |
1165 displayed." | |
1166 (let ((max nil)) | |
1167 (when (and (boundp 'font-lock-maximum-size) font-lock-maximum-size) | |
1168 (cond ((numberp font-lock-maximum-size) | |
1169 (setq max font-lock-maximum-size)) | |
1170 ((listp font-lock-maximum-size) | |
1171 (setq max (cdr (or (assoc 'mh-show-mode font-lock-maximum-size) | |
1172 (assoc t font-lock-maximum-size))))))) | |
1173 (or (not (numberp max)) (>= (/ max 8) (buffer-size))))) | |
1174 | |
1175 | |
1176 | |
1177 ;;; MH-Letter Commands | |
1178 | |
1179 ;; MH-E commands are alphabetical; specific support routines follow command. | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1180 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1181 ;;;###mh-autoload |
68130
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1182 (defun mh-compose-forward (&optional description folder range) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1183 "Add tag to forward a message. |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1184 |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1185 You are prompted for a content DESCRIPTION, the name of the |
68130
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1186 FOLDER in which the messages to forward are located, and a RANGE |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1187 of messages, which defaults to the current message in that |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1188 folder. Check the documentation of `mh-interactive-range' to see |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1189 how RANGE is read in interactive use. |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1190 |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1191 The option `mh-compose-insertion' controls what type of tags are inserted." |
68130
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1192 (interactive |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1193 (let* ((description |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1194 (mml-minibuffer-read-description)) |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1195 (folder |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1196 (mh-prompt-for-folder "Message from" |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1197 mh-sent-from-folder nil)) |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1198 (default |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1199 (if (and (equal folder mh-sent-from-folder) |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1200 (numberp mh-sent-from-msg)) |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1201 mh-sent-from-msg |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1202 (nth 0 (mh-translate-range folder "cur")))) |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1203 (range |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1204 (mh-read-range "Forward" folder |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1205 (or (and default |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1206 (number-to-string default)) |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1207 t) |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1208 t t))) |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1209 (list description folder range))) |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1210 (let ((messages (mapconcat 'identity (mh-list-to-string range) " "))) |
dfa5a760e24f
* mh-comp.el (mh-insert-letter): If you choose a different folder, the
Bill Wohler <wohler@newt.com>
parents:
68125
diff
changeset
|
1211 (dolist (message (mh-translate-range folder messages)) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1212 (if (equal mh-compose-insertion 'mml) |
68104
b10ff4551ab2
Use consistent verbiage with compiler defvars.
Bill Wohler <wohler@newt.com>
parents:
68096
diff
changeset
|
1213 (mh-mml-forward-message description folder (format "%s" message)) |
b10ff4551ab2
Use consistent verbiage with compiler defvars.
Bill Wohler <wohler@newt.com>
parents:
68096
diff
changeset
|
1214 (mh-mh-forward-message description folder (format "%s" message)))))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1215 |
68465 | 1216 ;;;###mh-autoload |
1217 (defun mh-mml-forward-message (description folder message) | |
1218 "Forward a message as attachment. | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1219 |
68465 | 1220 The function will prompt the user for a DESCRIPTION, a FOLDER and |
1221 MESSAGE number." | |
1222 (let ((msg (if (and (equal message "") (numberp mh-sent-from-msg)) | |
1223 mh-sent-from-msg | |
1224 (string-to-number message)))) | |
1225 (cond ((integerp msg) | |
82476
c4d5c23a6b0a
(mh-mml-forward-message): Address SF 1378993 and
Jeffrey C Honig <jch@bsdi.com>
parents:
82473
diff
changeset
|
1226 (mml-attach-file (format "%s%s/%d" |
c4d5c23a6b0a
(mh-mml-forward-message): Address SF 1378993 and
Jeffrey C Honig <jch@bsdi.com>
parents:
82473
diff
changeset
|
1227 mh-user-path (substring folder 1) msg) |
c4d5c23a6b0a
(mh-mml-forward-message): Address SF 1378993 and
Jeffrey C Honig <jch@bsdi.com>
parents:
82473
diff
changeset
|
1228 "message/rfc822" |
c4d5c23a6b0a
(mh-mml-forward-message): Address SF 1378993 and
Jeffrey C Honig <jch@bsdi.com>
parents:
82473
diff
changeset
|
1229 (if (string= "" description) nil description) |
c4d5c23a6b0a
(mh-mml-forward-message): Address SF 1378993 and
Jeffrey C Honig <jch@bsdi.com>
parents:
82473
diff
changeset
|
1230 "inline")) |
68465 | 1231 (t (error "The message number, %s, is not a integer" msg))))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1232 |
68465 | 1233 (defun mh-mh-forward-message (&optional description folder messages) |
1234 "Add tag to forward a message. | |
1235 You are prompted for a content DESCRIPTION, the name of the | |
1236 FOLDER in which the messages to forward are located, and the | |
1237 MESSAGES' numbers. | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1238 |
68465 | 1239 See also \\[mh-mh-to-mime]." |
1240 (interactive (list | |
1241 (mml-minibuffer-read-description) | |
1242 (mh-prompt-for-folder "Message from" mh-sent-from-folder nil) | |
1243 (read-string (concat "Messages" | |
1244 (if (numberp mh-sent-from-msg) | |
1245 (format " (default %d): " | |
1246 mh-sent-from-msg) | |
1247 ": "))))) | |
1248 (beginning-of-line) | |
1249 (insert "#forw [") | |
1250 (and description | |
1251 (not (string= description "")) | |
1252 (insert description)) | |
1253 (insert "]") | |
1254 (and folder | |
1255 (not (string= folder "")) | |
1256 (insert " " folder)) | |
1257 (if (and messages | |
1258 (not (string= messages ""))) | |
1259 (let ((start (point))) | |
1260 (insert " " messages) | |
1261 (subst-char-in-region start (point) ?, ? )) | |
1262 (if (numberp mh-sent-from-msg) | |
1263 (insert " " (int-to-string mh-sent-from-msg)))) | |
1264 (insert "\n")) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1265 |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1266 ;;;###mh-autoload |
68465 | 1267 (defun mh-compose-insertion (&optional inline) |
1268 "Add tag to include a file such as an image or sound. | |
1269 | |
1270 You are prompted for the filename containing the object, the | |
1271 media type if it cannot be determined automatically, and a | |
1272 content description. If you're using MH-style directives, you | |
1273 will also be prompted for additional attributes. | |
1274 | |
1275 The option `mh-compose-insertion' controls what type of tags are | |
1276 inserted. Optional argument INLINE means make it an inline | |
1277 attachment." | |
1278 (interactive "P") | |
1279 (if (equal mh-compose-insertion 'mml) | |
1280 (if inline | |
1281 (mh-mml-attach-file "inline") | |
1282 (mh-mml-attach-file)) | |
1283 (call-interactively 'mh-mh-attach-file))) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1284 |
68465 | 1285 (defun mh-mml-attach-file (&optional disposition) |
1286 "Add a tag to insert a MIME message part from a file. | |
1287 | |
1288 You are prompted for the filename containing the object, the | |
1289 media type if it cannot be determined automatically, a content | |
1290 description and the DISPOSITION of the attachment. | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1291 |
68465 | 1292 This is basically `mml-attach-file' from Gnus, modified such that a prefix |
1293 argument yields an \"inline\" disposition and Content-Type is determined | |
1294 automatically." | |
1295 (let* ((file (mml-minibuffer-read-file "Attach file: ")) | |
1296 (type (mh-minibuffer-read-type file)) | |
1297 (description (mml-minibuffer-read-description)) | |
1298 (dispos (or disposition | |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
1299 (mh-mml-minibuffer-read-disposition type)))) |
68465 | 1300 (mml-insert-empty-tag 'part 'type type 'filename file |
1301 'disposition dispos 'description description))) | |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1302 |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1303 (defun mh-mh-attach-file (filename type description attributes) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1304 "Add a tag to insert a MIME message part from a file. |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1305 You are prompted for the FILENAME containing the object, the |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1306 media TYPE if it cannot be determined automatically, and a |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1307 content DESCRIPTION. In addition, you are also prompted for |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1308 additional ATTRIBUTES. |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1309 |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1310 See also \\[mh-mh-to-mime]." |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1311 (interactive (let ((filename (mml-minibuffer-read-file "Attach file: "))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1312 (list |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1313 filename |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1314 (mh-minibuffer-read-type filename) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1315 (mml-minibuffer-read-description) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1316 (read-string "Attributes: " |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1317 (concat "name=\"" |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1318 (file-name-nondirectory filename) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1319 "\""))))) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1320 (mh-mh-compose-type filename type description attributes)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1321 |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1322 (defun mh-mh-compose-type (filename type |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1323 &optional description attributes comment) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1324 "Insert an MH-style directive to insert a file. |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1325 The file specified by FILENAME is encoded as TYPE. An optional |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1326 DESCRIPTION is used as the Content-Description field, optional |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1327 set of ATTRIBUTES and an optional COMMENT can also be included." |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1328 (beginning-of-line) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1329 (insert "#" type) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1330 (and attributes |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1331 (insert "; " attributes)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1332 (and comment |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1333 (insert " (" comment ")")) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1334 (insert " [") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1335 (and description |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1336 (insert description)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1337 (insert "] " (expand-file-name filename)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1338 (insert "\n")) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1339 |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1340 ;;;###mh-autoload |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1341 (defun mh-mh-compose-anon-ftp (host filename type description) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1342 "Add tag to include anonymous ftp reference to a file. |
67988
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1343 |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1344 You can have your message initiate an \"ftp\" transfer when the |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1345 recipient reads the message. You are prompted for the remote HOST |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1346 and FILENAME, the media TYPE, and the content DESCRIPTION. |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1347 |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1348 See also \\[mh-mh-to-mime]." |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1349 (interactive (list |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1350 (read-string "Remote host: ") |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1351 (read-string "Remote filename: ") |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1352 (mh-minibuffer-read-type "DUMMY-FILENAME") |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1353 (mml-minibuffer-read-description))) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1354 (mh-mh-compose-external-type "anon-ftp" host filename |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1355 type description)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1356 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1357 ;;;###mh-autoload |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1358 (defun mh-mh-compose-external-compressed-tar (host filename description) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1359 "Add tag to include anonymous ftp reference to a compressed tar file. |
67988
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1360 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1361 In addition to retrieving the file via anonymous \"ftp\" as per |
67988
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1362 the command \\[mh-mh-compose-anon-ftp], the file will also be |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1363 uncompressed and untarred. You are prompted for the remote HOST |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1364 and FILENAME and the content DESCRIPTION. |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1365 |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1366 See also \\[mh-mh-to-mime]." |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1367 (interactive (list |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1368 (read-string "Remote host: ") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1369 (read-string "Remote filename: ") |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1370 (mml-minibuffer-read-description))) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1371 (mh-mh-compose-external-type "anon-ftp" host filename |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1372 "application/octet-stream" |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1373 description |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1374 "type=tar; conversions=x-compress" |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1375 "mode=image")) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1376 |
68465 | 1377 ;; RFC 2045 - Multipurpose Internet Mail Extensions (MIME) Part One: |
1378 ;; Format of Internet Message Bodies. | |
1379 ;; RFC 2046 - Multipurpose Internet Mail Extensions (MIME) Part Two: | |
1380 ;; Media Types. | |
1381 ;; RFC 2049 - Multipurpose Internet Mail Extensions (MIME) Part Five: | |
1382 ;; Conformance Criteria and Examples. | |
1383 ;; RFC 2017 - Definition of the URL MIME External-Body Access-Type | |
1384 ;; RFC 1738 - Uniform Resource Locators (URL) | |
1385 (defvar mh-access-types | |
1386 '(("anon-ftp") ; RFC2046 Anonymous File Transfer Protocol | |
1387 ("file") ; RFC1738 Host-specific file names | |
1388 ("ftp") ; RFC2046 File Transfer Protocol | |
1389 ("gopher") ; RFC1738 The Gopher Protocol | |
1390 ("http") ; RFC1738 Hypertext Transfer Protocol | |
1391 ("local-file") ; RFC2046 Local file access | |
1392 ("mail-server") ; RFC2046 mail-server Electronic mail address | |
1393 ("mailto") ; RFC1738 Electronic mail address | |
1394 ("news") ; RFC1738 Usenet news | |
1395 ("nntp") ; RFC1738 Usenet news using NNTP access | |
1396 ("propspero") ; RFC1738 Prospero Directory Service | |
1397 ("telnet") ; RFC1738 Telnet | |
1398 ("tftp") ; RFC2046 Trivial File Transfer Protocol | |
1399 ("url") ; RFC2017 URL scheme MIME access-type Protocol | |
1400 ("wais")) ; RFC1738 Wide Area Information Servers | |
1401 "Valid MIME access-type values.") | |
1402 | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1403 ;;;###mh-autoload |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1404 (defun mh-mh-compose-external-type (access-type host filename type |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1405 &optional description |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1406 attributes parameters |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1407 comment) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1408 "Add tag to refer to a remote file. |
67988
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1409 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1410 This command is a general utility for referencing external files. |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1411 In fact, all of the other commands that insert directives to |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1412 access external files call this command. You are prompted for the |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1413 ACCESS-TYPE, remote HOST and FILENAME, and content TYPE. If you |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1414 provide a prefix argument, you are also prompted for a content |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1415 DESCRIPTION, ATTRIBUTES, PARAMETERS, and a COMMENT. |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1416 |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1417 See also \\[mh-mh-to-mime]." |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1418 (interactive (list |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1419 (completing-read "Access type: " mh-access-types) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1420 (read-string "Remote host: ") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1421 (read-string "Remote filename: ") |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1422 (mh-minibuffer-read-type "DUMMY-FILENAME") |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1423 (if current-prefix-arg (mml-minibuffer-read-description)) |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1424 (if current-prefix-arg (read-string "Attributes: ")) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1425 (if current-prefix-arg (read-string "Parameters: ")) |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1426 (if current-prefix-arg (read-string "Comment: ")))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1427 (beginning-of-line) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1428 (insert "#@" type) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1429 (and attributes |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1430 (insert "; " attributes)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1431 (and comment |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1432 (insert " (" comment ") ")) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1433 (insert " [") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1434 (and description |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1435 (insert description)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1436 (insert "] ") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1437 (insert "access-type=" access-type "; ") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1438 (insert "site=" host) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1439 (insert "; name=" (file-name-nondirectory filename)) |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1440 (let ((directory (file-name-directory filename))) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1441 (and directory |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1442 (insert "; directory=\"" directory "\""))) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1443 (and parameters |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1444 (insert "; " parameters)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1445 (insert "\n")) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1446 |
68465 | 1447 (defvar mh-mh-to-mime-args nil |
1448 "Extra arguments for \\[mh-mh-to-mime] to pass to the \"mhbuild\" command. | |
1449 The arguments are passed to \"mhbuild\" if \\[mh-mh-to-mime] is | |
1450 given a prefix argument. Normally default arguments to | |
1451 \"mhbuild\" are specified in the MH profile.") | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1452 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1453 ;;;###mh-autoload |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1454 (defun mh-mh-to-mime (&optional extra-args) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1455 "Compose MIME message from MH-style directives. |
67756
7ff92ad99326
* mh-alias.el (mh-alias-reload): Sync docstrings with manual.
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
1456 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1457 Typically, you send a message with attachments just like any other |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1458 message. However, you may take a sneak preview of the MIME encoding if |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1459 you wish by running this command. |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1460 |
67988
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1461 If you wish to pass additional arguments to \"mhbuild\" (\"mhn\") |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1462 to affect how it builds your message, use the option |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1463 `mh-mh-to-mime-args'. For example, you can build a consistency |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1464 check into the message by setting `mh-mh-to-mime-args' to |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1465 \"-check\". The recipient of your message can then run \"mhbuild |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1466 -check\" on the message--\"mhbuild\" (\"mhn\") will complain if |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1467 the message has been corrupted on the way. This command only |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1468 consults this option when given a prefix argument EXTRA-ARGS. |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1469 |
67756
7ff92ad99326
* mh-alias.el (mh-alias-reload): Sync docstrings with manual.
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
1470 The hook `mh-mh-to-mime-hook' is called after the message has been |
7ff92ad99326
* mh-alias.el (mh-alias-reload): Sync docstrings with manual.
Bill Wohler <wohler@newt.com>
parents:
67681
diff
changeset
|
1471 formatted. |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1472 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1473 The effects of this command can be undone by running |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1474 \\[mh-mh-to-mime-undo]." |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1475 (interactive "*P") |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1476 (mh-mh-quote-unescaped-sharp) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1477 (save-buffer) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1478 (message "Running %s..." (if (mh-variant-p 'nmh) "mhbuild" "mhn")) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1479 (cond |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1480 ((mh-variant-p 'nmh) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1481 (mh-exec-cmd-error nil |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1482 "mhbuild" |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1483 (if extra-args mh-mh-to-mime-args) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1484 buffer-file-name)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1485 (t |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1486 (mh-exec-cmd-error (format "mhdraft=%s" buffer-file-name) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1487 "mhn" |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1488 (if extra-args mh-mh-to-mime-args) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1489 buffer-file-name))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1490 (revert-buffer t t) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1491 (message "Running %s...done" (if (mh-variant-p 'nmh) "mhbuild" "mhn")) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1492 (run-hooks 'mh-mh-to-mime-hook)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1493 |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1494 (defun mh-mh-quote-unescaped-sharp () |
67760
9c3504ae6060
Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents:
67759
diff
changeset
|
1495 "Quote \"#\" characters that haven't been quoted for \"mhbuild\". |
9c3504ae6060
Follow MH-E Developers Guide conventions. Use `' quotes for Help
Bill Wohler <wohler@newt.com>
parents:
67759
diff
changeset
|
1496 If the \"#\" character is present in the first column, but it isn't |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1497 part of a MH-style directive then \"mhbuild\" gives an error. |
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1498 This function will quote all such characters." |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1499 (save-excursion |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1500 (goto-char (point-min)) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1501 (while (re-search-forward "^#" nil t) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1502 (beginning-of-line) |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
1503 (unless (mh-mh-directive-present-p (point) (mh-line-end-position)) |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1504 (insert "#")) |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
1505 (goto-char (mh-line-end-position))))) |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1506 |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1507 ;;;###mh-autoload |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1508 (defun mh-mh-to-mime-undo (noconfirm) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1509 "Undo effects of \\[mh-mh-to-mime]. |
67988
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1510 |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1511 It does this by reverting to a backup file. You are prompted to |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1512 confirm this action, but you can avoid the confirmation by adding |
7882fc7df359
* mh-alias.el (mh-alias-grab-from-field): Remove leading * from
Bill Wohler <wohler@newt.com>
parents:
67984
diff
changeset
|
1513 a prefix argument NOCONFIRM." |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1514 (interactive "*P") |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1515 (if (null buffer-file-name) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1516 (error "Buffer does not seem to be associated with any file")) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1517 (let ((backup-strings '("," "#")) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1518 backup-file) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1519 (while (and backup-strings |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1520 (not (file-exists-p |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1521 (setq backup-file |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1522 (concat (file-name-directory buffer-file-name) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1523 (car backup-strings) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1524 (file-name-nondirectory buffer-file-name) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1525 ".orig"))))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1526 (setq backup-strings (cdr backup-strings))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1527 (or backup-strings |
68013
bbc0e52abce5
* mh-alias.el (mh-alias-add-alias): Grand message and error string
Bill Wohler <wohler@newt.com>
parents:
68012
diff
changeset
|
1528 (error "Backup file for %s no longer exists" buffer-file-name)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1529 (or noconfirm |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1530 (yes-or-no-p (format "Revert buffer from file %s? " |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1531 backup-file)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1532 (error "Revert not confirmed")) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1533 (let ((buffer-read-only nil)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1534 (erase-buffer) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1535 (insert-file-contents backup-file)) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1536 (after-find-file nil))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1537 |
68465 | 1538 ;; Shush compiler. |
70027
0e0916499a15
* mh-funcs.el (view-exit-action): No need to wrap defvar with
Bill Wohler <wohler@newt.com>
parents:
69188
diff
changeset
|
1539 (defvar mh-identity-pgg-default-user-id) |
68465 | 1540 |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
1541 ;;;###mh-autoload |
68465 | 1542 (defun mh-mml-secure-message-encrypt (method) |
1543 "Add tag to encrypt the message. | |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
1544 |
68465 | 1545 A proper multipart message is created for you when you send the |
1546 message. Use the command \\[mh-mml-unsecure-message] to remove | |
1547 this tag. Use a prefix argument METHOD to be prompted for one of | |
1548 the possible security methods (see `mh-mml-method-default')." | |
1549 (interactive (list (mh-mml-query-cryptographic-method))) | |
1550 (mh-secure-message method "encrypt" mh-identity-pgg-default-user-id)) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1551 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1552 ;;;###mh-autoload |
68465 | 1553 (defun mh-mml-secure-message-sign (method) |
1554 "Add tag to sign the message. | |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1555 |
68465 | 1556 A proper multipart message is created for you when you send the |
1557 message. Use the command \\[mh-mml-unsecure-message] to remove | |
1558 this tag. Use a prefix argument METHOD to be prompted for one of | |
1559 the possible security methods (see `mh-mml-method-default')." | |
1560 (interactive (list (mh-mml-query-cryptographic-method))) | |
1561 (mh-secure-message method "sign" mh-identity-pgg-default-user-id)) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1562 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1563 ;;;###mh-autoload |
68465 | 1564 (defun mh-mml-secure-message-signencrypt (method) |
1565 "Add tag to encrypt and sign the message. | |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1566 |
68465 | 1567 A proper multipart message is created for you when you send the |
1568 message. Use the command \\[mh-mml-unsecure-message] to remove | |
1569 this tag. Use a prefix argument METHOD to be prompted for one of | |
1570 the possible security methods (see `mh-mml-method-default')." | |
1571 (interactive (list (mh-mml-query-cryptographic-method))) | |
1572 (mh-secure-message method "signencrypt" mh-identity-pgg-default-user-id)) | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1573 |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1574 (defvar mh-mml-cryptographic-method-history ()) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1575 |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1576 (defun mh-mml-query-cryptographic-method () |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1577 "Read the cryptographic method to use." |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1578 (if current-prefix-arg |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1579 (let ((def (or (car mh-mml-cryptographic-method-history) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1580 mh-mml-method-default))) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1581 (completing-read (format "Method (default %s): " def) |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1582 '(("pgp") ("pgpmime") ("smime")) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1583 nil t nil 'mh-mml-cryptographic-method-history def)) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1584 mh-mml-method-default)) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1585 |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1586 (defun mh-secure-message (method mode &optional identity) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1587 "Add tag to encrypt or sign message. |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1588 |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1589 METHOD should be one of: \"pgpmime\", \"pgp\", \"smime\". |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1590 MODE should be one of: \"sign\", \"encrypt\", \"signencrypt\", \"none\". |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1591 IDENTITY is optionally the default-user-id to use." |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1592 (if (not mh-pgp-support-flag) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1593 (error "Your version of Gnus does not support PGP/GPG") |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1594 ;; Check the arguments |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1595 (let ((valid-methods (list "pgpmime" "pgp" "smime")) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1596 (valid-modes (list "sign" "encrypt" "signencrypt" "none"))) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1597 (if (not (member method valid-methods)) |
68013
bbc0e52abce5
* mh-alias.el (mh-alias-add-alias): Grand message and error string
Bill Wohler <wohler@newt.com>
parents:
68012
diff
changeset
|
1598 (error "Method %s is invalid" method)) |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1599 (if (not (member mode valid-modes)) |
68013
bbc0e52abce5
* mh-alias.el (mh-alias-add-alias): Grand message and error string
Bill Wohler <wohler@newt.com>
parents:
68012
diff
changeset
|
1600 (error "Mode %s is invalid" mode)) |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1601 (mml-unsecure-message) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1602 (if (not (string= mode "none")) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1603 (save-excursion |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1604 (goto-char (point-min)) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1605 (mh-goto-header-end 1) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1606 (if mh-identity-pgg-default-user-id |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1607 (mml-insert-tag 'secure 'method method 'mode mode |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1608 'sender mh-identity-pgg-default-user-id) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1609 (mml-insert-tag 'secure 'method method 'mode mode))))))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1610 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1611 ;;;###mh-autoload |
68465 | 1612 (defun mh-mml-to-mime () |
1613 "Compose MIME message from MML tags. | |
1614 | |
1615 Typically, you send a message with attachments just like any | |
1616 other message. However, you may take a sneak preview of the MIME | |
1617 encoding if you wish by running this command. | |
1618 | |
1619 This action can be undone by running \\[undo]." | |
1620 (interactive) | |
1621 (require 'message) | |
82473
d318e41ee7db
(mh-mml-to-mime): GPG requires e-mail addresses, not
Jeffrey C Honig <jch@bsdi.com>
parents:
78231
diff
changeset
|
1622 (when mh-pgp-support-flag |
d318e41ee7db
(mh-mml-to-mime): GPG requires e-mail addresses, not
Jeffrey C Honig <jch@bsdi.com>
parents:
78231
diff
changeset
|
1623 ;; PGP requires actual e-mail addresses, not aliases. |
88078
3f6a9fe50cce
(mh-mml-to-mime): Don't look up sender if From absent. Fixes "Wrong
Bill Wohler <wohler@newt.com>
parents:
87649
diff
changeset
|
1624 ;; Parse the recipients and sender from the message. |
82473
d318e41ee7db
(mh-mml-to-mime): GPG requires e-mail addresses, not
Jeffrey C Honig <jch@bsdi.com>
parents:
78231
diff
changeset
|
1625 (message-options-set-recipient) |
88078
3f6a9fe50cce
(mh-mml-to-mime): Don't look up sender if From absent. Fixes "Wrong
Bill Wohler <wohler@newt.com>
parents:
87649
diff
changeset
|
1626 ;; Do an alias lookup on sender (if From field is present). |
3f6a9fe50cce
(mh-mml-to-mime): Don't look up sender if From absent. Fixes "Wrong
Bill Wohler <wohler@newt.com>
parents:
87649
diff
changeset
|
1627 (when (message-options-get 'message-sender) |
3f6a9fe50cce
(mh-mml-to-mime): Don't look up sender if From absent. Fixes "Wrong
Bill Wohler <wohler@newt.com>
parents:
87649
diff
changeset
|
1628 (message-options-set 'message-sender |
3f6a9fe50cce
(mh-mml-to-mime): Don't look up sender if From absent. Fixes "Wrong
Bill Wohler <wohler@newt.com>
parents:
87649
diff
changeset
|
1629 (mail-strip-quoted-names |
3f6a9fe50cce
(mh-mml-to-mime): Don't look up sender if From absent. Fixes "Wrong
Bill Wohler <wohler@newt.com>
parents:
87649
diff
changeset
|
1630 (mh-alias-expand |
3f6a9fe50cce
(mh-mml-to-mime): Don't look up sender if From absent. Fixes "Wrong
Bill Wohler <wohler@newt.com>
parents:
87649
diff
changeset
|
1631 (message-options-get 'message-sender))))) |
82473
d318e41ee7db
(mh-mml-to-mime): GPG requires e-mail addresses, not
Jeffrey C Honig <jch@bsdi.com>
parents:
78231
diff
changeset
|
1632 ;; Do an alias lookup on recipients |
d318e41ee7db
(mh-mml-to-mime): GPG requires e-mail addresses, not
Jeffrey C Honig <jch@bsdi.com>
parents:
78231
diff
changeset
|
1633 (message-options-set 'message-recipients |
d318e41ee7db
(mh-mml-to-mime): GPG requires e-mail addresses, not
Jeffrey C Honig <jch@bsdi.com>
parents:
78231
diff
changeset
|
1634 (mapconcat |
d318e41ee7db
(mh-mml-to-mime): GPG requires e-mail addresses, not
Jeffrey C Honig <jch@bsdi.com>
parents:
78231
diff
changeset
|
1635 '(lambda (ali) |
d318e41ee7db
(mh-mml-to-mime): GPG requires e-mail addresses, not
Jeffrey C Honig <jch@bsdi.com>
parents:
78231
diff
changeset
|
1636 (mail-strip-quoted-names (mh-alias-expand ali))) |
d318e41ee7db
(mh-mml-to-mime): GPG requires e-mail addresses, not
Jeffrey C Honig <jch@bsdi.com>
parents:
78231
diff
changeset
|
1637 (split-string (message-options-get 'message-recipients) "[, ]+") |
d318e41ee7db
(mh-mml-to-mime): GPG requires e-mail addresses, not
Jeffrey C Honig <jch@bsdi.com>
parents:
78231
diff
changeset
|
1638 ", "))) |
68465 | 1639 (let ((saved-text (buffer-string)) |
1640 (buffer (current-buffer)) | |
1641 (modified-flag (buffer-modified-p))) | |
1642 (condition-case err (mml-to-mime) | |
1643 (error | |
1644 (with-current-buffer buffer | |
1645 (delete-region (point-min) (point-max)) | |
1646 (insert saved-text) | |
1647 (set-buffer-modified-p modified-flag)) | |
1648 (error (error-message-string err)))))) | |
1649 | |
1650 ;;;###mh-autoload | |
67984
fb7a11feb83e
* mh-mime.el (mh-mml-unsecure-message): Remove unused argument.
Mark D. Baushke <mdb@gnu.org>
parents:
67969
diff
changeset
|
1651 (defun mh-mml-unsecure-message () |
fb7a11feb83e
* mh-mime.el (mh-mml-unsecure-message): Remove unused argument.
Mark D. Baushke <mdb@gnu.org>
parents:
67969
diff
changeset
|
1652 "Remove any secure message tags." |
fb7a11feb83e
* mh-mime.el (mh-mml-unsecure-message): Remove unused argument.
Mark D. Baushke <mdb@gnu.org>
parents:
67969
diff
changeset
|
1653 (interactive) |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1654 (if (not mh-pgp-support-flag) |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1655 (error "Your version of Gnus does not support PGP/GPG") |
56673
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1656 (mml-unsecure-message))) |
e9a6cbc8ca5e
Upgraded to MH-E version 7.4.80.
Bill Wohler <wohler@newt.com>
parents:
56406
diff
changeset
|
1657 |
68465 | 1658 |
67758
6b063593fdad
Follow Emacs coding conventions. Use default setting of
Bill Wohler <wohler@newt.com>
parents:
67756
diff
changeset
|
1659 |
68465 | 1660 ;;; Support Routines for MH-Letter Commands |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
1661 |
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
1662 ;;;###mh-autoload |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1663 (defun mh-mml-tag-present-p () |
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1664 "Check if the current buffer has text which may be a MML tag." |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
1665 (save-excursion |
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
1666 (goto-char (point-min)) |
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
1667 (re-search-forward |
68083
4aea781df851
(mh-mml-tag-present-p): Update regexp to handle <mml> tags inserted by
Bill Wohler <wohler@newt.com>
parents:
68013
diff
changeset
|
1668 (concat |
4aea781df851
(mh-mml-tag-present-p): Update regexp to handle <mml> tags inserted by
Bill Wohler <wohler@newt.com>
parents:
68013
diff
changeset
|
1669 "\\(<#\\(mml\\|part\\)\\(.\\|\n\\)*>[ \n\t]*<#/\\(mml\\|part\\)>\\|" |
4aea781df851
(mh-mml-tag-present-p): Update regexp to handle <mml> tags inserted by
Bill Wohler <wohler@newt.com>
parents:
68013
diff
changeset
|
1670 "^<#secure.+>$\\)") |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
1671 nil t))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1672 |
68465 | 1673 (defvar mh-media-type-regexp |
1674 (concat (regexp-opt '("text" "image" "audio" "video" "application" | |
1675 "multipart" "message") t) | |
1676 "/[-.+a-zA-Z0-9]+") | |
1677 "Regexp matching valid media types used in MIME attachment compositions.") | |
1678 | |
1679 ;;;###mh-autoload | |
1680 (defun mh-mh-directive-present-p (&optional begin end) | |
1681 "Check if the text between BEGIN and END might be a MH-style directive. | |
1682 The optional argument BEGIN defaults to the beginning of the | |
77941
0bd276ce7806
(mh-mh-directive-present-p): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
1683 buffer, while END defaults to the end of the buffer." |
68465 | 1684 (unless begin (setq begin (point-min))) |
1685 (unless end (setq end (point-max))) | |
1686 (save-excursion | |
1687 (block 'search-for-mh-directive | |
1688 (goto-char begin) | |
1689 (while (re-search-forward "^#" end t) | |
68529
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
1690 (let ((s (buffer-substring-no-properties |
7daec5f4a289
* mh-alias.el (mh-alias-gecos-name): Use mh-replace-regexp-in-string
Bill Wohler <wohler@newt.com>
parents:
68520
diff
changeset
|
1691 (point) (mh-line-end-position)))) |
68465 | 1692 (cond ((equal s "")) |
1693 ((string-match "^forw[ \t\n]+" s) | |
1694 (return-from 'search-for-mh-directive t)) | |
1695 (t (let ((first-token (car (split-string s "[ \t;@]")))) | |
1696 (when (and first-token | |
1697 (string-match mh-media-type-regexp | |
1698 first-token)) | |
1699 (return-from 'search-for-mh-directive t))))))) | |
1700 nil))) | |
1701 | |
1702 (defun mh-minibuffer-read-type (filename &optional default) | |
1703 "Return the content type associated with the given FILENAME. | |
1704 If the \"file\" command exists and recognizes the given file, | |
1705 then its value is returned\; otherwise, the user is prompted for | |
69188
bbe4019f0045
(mh-minibuffer-read-type): Deleted comment in docstring about obsolete
Bill Wohler <wohler@newt.com>
parents:
68947
diff
changeset
|
1706 a type (see `mailcap-mime-types'). |
68465 | 1707 Optional argument DEFAULT is returned if a type isn't entered." |
1708 (mailcap-parse-mimetypes) | |
1709 (let* ((default (or default | |
1710 (mm-default-file-encoding filename) | |
1711 "application/octet-stream")) | |
1712 (probed-type (mh-file-mime-type filename)) | |
1713 (type (or (and (not (equal probed-type "application/octet-stream")) | |
1714 probed-type) | |
1715 (completing-read | |
1716 (format "Content type (default %s): " default) | |
1717 (mapcar 'list (mailcap-mime-types)))))) | |
1718 (if (not (equal type "")) | |
1719 type | |
1720 default))) | |
1721 | |
1722 ;;;###mh-autoload | |
1723 (defun mh-file-mime-type (filename) | |
1724 "Return MIME type of FILENAME from file command. | |
1725 Returns nil if file command not on system." | |
1726 (cond | |
1727 ((not (mh-have-file-command)) | |
1728 nil) ;no file command, exit now | |
1729 ((not (and (file-exists-p filename) | |
1730 (file-readable-p filename))) | |
1731 nil) ;no file or not readable, ditto | |
1732 (t | |
1733 (save-excursion | |
1734 (let ((tmp-buffer (get-buffer-create mh-temp-buffer))) | |
1735 (set-buffer tmp-buffer) | |
1736 (unwind-protect | |
1737 (progn | |
1738 (call-process "file" nil '(t nil) nil "-b" "-i" | |
1739 (expand-file-name filename)) | |
1740 (goto-char (point-min)) | |
1741 (if (not (re-search-forward mh-media-type-regexp nil t)) | |
1742 nil | |
1743 (mh-file-mime-type-substitute (match-string 0) filename))) | |
1744 (kill-buffer tmp-buffer))))))) | |
1745 | |
1746 (defvar mh-file-mime-type-substitutions | |
1747 '(("application/msword" "\.xls" "application/ms-excel") | |
1748 ("application/msword" "\.ppt" "application/ms-powerpoint") | |
68620
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1749 ("text/plain" "\.vcf" "text/x-vcard") |
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1750 ("text/rtf" "\.rtf" "application/rtf") |
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1751 ("application/x-zip" "\.sxc" "application/vnd.sun.xml.calc") |
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1752 ("application/x-zip" "\.sxd" "application/vnd.sun.xml.draw") |
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1753 ("application/x-zip" "\.sxi" "application/vnd.sun.xml.impress") |
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1754 ("application/x-zip" "\.sxw" "application/vnd.sun.xml.writer") |
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1755 ("application/x-zip" "\.odg" "application/vnd.oasis.opendocument.graphics") |
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1756 ("application/x-zip" "\.odi" "application/vnd.oasis.opendocument.image") |
68947
bbac579a3af5
(mh-file-mime-type-substitutions): Remove trailing whitespace
Bill Wohler <wohler@newt.com>
parents:
68620
diff
changeset
|
1757 ("application/x-zip" "\.odp" |
68620
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1758 "application/vnd.oasis.opendocument.presentation") |
68947
bbac579a3af5
(mh-file-mime-type-substitutions): Remove trailing whitespace
Bill Wohler <wohler@newt.com>
parents:
68620
diff
changeset
|
1759 ("application/x-zip" "\.ods" |
68620
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1760 "application/vnd.oasis.opendocument.spreadsheet") |
f58b821a2f40
* mh-mime.el (mh-file-mime-type-substitutions): Added entries to
Peter Galbraith <galbraith@mixing.qc.dfo.ca>
parents:
68529
diff
changeset
|
1761 ("application/x-zip" "\.odt" "application/vnd.oasis.opendocument.text")) |
68465 | 1762 "Substitutions to make for Content-Type returned from file command. |
1763 The first element is the Content-Type returned by the file command. | |
1764 The second element is a regexp matching the file name, usually the | |
1765 extension. | |
1766 The third element is the Content-Type to replace with.") | |
1767 | |
1768 (defun mh-file-mime-type-substitute (content-type filename) | |
1769 "Return possibly changed CONTENT-TYPE on the FILENAME. | |
1770 Substitutions are made from the `mh-file-mime-type-substitutions' | |
1771 variable." | |
1772 (let ((subst mh-file-mime-type-substitutions) | |
1773 (type) (match) (answer content-type) | |
1774 (case-fold-search t)) | |
1775 (while subst | |
1776 (setq type (car (car subst)) | |
1777 match (elt (car subst) 1)) | |
1778 (if (and (string-equal content-type type) | |
1779 (string-match match filename)) | |
1780 (setq answer (elt (car subst) 2) | |
1781 subst nil) | |
1782 (setq subst (cdr subst)))) | |
1783 answer)) | |
1784 | |
1785 (defvar mh-have-file-command 'undefined | |
1786 "Cached value of function `mh-have-file-command'. | |
1787 Do not reference this variable directly as it might not have been | |
1788 initialized. Always use the command `mh-have-file-command'.") | |
1789 | |
1790 ;;;###mh-autoload | |
1791 (defun mh-have-file-command () | |
1792 "Return t if 'file' command is on the system. | |
1793 'file -i' is used to get MIME type of composition insertion." | |
1794 (when (eq mh-have-file-command 'undefined) | |
1795 (setq mh-have-file-command | |
1796 (and (fboundp 'executable-find) | |
1797 (executable-find "file") ; file command exists | |
1798 ; and accepts -i and -b args. | |
1799 (zerop (call-process "file" nil nil nil "-i" "-b" | |
1800 (expand-file-name "inc" mh-progs)))))) | |
1801 mh-have-file-command) | |
1802 | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1803 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1804 |
68465 | 1805 ;;; MIME Cleanup |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1806 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1807 ;;;###mh-autoload |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1808 (defun mh-mime-cleanup () |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1809 "Free the decoded MIME parts." |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1810 (let ((mime-data (gethash (current-buffer) mh-globals-hash))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1811 ;; This is for Emacs, what about XEmacs? |
50702
7dd3d5eae9c7
Upgraded to MH-E version 7.3.
Bill Wohler <wohler@newt.com>
parents:
49578
diff
changeset
|
1812 (mh-funcall-if-exists remove-images (point-min) (point-max)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1813 (when mime-data |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
1814 (mh-mm-destroy-parts (mh-mime-handles mime-data)) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1815 (remhash (current-buffer) mh-globals-hash)))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1816 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1817 ;;;###mh-autoload |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1818 (defun mh-destroy-postponed-handles () |
66354
cf99ce27df54
* mh-comp.el (mh-letter-menu): Rename
Bill Wohler <wohler@newt.com>
parents:
66087
diff
changeset
|
1819 "Free MIME data for externally displayed MIME parts." |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1820 (let ((mime-data (mh-buffer-data))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1821 (when mime-data |
68520
6a7173abcf59
* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument
Bill Wohler <wohler@newt.com>
parents:
68465
diff
changeset
|
1822 (mh-mm-destroy-parts (mh-mime-handles mime-data))) |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1823 (remhash (current-buffer) mh-globals-hash))) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1824 |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1825 (provide 'mh-mime) |
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1826 |
67681 | 1827 ;; Local Variables: |
1828 ;; indent-tabs-mode: nil | |
1829 ;; sentence-end-double-space: nil | |
1830 ;; End: | |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1831 |
67681 | 1832 ;; arch-tag: 0dd36518-1b64-4a84-8f4e-59f422d3f002 |
49459
06b77df47802
* mh-e: Created directory. ChangeLog will appear in a week when we
Bill Wohler <wohler@newt.com>
parents:
diff
changeset
|
1833 ;;; mh-mime.el ends here |