Mercurial > emacs
annotate lisp/mail/mh-mime.el @ 48540:283a6d8bdf2b
Comment.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 25 Nov 2002 19:06:07 +0000 |
parents | 2568d5a27317 |
children | 8aaba207e44b |
rev | line source |
---|---|
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
23305
diff
changeset
|
1 ;;; mh-mime.el --- mh-e support for composing MIME messages |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
2 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
3 ;; Copyright (C) 1993, 1995, 2001, 2002 Free Software Foundation, Inc. |
6365 | 4 |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
5 ;; Author: Bill Wohler <wohler@newt.com> |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
6 ;; Maintainer: Bill Wohler <wohler@newt.com> |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
7 ;; Keywords: mail |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
8 ;; See: mh-e.el |
6365 | 9 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
23305
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
6365 | 11 |
11333 | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
6365 | 13 ;; it under the terms of the GNU General Public License as published by |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
11333 | 17 ;; GNU Emacs is distributed in the hope that it will be useful, |
6365 | 18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
6365 | 26 |
27 ;;; Commentary: | |
28 | |
14169 | 29 ;; Internal support for mh-e package. |
30 ;; Support for generating an mhn composition file. | |
31 ;; MIME is supported only by MH 6.8 or later. | |
6365 | 32 |
11332 | 33 ;;; Change Log: |
34 | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
35 ;; $Id: mh-mime.el,v 1.26 2002/04/07 19:20:56 wohler Exp $ |
11332 | 36 |
6365 | 37 ;;; Code: |
38 | |
39 (provide 'mh-mime) | |
40 (require 'mh-comp) | |
41 | |
42 ;; To do: | |
43 ;; paragraph code should not fill # lines if MIME enabled. | |
44 ;; implement mh-auto-edit-mhn (if non-nil, \\[mh-send-letter] | |
45 ;; invokes mh-edit-mhn automatically before sending.) | |
46 ;; actually, instead of mh-auto-edit-mhn, | |
47 ;; should read automhnproc from profile | |
48 ;; MIME option to mh-forward | |
49 ;; command to move to content-description insertion point | |
50 | |
11332 | 51 (defvar mh-mhn-args nil |
52 "Extra arguments to have \\[mh-edit-mhn] pass to the \"mhn\" command. | |
53 The arguments are passed to mhn if \\[mh-edit-mhn] is given a | |
54 prefix argument. Normally default arguments to mhn are specified in the | |
55 MH profile.") | |
56 | |
57 (defvar mh-edit-mhn-hook nil | |
58 "Invoked on the formatted letter by \\<mh-letter-mode-map>\\[mh-edit-mhn].") | |
59 | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
60 (defun mh-have-file-command () |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
61 "Return t if 'file' command is on the system. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
62 'file -i' is used to get MIME type of composition insertion." |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
63 (when (not (boundp 'mh-have-file-command)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
64 (load "executable" t t) ; executable-find not autoloaded in emacs20 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
65 (setq mh-have-file-command |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
66 (and (fboundp 'executable-find) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
67 (executable-find "file") ; file command exists |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
68 ; and accepts -i and -b args. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
69 (zerop (call-process "file" nil nil nil "-i" "-b" |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
70 (expand-file-name "inc" mh-progs)))))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
71 mh-have-file-command) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
72 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
73 (defun mh-file-mime-type (filename) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
74 "Return MIME type of FILENAME from file command. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
75 Returns nil if file command not on system." |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
76 (cond |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
77 ((not (mh-have-file-command)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
78 nil) ;No file command, exit now. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
79 ((not (and (file-exists-p filename)(file-readable-p filename))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
80 nil) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
81 (t |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
82 (save-excursion |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
83 (let ((tmp-buffer (get-buffer-create mh-temp-buffer))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
84 (set-buffer tmp-buffer) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
85 (unwind-protect |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
86 (progn |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
87 (call-process "file" nil '(t nil) nil "-b" "-i" |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
88 (expand-file-name filename)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
89 (goto-char (point-min)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
90 (if (not (re-search-forward mh-media-type-regexp nil t)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
91 nil |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
92 (match-string 0))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
93 (kill-buffer tmp-buffer))))))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
94 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
95 (defvar mh-mhn-compose-insert-p nil |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
96 "Buffer-local variable to know whether MIME insertion was done. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
97 Triggers an automatic call to `mh-edit-mhn' in `mh-send-letter'.") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
98 (make-variable-buffer-local 'mh-mhn-compose-insert-p) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
99 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
100 ;;; This is needed for Emacs20 which doesn't have mailcap-mime-types. |
6365 | 101 (defvar mh-mime-content-types |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
102 '(("application/mac-binhex40") ("application/msword") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
103 ("application/octet-stream") ("application/pdf") ("application/pgp-keys") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
104 ("application/pgp-signature") ("application/pkcs7-signature") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
105 ("application/postscript") ("application/rtf") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
106 ("application/vnd.ms-excel") ("application/vnd.ms-powerpoint") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
107 ("application/vnd.ms-project") ("application/vnd.ms-tnef") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
108 ("application/wordperfect5.1") ("application/wordperfect6.0") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
109 ("application/zip") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
110 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
111 ("audio/basic") ("audio/mpeg") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
112 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
113 ("image/gif") ("image/jpeg") ("image/png") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
114 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
115 ("message/delivery-status") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
116 ("message/external-body") ("message/partial") ("message/rfc822") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
117 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
118 ("text/enriched") ("text/html") ("text/plain") ("text/rfc822-headers") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
119 ("text/richtext") ("text/xml") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
120 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
121 ("video/mpeg") ("video/quicktime")) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
122 "Legal MIME content types. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
123 See documentation for \\[mh-edit-mhn].") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
124 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
125 (defvar mh-media-type-regexp |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
126 (concat (regexp-opt '("text" "image" "audio" "video" "application" |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
127 "multipart" "message") t) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
128 "/[-.+a-zA-Z0-9]+") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
129 "Regexp matching valid media types used in MIME attachment compositions.") |
6365 | 130 |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
131 (defun mh-mhn-compose-insertion (filename type description attributes) |
11506 | 132 "Add a directive to insert a MIME message part from a file. |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
133 This is the typical way to insert non-text parts in a message. Arguments are |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
134 FILENAME, which tells where to find the file, TYPE, the MIME content type, |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
135 DESCRIPTION, a line of text for the Content-Description field. ATTRIBUTES is a |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
136 comma separated list of name=value pairs that is appended to the Content-Type |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
137 field of the attachment. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
138 See also \\[mh-edit-mhn]." |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
139 (interactive (let ((filename (read-file-name "Insert contents of: "))) |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
140 (list |
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
141 filename |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
142 (or (mh-file-mime-type filename) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
143 (completing-read "Content-Type: " |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
144 (if (and (require 'mailcap nil t) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
145 (fboundp 'mailcap-mime-types)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
146 (mapcar 'list (mailcap-mime-types)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
147 mh-mime-content-types))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
148 (read-string "Content-Description: ") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
149 (read-string "Content-Attributes: " |
23305
61483b4c169c
(mh-mhn-compose-insertion): Use quotes.
Karl Heuer <kwzh@gnu.org>
parents:
16862
diff
changeset
|
150 (concat "name=\"" |
61483b4c169c
(mh-mhn-compose-insertion): Use quotes.
Karl Heuer <kwzh@gnu.org>
parents:
16862
diff
changeset
|
151 (file-name-nondirectory filename) |
61483b4c169c
(mh-mhn-compose-insertion): Use quotes.
Karl Heuer <kwzh@gnu.org>
parents:
16862
diff
changeset
|
152 "\""))))) |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
153 (mh-mhn-compose-type filename type description attributes )) |
6365 | 154 |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
155 (defun mh-mhn-compose-type (filename type |
6365 | 156 &optional description attributes comment) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
157 (setq mh-mhn-compose-insert-p t) |
6365 | 158 (beginning-of-line) |
159 (insert "#" type) | |
160 (and attributes | |
161 (insert "; " attributes)) | |
162 (and comment | |
163 (insert " (" comment ")")) | |
164 (insert " [") | |
165 (and description | |
166 (insert description)) | |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
167 (insert "] " (expand-file-name filename)) |
6365 | 168 (insert "\n")) |
169 | |
170 | |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
171 (defun mh-mhn-compose-anon-ftp (host filename type description) |
11506 | 172 "Add a directive for a MIME anonymous ftp external body part. |
11332 | 173 This directive tells MH to include a reference to a |
174 message/external-body part retrievable by anonymous FTP. Arguments | |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
175 are HOST and FILENAME, which tell where to find the file, TYPE, the |
11332 | 176 MIME content type, and DESCRIPTION, a line of text for the |
177 Content-description header. See also \\[mh-edit-mhn]." | |
6365 | 178 (interactive (list |
179 (read-string "Remote host: ") | |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
180 (read-string "Remote filename: ") |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
181 (completing-read "External Content-Type: " |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
182 (if (and (require 'mailcap nil t) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
183 (fboundp 'mailcap-mime-types)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
184 (mapcar 'list (mailcap-mime-types)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
185 mh-mime-content-types)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
186 (read-string "External Content-Description: "))) |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
187 (mh-mhn-compose-external-type "anon-ftp" host filename |
6365 | 188 type description)) |
189 | |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
190 (defun mh-mhn-compose-external-compressed-tar (host filename description) |
11506 | 191 "Add a directive to include a MIME reference to a compressed tar file. |
11332 | 192 The file should be available via anonymous ftp. This directive |
193 tells MH to include a reference to a message/external-body part. | |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
194 Arguments are HOST and FILENAME, which tell where to find the file, and |
11332 | 195 DESCRIPTION, a line of text for the Content-description header. |
6365 | 196 See also \\[mh-edit-mhn]." |
197 (interactive (list | |
198 (read-string "Remote host: ") | |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
199 (read-string "Remote filename: ") |
6365 | 200 (read-string "Tar file Content-description: "))) |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
201 (mh-mhn-compose-external-type "anon-ftp" host filename |
6365 | 202 "application/octet-stream" |
203 description | |
204 "type=tar; conversions=x-compress" | |
205 "mode=image")) | |
206 | |
207 | |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
208 (defun mh-mhn-compose-external-type (access-type host filename type |
6365 | 209 &optional description |
210 attributes extra-params comment) | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
211 (setq mh-mhn-compose-insert-p t) |
6365 | 212 (beginning-of-line) |
213 (insert "#@" type) | |
214 (and attributes | |
215 (insert "; " attributes)) | |
216 (and comment | |
217 (insert " (" comment ") ")) | |
218 (insert " [") | |
219 (and description | |
220 (insert description)) | |
221 (insert "] ") | |
222 (insert "access-type=" access-type "; ") | |
223 (insert "site=" host) | |
16862
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
224 (insert "; name=" (file-name-nondirectory filename)) |
7417db9e3f61
Rename args PATHNAME to FILENAME in various functions.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
225 (insert "; directory=\"" (file-name-directory filename) "\"") |
6365 | 226 (and extra-params |
227 (insert "; " extra-params)) | |
228 (insert "\n")) | |
229 | |
11332 | 230 (defun mh-mhn-compose-forw (&optional description folder messages) |
11506 | 231 "Add a forw directive to this message, to forward a message with MIME. |
6365 | 232 This directive tells MH to include the named messages in this one. |
233 Arguments are DESCRIPTION, a line of text for the Content-description header, | |
11506 | 234 and FOLDER and MESSAGES, which name the message(s) to be forwarded. |
6365 | 235 See also \\[mh-edit-mhn]." |
236 (interactive (list | |
237 (read-string "Forw Content-description: ") | |
11332 | 238 (mh-prompt-for-folder "Message from" mh-sent-from-folder nil) |
6365 | 239 (read-string (format "Messages%s: " |
240 (if mh-sent-from-msg | |
241 (format " [%d]" mh-sent-from-msg) | |
11332 | 242 ""))))) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
243 (setq mh-mhn-compose-insert-p t) |
6365 | 244 (beginning-of-line) |
245 (insert "#forw [") | |
246 (and description | |
247 (not (string= description "")) | |
248 (insert description)) | |
249 (insert "]") | |
250 (and folder | |
251 (not (string= folder "")) | |
252 (insert " " folder)) | |
11332 | 253 (if (and messages |
254 (not (string= messages ""))) | |
6365 | 255 (let ((start (point))) |
11332 | 256 (insert " " messages) |
6365 | 257 (subst-char-in-region start (point) ?, ? )) |
258 (if mh-sent-from-msg | |
259 (insert " " (int-to-string mh-sent-from-msg)))) | |
260 (insert "\n")) | |
261 | |
11332 | 262 (defun mh-edit-mhn (&optional extra-args) |
263 "Format the current draft for MIME, expanding any mhn directives. | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
264 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
265 Process the current draft with the mhn program, which, using directives |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
266 already inserted in the draft, fills in all the MIME components and header |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
267 fields. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
268 |
6365 | 269 This step should be done last just before sending the message. |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
270 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
271 The `\\[mh-revert-mhn-edit]' command undoes this command. The arguments in the |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
272 list `mh-mhn-args' are passed to mhn if this function is passed an optional |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
273 prefix argument EXTRA-ARGS. |
11332 | 274 |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
275 For assistance with creating mhn directives to insert various types of |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
276 components in a message, see \\[mh-mhn-compose-insertion] (generic insertion |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
277 from a file), \\[mh-mhn-compose-anon-ftp] (external reference to file via |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
278 anonymous ftp), \\[mh-mhn-compose-external-compressed-tar] \ \(reference to |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
279 compressed tar file via anonymous ftp), and \\[mh-mhn-compose-forw] (forward |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
280 message). If these helper functions are used, `mh-edit-mhn' is run |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
281 automatically when the draft is sent. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
282 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
283 The mhn program is part of MH version 6.8 or later." |
11332 | 284 (interactive "*P") |
6365 | 285 (save-buffer) |
286 (message "mhn editing...") | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
287 (cond |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
288 (mh-nmh-p |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
289 (mh-exec-cmd-error nil |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
290 "mhbuild" (if extra-args mh-mhn-args) buffer-file-name)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
291 (t |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
292 (mh-exec-cmd-error (format "mhdraft=%s" buffer-file-name) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
293 "mhn" (if extra-args mh-mhn-args) buffer-file-name))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
294 (setq mh-mhn-compose-insert-p nil) |
6365 | 295 (revert-buffer t t) |
11332 | 296 (message "mhn editing...done") |
297 (run-hooks 'mh-edit-mhn-hook)) | |
6365 | 298 |
299 | |
300 (defun mh-revert-mhn-edit (noconfirm) | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
301 "Undo the effect of \\[mh-edit-mhn] by reverting to the backup file. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
302 Optional non-nil argument NOCONFIRM means don't ask for confirmation." |
6365 | 303 (interactive "*P") |
304 (if (null buffer-file-name) | |
305 (error "Buffer does not seem to be associated with any file")) | |
306 (let ((backup-strings '("," "#")) | |
307 backup-file) | |
308 (while (and backup-strings | |
309 (not (file-exists-p | |
310 (setq backup-file | |
311 (concat (file-name-directory buffer-file-name) | |
312 (car backup-strings) | |
313 (file-name-nondirectory buffer-file-name) | |
314 ".orig"))))) | |
315 (setq backup-strings (cdr backup-strings))) | |
316 (or backup-strings | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
317 (error "Backup file for %s no longer exists!" buffer-file-name)) |
6365 | 318 (or noconfirm |
319 (yes-or-no-p (format "Revert buffer from file %s? " | |
320 backup-file)) | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
321 (error "Revert not confirmed")) |
6365 | 322 (let ((buffer-read-only nil)) |
323 (erase-buffer) | |
324 (insert-file-contents backup-file)) | |
325 (after-find-file nil))) | |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
23305
diff
changeset
|
326 |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
23305
diff
changeset
|
327 ;;; mh-mime.el ends here |