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