annotate lisp/tm/tm-edit.el @ 76:c0c698873ce1 r20-0b33

Import from CVS: tag r20-0b33
author cvs
date Mon, 13 Aug 2007 09:05:10 +0200
parents 54cc21c15cbb
children c7528f8e288d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1 ;;; tm-edit.el --- Simple MIME Composer for GNU Emacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
3 ;; Copyright (C) 1993 .. 1996 Free Software Foundation, Inc.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
5 ;; Author: UMEDA Masanobu <umerin@mse.kyutech.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
7 ;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
8 ;; Created: 1994/08/21 renamed from mime.el
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
9 ;; Version: $Revision: 1.2 $
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
10 ;; Keywords: mail, news, MIME, multimedia, multilingual
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
11
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
12 ;; This file is part of tm (Tools for MIME).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
13
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
14 ;; This program is free software; you can redistribute it and/or
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
15 ;; modify it under the terms of the GNU General Public License as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
16 ;; published by the Free Software Foundation; either version 2, or (at
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
17 ;; your option) any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
18
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
19 ;; This program is distributed in the hope that it will be useful, but
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
22 ;; General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
23
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
27 ;; Boston, MA 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
28
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29 ;;; Commentary:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31 ;; This is an Emacs minor mode for editing Internet multimedia
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
32 ;; messages formatted in MIME (RFC 2045, 2046, 2047, 2048 and 2049).
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
33 ;; All messages in this mode are composed in the tagged MIME format,
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
34 ;; that are described in the following examples. The messages
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
35 ;; composed in the tagged MIME format are automatically translated
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
36 ;; into a MIME compliant message when exiting the mode.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
38 ;; Mule (a multilingual extension to Emacs 18 and 19) has a capability
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39 ;; of handling multilingual text in limited ISO-2022 manner that is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
40 ;; based on early experiences in Japanese Internet community and
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
41 ;; resulted in RFC 1468 (ISO-2022-JP charset for MIME). In order to
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
42 ;; enable multilingual capability in single text message in MIME,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
43 ;; charset of multilingual text written in Mule is declared as either
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
44 ;; `ISO-2022-JP-2' [RFC 1554] or `ISO-2022-INT-1'. Mule is required
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
45 ;; for reading the such messages.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
46
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
47 ;; This MIME composer can work with Mail mode, mh-e letter Mode, and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
48 ;; News mode. First of all, you need the following autoload
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
49 ;; definition to load mime/editor-mode automatically:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
50 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51 ;; (autoload 'mime/editor-mode "tm-edit"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
52 ;; "Minor mode for editing MIME message." t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
54 ;; In case of Mail mode (includes VM mode), you need the following
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55 ;; hook definition:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
57 ;; (add-hook 'mail-mode-hook 'mime/editor-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58 ;; (add-hook 'mail-send-hook 'mime-editor/maybe-translate)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
59 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
60 ;; In case of MH-E, you need the following hook definition:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
61 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62 ;; (add-hook 'mh-letter-mode-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63 ;; (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64 ;; (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
65 ;; (mime/editor-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
66 ;; (make-local-variable 'mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
67 ;; (setq mail-header-separator "--------")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
68 ;; ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 ;; (add-hook 'mh-before-send-letter-hook 'mime-editor/maybe-translate)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71 ;; In case of News mode, you need the following hook definition:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
73 ;; (add-hook 'news-reply-mode-hook 'mime/editor-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
74 ;; (add-hook 'news-inews-hook 'mime-editor/maybe-translate)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
75 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
76 ;; In case of Emacs 19, it is possible to emphasize the message tags
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
77 ;; using font-lock mode as follows:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
78 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79 ;; (add-hook 'mime/editor-mode-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80 ;; (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 ;; (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82 ;; (font-lock-mode 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
83 ;; (setq font-lock-keywords (list mime-editor/tag-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84 ;; ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
86 ;; The message tag looks like:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 ;; --[[TYPE/SUBTYPE;PARAMETERS][ENCODING]]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90 ;; The tagged MIME message examples:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 ;; This is a conventional plain text. It should be translated into
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93 ;; text/plain.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
94 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
95 ;;--[[text/plain]]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 ;; This is also a plain text. But, it is explicitly specified as is.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
98 ;;--[[text/plain; charset=ISO-2022-JP]]
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
99 ;; これは charset を ISO-2022-JP に指定した日本語の plain テキストです.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
100 ;;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
101 ;;--[[text/richtext]]
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 ;; <center>This is a richtext.</center>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
104 ;;--[[image/gif][base64]]^M...image encoded in base64 comes here...
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106 ;;--[[audio/basic][base64]]^M...audio encoded in base64 comes here...
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 ;;; Code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
109
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110 (require 'sendmail)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111 (require 'mail-utils)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 (require 'mel)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 (require 'tl-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114 (require 'tm-view)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115 (require 'tm-ew-e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116 (require 'signature)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 ;;; @ version
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
120 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
121
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
122 (defconst mime-editor/RCS-ID
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
123 "$Id: tm-edit.el,v 1.2 1996/12/28 21:03:13 steve Exp $")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125 (defconst mime-editor/version (get-version-string mime-editor/RCS-ID))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127 (defconst mime-editor/version-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128 (concat "tm-edit " mime-editor/version))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
130
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
131 ;;; @ variables
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
132 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
133
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
134 (defvar mime-prefix "\C-c\C-x"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
135 "*Keymap prefix for MIME commands.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
136
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
137 (defvar mime-ignore-preceding-spaces nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
138 "*Ignore preceding white spaces if non-nil.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
139
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
140 (defvar mime-ignore-trailing-spaces nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
141 "*Ignore trailing white spaces if non-nil.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
142
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
143 (defvar mime-ignore-same-text-tag t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
144 "*Ignore preceding text content-type tag that is same with new one.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
145 If non-nil, the text tag is not inserted unless something different.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
146
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147 (defvar mime-auto-hide-body t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 "*Hide non-textual body encoded in base64 after insertion if non-nil.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
149
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 (defvar mime-editor/voice-recorder
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151 (function mime-editor/voice-recorder-for-sun)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
152 "*Function to record a voice message and encode it. [tm-edit.el]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
153
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
154 (defvar mime/editor-mode-hook nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
155 "*Hook called when enter MIME mode.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
156
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
157 (defvar mime-editor/translate-hook nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
158 "*Hook called before translating into a MIME compliant message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
159 To insert a signature file automatically, call the function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
160 `mime-editor/insert-signature' from this hook.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
161
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
162 (defvar mime-editor/exit-hook nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
163 "*Hook called when exit MIME mode.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
164
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
165 (defvar mime-content-types
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
166 '(("text"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
167 ;; Charset parameter need not to be specified, since it is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
168 ;; defined automatically while translation.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
169 ("plain"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
170 ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
171 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
172 ("richtext"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
173 ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
174 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
175 ("enriched"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
176 ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
177 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
178 ("x-latex"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
179 ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
180 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
181 ("html"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
182 ;;("charset" "" "ISO-2022-JP" "US-ASCII" "ISO-8859-1" "ISO-8859-8")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
183 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
184 ("x-rot13-47")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
185 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
186 ("message"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
187 ("external-body"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
188 ("access-type"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
189 ("anon-ftp"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
190 ("site" "ftp.jaist.ac.jp" "wnoc-fuk.wide.ad.jp" "nic.karrn.ad.jp")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
191 ("directory" "/pub/GNU/elisp/mime")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
192 ("name")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
193 ("mode" "image" "ascii" "local8"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
194 ("ftp"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
195 ("site")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
196 ("directory")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
197 ("name")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
198 ("mode" "image" "ascii" "local8"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
199 ("tftp" ("site") ("name"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
200 ("afs" ("site") ("name"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
201 ("local-file" ("site") ("name"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
202 ("mail-server" ("server" "ftpmail@nic.karrn.ad.jp"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
203 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
204 ("rfc822")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
205 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
206 ("application"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
207 ("octet-stream" ("type" "" "tar" "shar"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
208 ("postscript")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
209 ("x-kiss" ("x-cnf")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
210 ("image"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
211 ("gif")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
212 ("jpeg")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
213 ("tiff")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
214 ("x-pic")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
215 ("x-mag")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
216 ("x-xwd")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
217 ("x-xbm")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
218 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
219 ("audio" ("basic"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
220 ("video" ("mpeg"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
221 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
222 "*Alist of content-type, subtype, parameters and its values.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 (defvar mime-file-types
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
225 '(("\\.rtf$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
226 "text" "richtext" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
227 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 nil nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
229 ("\\.html$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
230 "text" "html" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
231 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
232 nil nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
233 ("\\.ps$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
234 "application" "postscript" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
235 "quoted-printable"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
236 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
237 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
238 ("\\.jpg$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
239 "image" "jpeg" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
240 "base64"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241 "inline" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 ("\\.gif$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244 "image" "gif" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245 "base64"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
246 "inline" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248 ("\\.tiff$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249 "image" "tiff" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 "base64"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 "inline" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 ("\\.pic$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 "image" "x-pic" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 "base64"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256 "inline" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
258 ("\\.mag$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
259 "image" "x-mag" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
260 "base64"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
261 "inline" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
262 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
263 ("\\.xbm$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
264 "image" "x-xbm" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
265 "base64"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
266 "inline" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
267 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
268 ("\\.xwd$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
269 "image" "x-xwd" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
270 "base64"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
271 "inline" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
272 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
273 ("\\.au$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
274 "audio" "basic" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
275 "base64"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
276 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
277 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
278 ("\\.mpg$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
279 "video" "mpeg" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
280 "base64"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
281 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
282 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
283 ("\\.el$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
284 "application" "octet-stream" (("type" . "emacs-lisp"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
285 "7bit"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
286 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
287 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
288 ("\\.lsp$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
289 "application" "octet-stream" (("type" . "common-lisp"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
290 "7bit"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
291 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
292 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
293 ("\\.tar\\.gz$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
294 "application" "octet-stream" (("type" . "tar+gzip"))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
295 "base64"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
296 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
297 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
298 ("\\.tgz$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
299 "application" "octet-stream" (("type" . "tar+gzip"))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
300 "base64"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
301 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
302 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
303 ("\\.tar\\.Z$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
304 "application" "octet-stream" (("type" . "tar+compress"))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
305 "base64"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
306 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
307 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
308 ("\\.taz$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
309 "application" "octet-stream" (("type" . "tar+compress"))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
310 "base64"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
311 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
312 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
313 ("\\.gz$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
314 "application" "octet-stream" (("type" . "gzip"))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
315 "base64"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
316 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
317 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
318 ("\\.Z$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
319 "application" "octet-stream" (("type" . "compress"))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
320 "base64"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
321 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
322 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
323 ("\\.lzh$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
324 "application" "octet-stream" (("type" . "lha"))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
325 "base64"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
326 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
327 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
328 ("\\.zip$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
329 "application" "zip" nil
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
330 "base64"
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
331 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
332 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
333 ("\\.diff$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
334 "application" "octet-stream" (("type" . "patch"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
335 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
336 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
337 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
338 ("\\.patch$"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
339 "application" "octet-stream" (("type" . "patch"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
340 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
341 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
342 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
343 ("\\.signature"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
344 "text" "plain" nil nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
345 (".*"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
346 "application" "octet-stream" nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
347 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
348 "attachment" (("filename" . file))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
349 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
350 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
351 "*Alist of file name, types, parameters, and default encoding.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
352 If encoding is nil, it is determined from its contents.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
353
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
354 ;;; @@ about charset, encoding and transfer-level
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
355 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
356
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
357 (defvar mime-editor/transfer-level 7
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
358 "*A number of network transfer level. It should be bigger than 7.")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
359 (make-variable-buffer-local 'mime-editor/transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
360
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
361 (defvar mime-editor/transfer-level-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
362 (mime/encoding-name mime-editor/transfer-level 'not-omit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
363 "*A string formatted version of mime/defaul-transfer-level")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
364 (make-variable-buffer-local 'mime-editor/transfer-level-string)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
365
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
366 (defun mime-editor/make-charset-default-encoding-alist (transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
367 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
368 (lambda (charset-type)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
369 (let ((charset (car charset-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
370 (type (nth 1 charset-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
371 (encoding (nth 2 charset-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
372 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
373 (if (<= type transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
374 (cons charset (mime/encoding-name type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
375 (cons charset encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
376 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
377 mime-charset-type-list))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
378
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
379 (defvar mime-editor/charset-default-encoding-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
380 (mime-editor/make-charset-default-encoding-alist mime-editor/transfer-level))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
381 (make-variable-buffer-local 'mime-editor/charset-default-encoding-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
382
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
383 ;;; @@ about message inserting
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
384 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
385
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
386 (defvar mime-editor/yank-ignored-field-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
387 '("Received" "Approved" "Path" "Replied" "Status"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
388 "Xref" "X-UIDL" "X-Filter" "X-Gnus-.*" "X-VM-.*")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
389 "Delete these fields from original message when it is inserted
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
390 as message/rfc822 part.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
391 Each elements are regexp of field-name. [tm-edit.el]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
392
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
393 (defvar mime-editor/yank-ignored-field-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
394 (concat "^"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
395 (apply (function regexp-or) mime-editor/yank-ignored-field-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
396 ":"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
397
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
398 (defvar mime-editor/message-inserter-alist nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
399 (defvar mime-editor/mail-inserter-alist nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
400
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
401 ;;; @@ about message splitting
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
402 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
403
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
404 (defvar mime-editor/split-message t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
405 "*Split large message if it is non-nil. [tm-edit.el]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
406
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
407 (defvar mime-editor/message-default-max-lines 1000
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
408 "*Default maximum lines of a message. [tm-edit.el]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
409
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
410 (defvar mime-editor/message-max-lines-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
411 '((news-reply-mode . 500))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
412 "Alist of major-mode vs maximum lines of a message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
413 If it is not specified for a major-mode,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
414 `mime-editor/message-default-max-lines' is used. [tm-edit.el]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
415
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
416 (defconst mime-editor/split-ignored-field-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
417 "\\(^Content-\\|^Subject:\\|^Mime-Version:\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
418
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
419 (defvar mime-editor/split-blind-field-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
420 "\\(^[BDFbdf]cc:\\|^cc:[ \t]*$\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
421
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
422 (defvar mime-editor/split-message-sender-alist nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
423
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
424 (defvar mime-editor/news-reply-mode-server-running nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
425
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
426
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
427 ;;; @@ about PGP
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
428 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
429
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
430 (defvar mime-editor/signing-type 'pgp-elkins
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
431 "*PGP signing type (pgp-elkins, pgp-kazu or nil). [tm-edit.el]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
432
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
433 (defvar mime-editor/encrypting-type 'pgp-elkins
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
434 "*PGP encrypting type (pgp-elkins, pgp-kazu or nil). [tm-edit.el]")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
435
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
436 (defvar mime-editor/pgp-sign-function 'tm:mc-pgp-sign-region)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
437 (defvar mime-editor/pgp-encrypt-function 'tm:mc-pgp-encrypt-region)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
438 (defvar mime-editor/traditional-pgp-sign-function 'mc-pgp-sign-region)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
439 (defvar mime-editor/pgp-insert-public-key-function 'mc-insert-public-key)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
440
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
441 (autoload mime-editor/pgp-sign-function "tm-edit-mc")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
442 (autoload mime-editor/pgp-encrypt-function "tm-edit-mc")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
443 (autoload mime-editor/traditional-pgp-sign-function "mc-pgp")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
444 (autoload mime-editor/pgp-insert-public-key-function "mc-toplev")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
445
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
446
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
447 ;;; @@ about tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
448 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
449
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
450 (defconst mime-editor/single-part-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
451 "--[[][[]\\([^]]*\\)]\\([[]\\([^]]*\\)]\\|\\)]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
452 "*Regexp of MIME tag in the form of [[CONTENT-TYPE][ENCODING]].")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
453
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
454 (defconst mime-editor/quoted-single-part-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
455 (concat "- " (substring mime-editor/single-part-tag-regexp 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
456
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
457 (defconst mime-editor/multipart-beginning-regexp "--<<\\([^<>]+\\)>>-{\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
458
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
459 (defconst mime-editor/multipart-end-regexp "--}-<<\\([^<>]+\\)>>\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
460
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
461 (defconst mime-editor/beginning-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
462 (regexp-or mime-editor/single-part-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
463 mime-editor/multipart-beginning-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
464
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
465 (defconst mime-editor/end-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
466 (regexp-or mime-editor/single-part-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
467 mime-editor/multipart-end-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
468
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
469 (defconst mime-editor/tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
470 (regexp-or mime-editor/single-part-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
471 mime-editor/multipart-beginning-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
472 mime-editor/multipart-end-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
473
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
474 (defvar mime-tag-format "--[[%s]]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
475 "*Control-string making a MIME tag.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
476
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
477 (defvar mime-tag-format-with-encoding "--[[%s][%s]]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
478 "*Control-string making a MIME tag with encoding.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
479
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
480 ;;; @@ multipart boundary
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
481 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
482
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
483 (defvar mime-multipart-boundary "Multipart"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
484 "*Boundary of a multipart message.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
485
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
486
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
487 ;;; @@ buffer local variables
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
488 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
489
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
490 (defvar mime/editor-mode-old-local-map nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
491 (defvar mime/editing-buffer nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
492
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
493
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
494 ;;; @ constants
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
495 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
496
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
497 (defconst mime-tspecials-regexp "[][()<>@,;:\\\"/?.= \t]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
498 "*Specify MIME tspecials.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
499 Tspecials means any character that matches with it in header must be quoted.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
500
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
501 (defconst mime-editor/mime-version-value
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
502 (concat "1.0 (generated by " mime-editor/version-name ")")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
503 "MIME version number.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
504
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
505 (defconst mime-editor/mime-map (make-sparse-keymap)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
506 "Keymap for MIME commands.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
507
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
508 ;;; @ keymap and menu
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
509 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
510
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
511 (defvar mime/editor-mode-flag nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
512 (make-variable-buffer-local 'mime/editor-mode-flag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
513
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
514 (defun mime-editor/define-keymap (keymap)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
515 "Add mime-editor commands to KEYMAP."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
516 (if (not (keymapp keymap))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
517 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
518 (define-key keymap "\C-t" 'mime-editor/insert-text)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
519 (define-key keymap "\C-i" 'mime-editor/insert-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
520 (define-key keymap "\C-e" 'mime-editor/insert-external)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
521 (define-key keymap "\C-v" 'mime-editor/insert-voice)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
522 (define-key keymap "\C-y" 'mime-editor/insert-message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
523 (define-key keymap "\C-m" 'mime-editor/insert-mail)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
524 (define-key keymap "\C-w" 'mime-editor/insert-signature)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
525 (define-key keymap "\C-s" 'mime-editor/insert-signature)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
526 (define-key keymap "\C-k" 'mime-editor/insert-key)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
527 (define-key keymap "t" 'mime-editor/insert-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
528 (define-key keymap "a" 'mime-editor/enclose-alternative-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
529 (define-key keymap "p" 'mime-editor/enclose-parallel-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
530 (define-key keymap "m" 'mime-editor/enclose-mixed-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
531 (define-key keymap "d" 'mime-editor/enclose-digest-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
532 (define-key keymap "s" 'mime-editor/enclose-signed-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
533 (define-key keymap "e" 'mime-editor/enclose-encrypted-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
534 (define-key keymap "q" 'mime-editor/enclose-quote-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
535 (define-key keymap "7" 'mime-editor/set-transfer-level-7bit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
536 (define-key keymap "8" 'mime-editor/set-transfer-level-8bit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
537 (define-key keymap "/" 'mime-editor/set-split)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
538 (define-key keymap "v" 'mime-editor/set-sign)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
539 (define-key keymap "h" 'mime-editor/set-encrypt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
540 (define-key keymap "\C-p" 'mime-editor/preview-message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
541 (define-key keymap "\C-z" 'mime-editor/exit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
542 (define-key keymap "?" 'mime-editor/help)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
543 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
544
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
545 (mime-editor/define-keymap mime-editor/mime-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
546
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
547 (defun mime-editor/toggle-mode ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
548 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
549 (if mime/editor-mode-flag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
550 (mime-editor/exit 'nomime)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
551 (mime/editor-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
552 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
553
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
554 (cond (running-xemacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
555 (defconst mime-editor/minor-mime-map nil "Keymap for MIME commands.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
556 (or mime-editor/minor-mime-map
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
557 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
558 (setq mime-editor/minor-mime-map
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
559 (make-sparse-keymap 'mime-editor/minor-mime-map))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
560 (define-key
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
561 mime-editor/minor-mime-map mime-prefix mime-editor/mime-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
562 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
563 (add-minor-mode 'mime/editor-mode-flag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
564 '((" MIME-Edit " mime-editor/transfer-level-string))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
565 mime-editor/minor-mime-map
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
566 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
567 'mime-editor/toggle-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
568 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
569 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
570 (set-alist 'minor-mode-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
571 'mime/editor-mode-flag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
572 '((" MIME-Edit " mime-editor/transfer-level-string))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
573 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
574
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
575 (defconst mime-editor/menu-title "MIME-Edit")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
576
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
577 (defconst mime-editor/menu-list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
578 '((mime-help "Describe MIME editor mode" mime-editor/help)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
579 (file "Insert File" mime-editor/insert-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
580 (external "Insert External" mime-editor/insert-external)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
581 (voice "Insert Voice" mime-editor/insert-voice)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
582 (message "Insert Message" mime-editor/insert-message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
583 (mail "Insert Mail" mime-editor/insert-mail)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
584 (signature "Insert Signature" mime-editor/insert-signature)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
585 (text "Insert Text" mime-editor/insert-text)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
586 (tag "Insert Tag" mime-editor/insert-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
587 (alternative "Enclose as alternative"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
588 mime-editor/enclose-alternative-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
589 (parallel "Enclose as parallel" mime-editor/enclose-parallel-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
590 (mixed "Enclose as serial" mime-editor/enclose-mixed-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
591 (digest "Enclose as digest" mime-editor/enclose-digest-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
592 (signed "Enclose as signed" mime-editor/enclose-signed-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
593 (encrypted "Enclose as encrypted" mime-editor/enclose-encrypted-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
594 (quote "Verbatim region" mime-editor/enclose-quote-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
595 (key "Insert Public Key" mime-editor/insert-key)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
596 (split "About split" mime-editor/set-split)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
597 (sign "About sign" mime-editor/set-sign)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
598 (encrypt "About encryption" mime-editor/set-encrypt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
599 (preview "Preview Message" mime-editor/preview-message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
600 (level "Toggle transfer-level" mime-editor/toggle-transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
601 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
602 "MIME-edit menubar entry.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
603
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
604 (defun mime-editor/define-menu-for-emacs19 ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
605 "Define menu for Emacs 19."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
606 (define-key (current-local-map) [menu-bar mime-edit]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
607 (cons mime-editor/menu-title
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
608 (make-sparse-keymap mime-editor/menu-title)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
609 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
610 (lambda (item)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
611 (define-key (current-local-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
612 (vector 'menu-bar 'mime-edit (car item))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
613 (cons (nth 1 item)(nth 2 item))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
614 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
615 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
616 (reverse mime-editor/menu-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
617 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
618
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
619 ;;; modified by Pekka Marjola <pema@iki.fi>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
620 ;;; 1995/9/5 (c.f. [tm-en:69])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
621 (defun mime-editor/define-menu-for-xemacs ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
622 "Define menu for Emacs 19."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
623 (cond ((featurep 'menubar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
624 (make-local-variable 'current-menubar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
625 (set-buffer-menubar current-menubar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
626 (add-submenu nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
627 (cons mime-editor/menu-title
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
628 (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
629 (lambda (item)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
630 (vector (nth 1 item)(nth 2 item)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
631 mime/editor-mode-flag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
632 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
633 mime-editor/menu-list)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
634 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
635
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
636 ;;; modified by Steven L. Baur <steve@miranova.com>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
637 ;;; 1995/12/6 (c.f. [tm-en:209])
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
638 (if (and running-xemacs (not (boundp 'mime-editor/popup-menu-for-xemacs)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
639 (setq mime-editor/popup-menu-for-xemacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
640 (append '("MIME Commands" "---")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
641 (mapcar (function (lambda (item)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
642 (vector (nth 1 item)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
643 (nth 2 item)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
644 t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
645 mime-editor/menu-list)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
646 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
647 ;;; end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
648
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
649
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
650 ;;; @ functions
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
651 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
652
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
653 ;; The following text was removed from the docstring of the subsequent
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
654 ;; functions due to problems with the resulting autoload file. -sb
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
655
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
656 ;; --[[text/plain; charset=ISO-2022-JP]]
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
657 ;; これは charset を ISO-2022-JP に指定した日本語の plain テキス
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
658 ;; トです.
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
659
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
660
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
661 ;;;###autoload
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
662 (defun mime/editor-mode ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
663 "MIME minor mode for editing the tagged MIME message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
664
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
665 In this mode, basically, the message is composed in the tagged MIME
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
666 format. The message tag looks like:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
667
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
668 --[[text/plain; charset=ISO-2022-JP][7bit]]
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
669
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
670 The tag specifies the MIME content type, subtype, optional parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
671 and transfer encoding of the message following the tag. Messages
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
672 without any tag are treated as `text/plain' by default. Charset and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
673 transfer encoding are automatically defined unless explicitly
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
674 specified. Binary messages such as audio and image are usually hidden.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
675 The messages in the tagged MIME format are automatically translated
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
676 into a MIME compliant message when exiting this mode.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
677
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
678 Available charsets depend on Emacs version being used. The following
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
679 lists the available charsets of each emacs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
680
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
681 EMACS 18: US-ASCII is only available.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
682 NEmacs: US-ASCII and ISO-2022-JP are available.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
683 EMACS 19: US-ASCII and ISO-8859-1 (or other charset) are available.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
684 XEmacs 19: US-ASCII and ISO-8859-1 (or other charset) are available.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
685 Mule: US-ASCII, ISO-8859-* (except for ISO-8859-5), KOI8-R,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
686 ISO-2022-JP, ISO-2022-JP-2, ISO-2022-KR, BIG5 and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
687 ISO-2022-INT-1 are available.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
688
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
689 ISO-2022-JP-2 and ISO-2022-INT-1 charsets used in mule is expected to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
690 be used to represent multilingual text in intermixed manner. Any
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
691 languages that has no registered charset are represented as either
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
692 ISO-2022-JP-2 or ISO-2022-INT-1 in mule.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
693
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
694 If you want to use non-ISO-8859-1 charset in EMACS 19 or XEmacs 19,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
695 please set variable `default-mime-charset'. This variable must be
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
696 symbol of which name is a MIME charset.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
697
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
698 If you want to add more charsets in mule, please set variable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
699 `charsets-mime-charset-alist'. This variable must be alist of which
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
700 key is list of leading-char/charset and value is symbol of MIME
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
701 charset. (leading-char is a term of MULE 1.* and 2.*. charset is a
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
702 term of XEmacs/mule, mule merged EMACS and MULE 3.*) If name of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
703 coding-system is different as MIME charset, please set variable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
704 `mime-charset-coding-system-alist'. This variable must be alist of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
705 which key is MIME charset and value is coding-system.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
706
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
707 Following commands are available in addition to major mode commands:
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
708
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
709 \[make single part\]
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
710 \\[mime-editor/insert-text] insert a text message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
711 \\[mime-editor/insert-file] insert a (binary) file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
712 \\[mime-editor/insert-external] insert a reference to external body.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
713 \\[mime-editor/insert-voice] insert a voice message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
714 \\[mime-editor/insert-message] insert a mail or news message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
715 \\[mime-editor/insert-mail] insert a mail message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
716 \\[mime-editor/insert-signature] insert a signature file at end.
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
717 \\[mime-editor/insert-key] insert PGP public key.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
718 \\[mime-editor/insert-tag] insert a new MIME tag.
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
719
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
720 \[make enclosure (maybe multipart)\]
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
721 \\[mime-editor/enclose-alternative-region] enclose as multipart/alternative.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
722 \\[mime-editor/enclose-parallel-region] enclose as multipart/parallel.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
723 \\[mime-editor/enclose-mixed-region] enclose as multipart/mixed.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
724 \\[mime-editor/enclose-digest-region] enclose as multipart/digest.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
725 \\[mime-editor/enclose-signed-region] enclose as PGP signed.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
726 \\[mime-editor/enclose-encrypted-region] enclose as PGP encrypted.
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
727 \\[mime-editor/enclose-quote-region] enclose as verbose mode (to avoid to expand tags)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
728
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
729 \[other commands\]
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
730 \\[mime-editor/set-transfer-level-7bit] set transfer-level as 7.
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
731 \\[mime-editor/set-transfer-level-8bit] set transfer-level as 8.
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
732 \\[mime-editor/set-split] set message splitting mode.
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
733 \\[mime-editor/set-sign] set PGP-sign mode.
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
734 \\[mime-editor/set-encrypt] set PGP-encryption mode.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
735 \\[mime-editor/preview-message] preview editing MIME message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
736 \\[mime-editor/exit] exit and translate into a MIME compliant message.
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
737 \\[mime-editor/help] show this help.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
738 \\[mime-editor/maybe-translate] exit and translate if in MIME mode, then split.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
739
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
740 Additional commands are available in some major modes:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
741 C-c C-c exit, translate and run the original command.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
742 C-c C-s exit, translate and run the original command.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
743
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
744 The following is a message example written in the tagged MIME format.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
745 TABs at the beginning of the line are not a part of the message:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
746
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
747 This is a conventional plain text. It should be translated
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
748 into text/plain.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
749 --[[text/plain]]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
750 This is also a plain text. But, it is explicitly specified as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
751 is.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
752 --[[text/richtext]]
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
753 <center>This is a richtext.</center>
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
754 --[[image/gif][base64]]^M...image encoded in base64 here...
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
755 --[[audio/basic][base64]]^M...audio encoded in base64 here...
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
756
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
757 User customizable variables (not documented all of them):
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
758 mime-prefix
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
759 Specifies a key prefix for MIME minor mode commands.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
760
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
761 mime-ignore-preceding-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
762 Preceding white spaces in a message body are ignored if non-nil.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
763
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
764 mime-ignore-trailing-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
765 Trailing white spaces in a message body are ignored if non-nil.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
766
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
767 mime-auto-hide-body
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
768 Hide a non-textual body message encoded in base64 after insertion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
769 if non-nil.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
770
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
771 mime-editor/transfer-level
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
772 A number of network transfer level. It should be bigger than 7.
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
773 If you are in 8bit-through environment, please set 8.
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
774
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
775 mime-editor/voice-recorder
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
776 Specifies a function to record a voice message and encode it.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
777 The function `mime-editor/voice-recorder-for-sun' is for Sun
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
778 SparcStations.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
779
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
780 mime/editor-mode-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
781 Turning on MIME mode calls the value of mime/editor-mode-hook, if
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
782 it is non-nil.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
783
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
784 mime-editor/translate-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
785 The value of mime-editor/translate-hook is called just before translating
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
786 the tagged MIME format into a MIME compliant message if it is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
787 non-nil. If the hook call the function mime-editor/insert-signature,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
788 the signature file will be inserted automatically.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
789
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
790 mime-editor/exit-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
791 Turning off MIME mode calls the value of mime-editor/exit-hook, if it is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
792 non-nil."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
793 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
794 (if mime/editor-mode-flag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
795 (error "You are already editing a MIME message.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
796 (setq mime/editor-mode-flag t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
797 ;; Remember old key bindings.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
798 (if running-xemacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
799 (use-local-map (or (current-local-map) (make-sparse-keymap)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
800 (make-local-variable 'mime/editor-mode-old-local-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
801 (setq mime/editor-mode-old-local-map (current-local-map))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
802 ;; Add MIME commands to current local map.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
803 (use-local-map (copy-keymap (or (current-local-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
804 (make-sparse-keymap))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
805 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
806 (if (not (lookup-key (current-local-map) mime-prefix))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
807 (define-key (current-local-map) mime-prefix mime-editor/mime-map))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
808
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
809 ;; Set transfer level into mode line
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
810 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
811 (setq mime-editor/transfer-level-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
812 (mime/encoding-name mime-editor/transfer-level 'not-omit))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
813 (force-mode-line-update)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
814
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
815 ;; Define menu. Menus for other emacs implementations are
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
816 ;; welcome.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
817 (cond (running-xemacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
818 (mime-editor/define-menu-for-xemacs))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
819 ((>= emacs-major-version 19)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
820 (mime-editor/define-menu-for-emacs19)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
821 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
822 ;; end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
823
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
824 (enable-invisible)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
825
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
826 ;; I don't care about saving these.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
827 (setq paragraph-start
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
828 (regexp-or mime-editor/single-part-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
829 paragraph-start))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
830 (setq paragraph-separate
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
831 (regexp-or mime-editor/single-part-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
832 paragraph-separate))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
833 (run-hooks 'mime/editor-mode-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
834 (message
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
835 (substitute-command-keys
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
836 "Type \\[mime-editor/exit] to exit MIME mode, and type \\[mime-editor/help] to get help."))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
837 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
838
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
839 ;;;###autoload
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
840 (defalias 'edit-mime 'mime/editor-mode) ; for convenience
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
841 (defalias 'mime-mode 'mime/editor-mode) ; for convenience
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
842
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
843 (defun mime-editor/exit (&optional nomime no-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
844 "Translate the tagged MIME message into a MIME compliant message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
845 With no argument encode a message in the buffer into MIME, otherwise
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
846 just return to previous mode."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
847 (interactive "P")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
848 (if (not mime/editor-mode-flag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
849 (if (null no-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
850 (error "You aren't editing a MIME message.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
851 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
852 (if (not nomime)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
853 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
854 (run-hooks 'mime-editor/translate-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
855 (mime-editor/translate-buffer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
856 ;; Restore previous state.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
857 (setq mime/editor-mode-flag nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
858 (cond (running-xemacs
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
859 (delete-menu-item (list mime-editor/menu-title)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
860 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
861 (use-local-map mime/editor-mode-old-local-map)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
862
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
863 (end-of-invisible)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
864 (set-buffer-modified-p (buffer-modified-p))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
865 (run-hooks 'mime-editor/exit-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
866 (message "Exit MIME editor mode.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
867 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
868
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
869 (defun mime-editor/maybe-translate ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
870 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
871 (mime-editor/exit nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
872 (call-interactively 'mime-editor/maybe-split-and-send)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
873 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
874
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
875 (defun mime-editor/help ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
876 "Show help message about MIME mode."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
877 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
878 (with-output-to-temp-buffer "*Help*"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
879 (princ "MIME editor mode:\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
880 (princ (documentation 'mime/editor-mode))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
881 (print-help-return-message)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
882
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
883 (defun mime-editor/insert-text ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
884 "Insert a text message.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
885 Charset is automatically obtained from the `mime/lc-charset-alist'."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
886 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
887 (let ((ret (mime-editor/insert-tag "text" nil nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
888 (if ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
889 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
890 (if (looking-at mime-editor/single-part-tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
891 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
892 ;; Make a space between the following message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
893 (insert "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
894 (forward-char -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
895 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
896 (if (and (member (second ret) '("enriched" "richtext"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
897 (fboundp 'enriched-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
898 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
899 (enriched-mode t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
900 (if (boundp 'enriched-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
901 (enriched-mode nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
902 ))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
903
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
904 (defun mime-editor/insert-file (file &optional verbose)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
905 "Insert a message from a file."
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
906 (interactive "fInsert file as MIME message: \nP")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
907 (let* ((guess (mime-find-file-type file))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
908 (type (nth 0 guess))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
909 (subtype (nth 1 guess))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
910 (parameters (nth 2 guess))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
911 (encoding (nth 3 guess))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
912 (disposition-type (nth 4 guess))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
913 (disposition-params (nth 5 guess))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
914 )
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
915 (if verbose
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
916 (setq type (mime-prompt-for-type type)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
917 subtype (mime-prompt-for-subtype type subtype)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
918 ))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
919 (if (or (interactive-p) verbose)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
920 (setq encoding (mime-prompt-for-encoding encoding))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
921 )
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
922 (if (or (consp parameters) (stringp disposition-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
923 (let ((rest parameters) cell attribute value)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
924 (setq parameters "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
925 (while rest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
926 (setq cell (car rest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
927 (setq attribute (car cell))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
928 (setq value (cdr cell))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
929 (if (eq value 'file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
930 (setq value (std11-wrap-as-quoted-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
931 (file-name-nondirectory file)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
932 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
933 (setq parameters (concat parameters "; " attribute "=" value))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
934 (setq rest (cdr rest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
935 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
936 (if disposition-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
937 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
938 (setq parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
939 (concat parameters "\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
940 "Content-Disposition: " disposition-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
941 (setq rest disposition-params)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
942 (while rest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
943 (setq cell (car rest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
944 (setq attribute (car cell))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
945 (setq value (cdr cell))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
946 (if (eq value 'file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
947 (setq value (std11-wrap-as-quoted-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
948 (file-name-nondirectory file)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
949 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
950 (setq parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
951 (concat parameters "; " attribute "=" value))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
952 (setq rest (cdr rest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
953 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
954 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
955 ))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
956 (mime-editor/insert-tag type subtype parameters)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
957 (mime-editor/insert-binary-file file encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
958 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
959
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
960 (defun mime-editor/insert-external ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
961 "Insert a reference to external body."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
962 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
963 (mime-editor/insert-tag "message" "external-body" nil ";\n\t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
964 ;;(forward-char -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
965 ;;(insert "Content-Description: " (read-string "Content-Description: ") "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
966 ;;(forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
967 (let* ((pritype (mime-prompt-for-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
968 (subtype (mime-prompt-for-subtype pritype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
969 (parameters (mime-prompt-for-parameters pritype subtype ";\n\t")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
970 (and pritype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
971 subtype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
972 (insert "Content-Type: "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
973 pritype "/" subtype (or parameters "") "\n")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
974 (if (and (not (eobp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
975 (not (looking-at mime-editor/single-part-tag-regexp)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
976 (insert (mime-make-text-tag) "\n")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
977
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
978 (defun mime-editor/insert-voice ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
979 "Insert a voice message."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
980 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
981 (let ((encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
982 (completing-read
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
983 "What transfer encoding: "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
984 mime-file-encoding-method-alist nil t nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
985 (mime-editor/insert-tag "audio" "basic" nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
986 (mime-editor/define-encoding encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
987 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
988 (narrow-to-region (1- (point))(point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
989 (unwind-protect
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
990 (funcall mime-editor/voice-recorder encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
991 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
992 (insert "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
993 (invisible-region (point-min)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
994 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
995 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
996
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
997 (defun mime-editor/insert-signature (&optional arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
998 "Insert a signature file."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
999 (interactive "P")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1000 (let ((signature-insert-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1001 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1002 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1003 (apply (function mime-editor/insert-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1004 (mime-find-file-type signature-file-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1005 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1006 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1007 (insert-signature arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1008 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1009
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1010
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1011 ;; Insert a new tag around a point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1012
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1013 (defun mime-editor/insert-tag (&optional pritype subtype parameters delimiter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1014 "Insert new MIME tag and return a list of PRITYPE, SUBTYPE, and PARAMETERS.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1015 If nothing is inserted, return nil."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1016 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1017 (let ((p (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1018 (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1019 (if (and (re-search-forward mime-editor/tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1020 (< (match-beginning 0) p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1021 (< p (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1022 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1023 (goto-char (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1024 (goto-char p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1025 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1026 (let ((oldtag nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1027 (newtag nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1028 (current (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1029 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1030 (setq pritype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1031 (or pritype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1032 (mime-prompt-for-type)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1033 (setq subtype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1034 (or subtype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1035 (mime-prompt-for-subtype pritype)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1036 (setq parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1037 (or parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1038 (mime-prompt-for-parameters pritype subtype delimiter)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1039 ;; Make a new MIME tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1040 (setq newtag (mime-make-tag pritype subtype parameters))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1041 ;; Find an current MIME tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1042 (setq oldtag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1043 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1044 (if (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1045 (buffer-substring (match-beginning 0) (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1046 ;; Assume content type is 'text/plan'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1047 (mime-make-tag "text" "plain")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1048 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1049 ;; We are only interested in TEXT.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1050 (if (and oldtag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1051 (not (mime-test-content-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1052 (mime-editor/get-contype oldtag) "text")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1053 (setq oldtag nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1054 ;; Make a new tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1055 (if (or (not oldtag) ;Not text
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1056 (or mime-ignore-same-text-tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1057 (not (string-equal oldtag newtag))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1058 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1059 ;; Mark the beginning of the tag for convenience.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1060 (push-mark (point) 'nomsg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1061 (insert newtag "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1062 (list pritype subtype parameters) ;New tag is created.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1063 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1064 ;; Restore previous point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1065 (goto-char current)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1066 nil ;Nothing is created.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1067 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1068 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1069
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1070 (defun mime-editor/insert-binary-file (file &optional encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1071 "Insert binary FILE at point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1072 Optional argument ENCODING specifies an encoding method such as base64."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1073 (let* ((tagend (1- (point))) ;End of the tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1074 (hide-p (and mime-auto-hide-body
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1075 (stringp encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1076 (not
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1077 (let ((en (downcase encoding)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1078 (or (string-equal en "7bit")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1079 (string-equal en "8bit")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1080 (string-equal en "binary")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1081 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1082 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1083 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1084 (narrow-to-region tagend (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1085 (mime-insert-encoded-file file encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1086 (if hide-p
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1087 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1088 (invisible-region (point-min) (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1089 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1090 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1091 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1092 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1093 (or hide-p
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1094 (looking-at mime-editor/tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1095 (= (point)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1096 (mime-editor/insert-tag "text" "plain")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1097 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1098 ;; Define encoding even if it is 7bit.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1099 (if (stringp encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1100 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1101 (goto-char tagend) ; Make sure which line the tag is on.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1102 (mime-editor/define-encoding encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1103 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1104 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1105
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1106
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1107 ;; Commands work on a current message flagment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1108
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1109 (defun mime-editor/goto-tag ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1110 "Search for the beginning of the tagged MIME message."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1111 (let ((current (point)) multipart)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1112 (if (looking-at mime-editor/tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1113 t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1114 ;; At first, go to the end.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1115 (cond ((re-search-forward mime-editor/beginning-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1116 (goto-char (1- (match-beginning 0))) ;For multiline tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1117 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1118 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1119 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1120 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1121 ;; Then search for the beginning.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1122 (re-search-backward mime-editor/end-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1123 (or (looking-at mime-editor/beginning-tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1124 ;; Restore previous point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1125 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1126 (goto-char current)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1127 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1128 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1129 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1130
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1131 (defun mime-editor/content-beginning ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1132 "Return the point of the beginning of content."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1133 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1134 (let ((beg (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1135 (beginning-of-line) (point))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1136 (if (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1137 (let ((top (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1138 (goto-char (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1139 (if (and (= beg top)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1140 (= (following-char) ?\^M))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1141 (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1142 (forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1143 (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1144 ;; Default text/plain tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1145 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1146 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1147 (concat "\n" (regexp-quote mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1148 (if mime-ignore-preceding-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1149 "[ \t\n]*\n" "\n")) nil 'move)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1150 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1151 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1152
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1153 (defun mime-editor/content-end ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1154 "Return the point of the end of content."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1155 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1156 (let ((beg (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1157 (if (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1158 (let ((top (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1159 (goto-char (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1160 (if (invisible-p (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1161 (next-visible-point (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1162 ;; Move to the end of this text.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1163 (if (re-search-forward mime-editor/tag-regexp nil 'move)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1164 ;; Don't forget a multiline tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1165 (goto-char (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1166 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1167 (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1168 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1169 ;; Assume the message begins with text/plain.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1170 (goto-char (mime-editor/content-beginning))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1171 (if (re-search-forward mime-editor/tag-regexp nil 'move)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1172 ;; Don't forget a multiline tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1173 (goto-char (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1174 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1175 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1176
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1177 (defun mime-editor/define-charset (charset)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1178 "Set charset of current tag to CHARSET."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1179 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1180 (if (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1181 (let ((tag (buffer-substring (match-beginning 0) (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1182 (delete-region (match-beginning 0) (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1183 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1184 (mime-create-tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1185 (mime-editor/set-parameter
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1186 (mime-editor/get-contype tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1187 "charset" (upcase (symbol-name charset)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1188 (mime-editor/get-encoding tag)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1189 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1190
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1191 (defun mime-editor/define-encoding (encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1192 "Set encoding of current tag to ENCODING."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1193 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1194 (if (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1195 (let ((tag (buffer-substring (match-beginning 0) (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1196 (delete-region (match-beginning 0) (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1197 (insert (mime-create-tag (mime-editor/get-contype tag) encoding)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1198 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1199
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1200 (defun mime-editor/choose-charset ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1201 "Choose charset of a text following current point."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1202 (detect-mime-charset-region (point) (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1203 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1204
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1205 (defun mime-make-text-tag (&optional subtype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1206 "Make a tag for a text after current point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1207 Subtype of text type can be specified by an optional argument SUBTYPE.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1208 Otherwise, it is obtained from mime-content-types."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1209 (let* ((pritype "text")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1210 (subtype (or subtype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1211 (car (car (cdr (assoc pritype mime-content-types)))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1212 ;; Charset should be defined later.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1213 (mime-make-tag pritype subtype)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1214
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1215
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1216 ;; Tag handling functions
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1217
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1218 (defun mime-make-tag (pritype subtype &optional parameters encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1219 "Make a tag of MIME message of PRITYPE, SUBTYPE and optional PARAMETERS."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1220 (mime-create-tag (concat (or pritype "") "/" (or subtype "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1221 (or parameters ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1222 encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1223
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1224 (defun mime-create-tag (contype &optional encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1225 "Make a tag with CONTENT-TYPE and optional ENCODING."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1226 (format (if encoding mime-tag-format-with-encoding mime-tag-format)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1227 contype encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1228
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1229 (defun mime-editor/get-contype (tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1230 "Return Content-Type (including parameters) of TAG."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1231 (and (stringp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1232 (or (string-match mime-editor/single-part-tag-regexp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1233 (string-match mime-editor/multipart-beginning-regexp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1234 (string-match mime-editor/multipart-end-regexp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1235 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1236 (substring tag (match-beginning 1) (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1237 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1238
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1239 (defun mime-editor/get-encoding (tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1240 "Return encoding of TAG."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1241 (and (stringp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1242 (string-match mime-editor/single-part-tag-regexp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1243 (match-beginning 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1244 (not (= (match-beginning 3) (match-end 3)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1245 (substring tag (match-beginning 3) (match-end 3))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1246
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1247 (defun mime-get-parameter (contype parameter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1248 "For given CONTYPE return value for PARAMETER.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1249 Nil if no such parameter."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1250 (if (string-match
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1251 (concat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1252 ";[ \t\n]*"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1253 (regexp-quote parameter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1254 "[ \t\n]*=[ \t\n]*\\([^\" \t\n;]*\\|\"[^\"]*\"\\)\\([ \t\n]*;\\|$\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1255 contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1256 (substring contype (match-beginning 1) (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1257 nil ;No such parameter
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1258 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1259
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1260 (defun mime-editor/set-parameter (contype parameter value)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1261 "For given CONTYPE set PARAMETER to VALUE."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1262 (let (ctype opt-fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1263 (if (string-match "\n[^ \t\n\r]+:" contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1264 (setq ctype (substring contype 0 (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1265 opt-fields (substring contype (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1266 (setq ctype contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1267 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1268 (if (string-match
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1269 (concat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1270 ";[ \t\n]*\\("
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1271 (regexp-quote parameter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1272 "[ \t\n]*=[ \t\n]*\\([^\" \t\n;]*\\|\"[^\"]*\"\\)\\)[ \t\n]*\\(;\\|$\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1273 ctype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1274 ;; Change value
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1275 (concat (substring ctype 0 (match-beginning 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1276 parameter "=" value
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1277 (substring contype (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1278 opt-fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1279 (concat ctype "; " parameter "=" value opt-fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1280 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1281
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1282 (defun mime-strip-parameters (contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1283 "Return primary content-type and subtype without parameters for CONTYPE."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1284 (if (string-match "^[ \t]*\\([^; \t\n]*\\)" contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1285 (substring contype (match-beginning 1) (match-end 1)) nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1286
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1287 (defun mime-test-content-type (contype type &optional subtype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1288 "Test if CONTYPE is a TYPE and an optional SUBTYPE."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1289 (and (stringp contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1290 (stringp type)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1291 (string-match
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1292 (concat "^[ \t]*" (downcase type) "/" (downcase (or subtype "")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1293 (downcase contype))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1294
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1295
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1296 ;; Basic functions
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1297
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1298 (defun mime-find-file-type (file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1299 "Guess Content-Type, subtype, and parameters from FILE."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1300 (let ((guess nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1301 (guesses mime-file-types))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1302 (while (and (not guess) guesses)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1303 (if (string-match (car (car guesses)) file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1304 (setq guess (cdr (car guesses))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1305 (setq guesses (cdr guesses)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1306 guess
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1307 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1308
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1309 (defun mime-prompt-for-type (&optional default)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1310 "Ask for Content-type."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1311 (let ((type ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1312 ;; Repeat until primary content type is specified.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1313 (while (string-equal type "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1314 (setq type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1315 (completing-read "What content type: "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1316 mime-content-types
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1317 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1318 'require-match ;Type must be specified.
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1319 default
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1320 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1321 (if (string-equal type "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1322 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1323 (message "Content type is required.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1324 (beep)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1325 (sit-for 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1326 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1327 )
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1328 type))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1329
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1330 (defun mime-prompt-for-subtype (type &optional default)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1331 "Ask for subtype of media-type TYPE."
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1332 (let ((subtypes (cdr (assoc type mime-content-types))))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1333 (or (and default
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1334 (assoc default subtypes))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1335 (setq default (car (car subtypes)))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1336 ))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1337 (let* ((answer
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1338 (completing-read
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1339 (if default
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1340 (concat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1341 "What content subtype: (default " default ") ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1342 "What content subtype: ")
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1343 (cdr (assoc type mime-content-types))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1344 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1345 'require-match ;Subtype must be specified.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1346 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1347 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1348 (if (string-equal answer "") default answer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1349
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1350 (defun mime-prompt-for-parameters (pritype subtype &optional delimiter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1351 "Ask for Content-type parameters of Content-Type PRITYPE and SUBTYPE.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1352 Optional DELIMITER specifies parameter delimiter (';' by default)."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1353 (let* ((delimiter (or delimiter "; "))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1354 (parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1355 (mapconcat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1356 (function identity)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1357 (delq nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1358 (mime-prompt-for-parameters-1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1359 (cdr (assoc subtype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1360 (cdr (assoc pritype mime-content-types))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1361 delimiter
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1362 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1363 (if (and (stringp parameters)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1364 (not (string-equal parameters "")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1365 (concat delimiter parameters)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1366 "" ;"" if no parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1367 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1368
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1369 (defun mime-prompt-for-parameters-1 (optlist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1370 (apply (function append)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1371 (mapcar (function mime-prompt-for-parameter) optlist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1372
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1373 (defun mime-prompt-for-parameter (parameter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1374 "Ask for PARAMETER.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1375 Parameter must be '(PROMPT CHOICE1 (CHOISE2 ...))."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1376 (let* ((prompt (car parameter))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1377 (choices (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1378 (lambda (e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1379 (if (consp e) e (list e))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1380 (cdr parameter)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1381 (default (car (car choices)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1382 (answer nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1383 (if choices
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1384 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1385 (setq answer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1386 (completing-read
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1387 (concat "What " prompt
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1388 ": (default "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1389 (if (string-equal default "") "\"\"" default)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1390 ") ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1391 choices nil nil ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1392 ;; If nothing is selected, use default.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1393 (if (string-equal answer "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1394 (setq answer default)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1395 (setq answer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1396 (read-string (concat "What " prompt ": "))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1397 (cons (if (and answer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1398 (not (string-equal answer "")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1399 (concat prompt "="
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1400 ;; Note: control characters ignored!
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1401 (if (string-match mime-tspecials-regexp answer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1402 (concat "\"" answer "\"") answer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1403 (mime-prompt-for-parameters-1 (cdr (assoc answer (cdr parameter)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1404 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1405
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1406 (defun mime-prompt-for-encoding (default)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1407 "Ask for Content-Transfer-Encoding. [tm-edit.el]"
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1408 (let (encoding)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1409 (while (string=
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1410 (setq encoding
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1411 (completing-read
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1412 "What transfer encoding: "
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1413 mime-file-encoding-method-alist nil t default)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1414 )
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1415 ""))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 74
diff changeset
1416 encoding))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1417
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1418
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1419 ;;; @ Translate the tagged MIME messages into a MIME compliant message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1420 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1421
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1422 (defvar mime-editor/translate-buffer-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1423 '(mime-editor/pgp-enclose-buffer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1424 mime-editor/translate-header
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1425 mime-editor/translate-body))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1426
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1427 (defun mime-editor/translate-header ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1428 "Encode the message header into network representation."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1429 (mime/encode-message-header 'code-conversion)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1430 (run-hooks 'mime-editor/translate-header-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1431 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1432
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1433 (defun mime-editor/translate-buffer ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1434 "Encode the tagged MIME message in current buffer in MIME compliant message."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1435 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1436 (if (catch 'mime-editor/error
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1437 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1438 (run-hooks 'mime-editor/translate-buffer-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1439 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1440 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1441 (undo)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1442 (error "Translation error!")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1443 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1444
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1445 (defun mime-editor/find-inmost ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1446 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1447 (if (re-search-forward mime-editor/multipart-beginning-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1448 (let ((bb (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1449 (be (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1450 (type (buffer-substring (match-beginning 1)(match-end 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1451 end-exp eb ee)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1452 (setq end-exp (format "--}-<<%s>>\n" type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1453 (widen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1454 (if (re-search-forward end-exp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1455 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1456 (setq eb (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1457 (setq ee (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1458 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1459 (setq eb (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1460 (setq ee (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1461 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1462 (narrow-to-region be eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1463 (goto-char be)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1464 (if (re-search-forward mime-editor/multipart-beginning-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1465 (let (ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1466 (narrow-to-region (match-beginning 0)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1467 (mime-editor/find-inmost)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1468 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1469 (widen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1470 (list type bb be eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1471 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1472
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1473 (defun mime-editor/process-multipart-1 (boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1474 (let ((ret (mime-editor/find-inmost)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1475 (if ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1476 (let ((type (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1477 (bb (nth 1 ret))(be (nth 2 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1478 (eb (nth 3 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1479 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1480 (narrow-to-region bb eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1481 (delete-region bb be)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1482 (setq bb (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1483 (setq eb (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1484 (widen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1485 (goto-char eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1486 (if (looking-at mime-editor/multipart-end-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1487 (let ((beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1488 (end (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1489 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1490 (delete-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1491 (or (looking-at mime-editor/beginning-tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1492 (eobp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1493 (insert (concat (mime-make-text-tag) "\n"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1494 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1495 (cond ((string-equal type "quote")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1496 (mime-editor/enquote-region bb eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1497 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1498 ((string-equal type "signed")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1499 (cond ((eq mime-editor/signing-type 'pgp-elkins)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1500 (mime-editor/sign-pgp-elkins bb eb boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1501 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1502 ((eq mime-editor/signing-type 'pgp-kazu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1503 (mime-editor/sign-pgp-kazu bb eb boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1504 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1505 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1506 ((string-equal type "encrypted")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1507 (cond ((eq mime-editor/encrypting-type 'pgp-elkins)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1508 (mime-editor/encrypt-pgp-elkins bb eb boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1509 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1510 ((eq mime-editor/encrypting-type 'pgp-kazu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1511 (mime-editor/encrypt-pgp-kazu bb eb boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1512 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1513 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1514 (setq boundary
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1515 (nth 2 (mime-editor/translate-region bb eb
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1516 boundary t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1517 (goto-char bb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1518 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1519 (format "--[[multipart/%s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1520 boundary=\"%s\"][7bit]]\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1521 type boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1522 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1523 boundary))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1524
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1525 (defun mime-editor/enquote-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1526 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1527 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1528 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1529 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1530 (while (re-search-forward mime-editor/single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1531 (let ((tag (buffer-substring (match-beginning 0)(match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1532 (replace-match (concat "- " (substring tag 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1533 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1534
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1535 (defun mime-editor/dequote-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1536 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1537 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1538 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1539 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1540 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1541 mime-editor/quoted-single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1542 (let ((tag (buffer-substring (match-beginning 0)(match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1543 (replace-match (concat "-" (substring tag 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1544 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1545
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1546 (defun mime-editor/sign-pgp-elkins (beg end boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1547 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1548 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1549 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1550 (let* ((ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1551 (mime-editor/translate-region beg end boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1552 (ctype (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1553 (encoding (nth 1 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1554 (parts (nth 3 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1555 (pgp-boundary (concat "pgp-sign-" boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1556 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1557 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1558 (insert (format "Content-Type: %s\n" ctype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1559 (if encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1560 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1561 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1562 (insert "\n")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1563 (or (funcall mime-editor/pgp-sign-function
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1564 (point-min)(point-max) nil nil pgp-boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1565 (throw 'mime-editor/error 'pgp-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1566 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1567 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1568
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1569 (defvar mime-editor/encrypt-recipient-fields-list '("To" "cc"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1570
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1571 (defun mime-editor/make-encrypt-recipient-header ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1572 (let* ((names mime-editor/encrypt-recipient-fields-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1573 (values
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1574 (std11-field-bodies (cons "From" names)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1575 nil mail-header-separator))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1576 (from (prog1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1577 (car values)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1578 (setq values (cdr values))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1579 (header (and (stringp from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1580 (if (string-equal from "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1581 ""
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1582 (format "From: %s\n" from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1583 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1584 recipients)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1585 (while (and names values)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1586 (let ((name (car names))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1587 (value (car values))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1588 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1589 (and (stringp value)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1590 (or (string-equal value "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1591 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1592 (setq header (concat header name ": " value "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1593 recipients (if recipients
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1594 (concat recipients " ," value)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1595 value))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1596 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1597 (setq names (cdr names)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1598 values (cdr values))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1599 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1600 (vector from recipients header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1601 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1602
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1603 (defun mime-editor/encrypt-pgp-elkins (beg end boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1604 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1605 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1606 (let (from recipients header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1607 (let ((ret (mime-editor/make-encrypt-recipient-header)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1608 (setq from (aref ret 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1609 recipients (aref ret 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1610 header (aref ret 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1611 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1612 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1613 (let* ((ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1614 (mime-editor/translate-region beg end boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1615 (ctype (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1616 (encoding (nth 1 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1617 (parts (nth 3 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1618 (pgp-boundary (concat "pgp-" boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1619 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1620 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1621 (insert header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1622 (insert (format "Content-Type: %s\n" ctype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1623 (if encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1624 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1625 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1626 (insert "\n")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1627 (or (funcall mime-editor/pgp-encrypt-function
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1628 recipients (point-min) (point-max) from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1629 (throw 'mime-editor/error 'pgp-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1630 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1631 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1632 (insert (format "--[[multipart/encrypted;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1633 boundary=\"%s\";
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1634 protocol=\"application/pgp-encrypted\"][7bit]]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1635 --%s
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1636 Content-Type: application/pgp-encrypted
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1637
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1638 --%s
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1639 Content-Type: application/octet-stream
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1640 Content-Transfer-Encoding: 7bit
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1641
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1642 " pgp-boundary pgp-boundary pgp-boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1643 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1644 (insert (format "\n--%s--\n" pgp-boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1645 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1646
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1647 (defun mime-editor/sign-pgp-kazu (beg end boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1648 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1649 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1650 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1651 (let* ((ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1652 (mime-editor/translate-region beg end boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1653 (ctype (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1654 (encoding (nth 1 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1655 (parts (nth 3 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1656 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1657 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1658 (insert (format "Content-Type: %s\n" ctype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1659 (if encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1660 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1661 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1662 (insert "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1663 (or (as-binary-process
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1664 (funcall mime-editor/traditional-pgp-sign-function
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1665 beg (point-max)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1666 (throw 'mime-editor/error 'pgp-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1667 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1668 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1669 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1670 "--[[application/pgp; format=mime][7bit]]\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1671 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1672 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1673
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1674 (defun mime-editor/encrypt-pgp-kazu (beg end boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1675 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1676 (let (from recipients header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1677 (let ((ret (mime-editor/make-encrypt-recipient-header)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1678 (setq from (aref ret 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1679 recipients (aref ret 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1680 header (aref ret 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1681 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1682 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1683 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1684 (let* ((ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1685 (mime-editor/translate-region beg end boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1686 (ctype (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1687 (encoding (nth 1 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1688 (parts (nth 3 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1689 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1690 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1691 (insert header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1692 (insert (format "Content-Type: %s\n" ctype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1693 (if encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1694 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1695 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1696 (insert "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1697 (or (as-binary-process
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1698 (funcall mime-editor/pgp-encrypt-function
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1699 recipients beg (point-max) nil 'maybe)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1700 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1701 (throw 'mime-editor/error 'pgp-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1702 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1703 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1704 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1705 "--[[application/pgp; format=mime][7bit]]\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1706 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1707 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1708
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1709 (defun mime-editor/translate-body ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1710 "Encode the tagged MIME body in current buffer in MIME compliant message."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1711 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1712 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1713 (let ((boundary
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1714 (concat mime-multipart-boundary "_"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1715 (replace-space-with-underline (current-time-string))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1716 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1717 (i 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1718 ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1719 (while (mime-editor/process-multipart-1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1720 (format "%s-%d" boundary i))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1721 (setq i (1+ i))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1722 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1723 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1724 ;; We are interested in message body.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1725 (let* ((beg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1726 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1727 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1728 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1729 (concat "\n" (regexp-quote mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1730 (if mime-ignore-preceding-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1731 "[ \t\n]*\n" "\n")) nil 'move)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1732 (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1733 (end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1734 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1735 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1736 (and mime-ignore-trailing-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1737 (re-search-backward "[^ \t\n]\n" beg t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1738 (forward-char 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1739 (point))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1740 (setq ret (mime-editor/translate-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1741 beg end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1742 (format "%s-%d" boundary i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1743 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1744 (mime-editor/dequote-region (point-min)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1745 (let ((contype (car ret)) ;Content-Type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1746 (encoding (nth 1 ret)) ;Content-Transfer-Encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1747 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1748 ;; Make primary MIME headers.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1749 (or (mail-position-on-field "Mime-Version")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1750 (insert mime-editor/mime-version-value))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1751 ;; Remove old Content-Type and other fields.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1752 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1753 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1754 (search-forward (concat "\n" mail-header-separator "\n") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1755 (narrow-to-region (point-min) (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1756 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1757 (mime-delete-field "Content-Type")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1758 (mime-delete-field "Content-Transfer-Encoding"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1759 ;; Then, insert Content-Type and Content-Transfer-Encoding fields.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1760 (mail-position-on-field "Content-Type")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1761 (insert contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1762 (if encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1763 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1764 (mail-position-on-field "Content-Transfer-Encoding")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1765 (insert encoding)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1766 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1767
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1768 (defun mime-editor/translate-single-part-tag (&optional prefix)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1769 (if (re-search-forward mime-editor/single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1770 (let* ((beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1771 (end (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1772 (tag (buffer-substring beg end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1773 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1774 (delete-region beg end)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1775 (setq contype (mime-editor/get-contype tag))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1776 (setq encoding (mime-editor/get-encoding tag))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1777 (insert (concat prefix "--" boundary "\n"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1778 (save-restriction
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1779 (narrow-to-region (point)(point))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1780 (insert "Content-Type: " contype "\n")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1781 (if encoding
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1782 (insert "Content-Transfer-Encoding: " encoding "\n"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1783 (mime/encode-message-header)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1784 )
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1785 t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1786
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1787 (defun mime-editor/translate-region (beg end &optional boundary multipart)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1788 (if (null boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1789 (setq boundary
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1790 (concat mime-multipart-boundary "_"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1791 (replace-space-with-underline (current-time-string))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1792 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1793 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1794 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1795 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1796 (let ((tag nil) ;MIME tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1797 (contype nil) ;Content-Type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1798 (encoding nil) ;Content-Transfer-Encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1799 (nparts 0)) ;Number of body parts
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1800 ;; Normalize the body part by inserting appropriate message
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1801 ;; tags for every message contents.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1802 (mime-editor/normalize-body)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1803 ;; Counting the number of Content-Type.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1804 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1805 (while (re-search-forward mime-editor/single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1806 (setq nparts (1+ nparts)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1807 ;; Begin translation.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1808 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1809 ((and (<= nparts 1)(not multipart))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1810 ;; It's a singular message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1811 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1812 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1813 mime-editor/single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1814 (setq tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1815 (buffer-substring (match-beginning 0) (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1816 (delete-region (match-beginning 0) (1+ (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1817 (setq contype (mime-editor/get-contype tag))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1818 (setq encoding (mime-editor/get-encoding tag))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1819 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1820 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1821 ;; It's a multipart message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1822 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1823 (and (mime-editor/translate-single-part-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1824 (while (mime-editor/translate-single-part-tag "\n"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1825 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1826 ;; Define Content-Type as "multipart/mixed".
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1827 (setq contype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1828 (concat "multipart/mixed;\n boundary=\"" boundary "\""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1829 ;; Content-Transfer-Encoding must be "7bit".
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1830 ;; The following encoding can be `nil', but is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1831 ;; specified as is since there is no way that a user
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1832 ;; specifies it.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1833 (setq encoding "7bit")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1834 ;; Insert the trailer.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1835 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1836 (insert "\n--" boundary "--\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1837 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1838 (list contype encoding boundary nparts)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1839 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1840
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1841 (defun mime-editor/normalize-body ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1842 "Normalize the body part by inserting appropriate message tags."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1843 ;; Insert the first MIME tags if necessary.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1844 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1845 (if (not (looking-at mime-editor/single-part-tag-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1846 (insert (mime-make-text-tag) "\n"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1847 ;; Check each tag, and add new tag or correct it if necessary.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1848 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1849 (while (re-search-forward mime-editor/single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1850 (let* ((tag (buffer-substring (match-beginning 0) (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1851 (contype (mime-editor/get-contype tag))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1852 (charset (mime-get-parameter contype "charset"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1853 (encoding (mime-editor/get-encoding tag)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1854 ;; Remove extra whitespaces after the tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1855 (if (looking-at "[ \t]+$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1856 (delete-region (match-beginning 0) (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1857 (let ((beg (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1858 (end (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1859 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1860 (if (= end (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1861 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1862 (goto-char end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1863 (or (looking-at mime-editor/beginning-tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1864 (eobp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1865 (insert (mime-make-text-tag) "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1866 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1867 (visible-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1868 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1869 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1870 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1871 ((mime-test-content-type contype "message")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1872 ;; Content-type "message" should be sent as is.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1873 (forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1874 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1875 ((mime-test-content-type contype "text")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1876 ;; Define charset for text if necessary.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1877 (setq charset (if charset
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1878 (intern (downcase charset))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1879 (mime-editor/choose-charset)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1880 (mime-editor/define-charset charset)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1881 (cond ((string-equal contype "text/x-rot13-47")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1882 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1883 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1884 (set-mark (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1885 (goto-char (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1886 (tm:caesar-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1887 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1888 ((string-equal contype "text/enriched")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1889 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1890 (let ((beg (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1891 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1892 (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1893 (end (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1894 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1895 ;; Patch for hard newlines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1896 ;; (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1897 ;; (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1898 ;; (while (search-forward "\n" end t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1899 ;; (put-text-property (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1900 ;; (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1901 ;; 'hard t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1902 ;; End patch for hard newlines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1903 (enriched-encode beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1904 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1905 (if (search-forward "\n\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1906 (delete-region beg (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1907 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1908 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1909 ;; Point is now on current tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1910 ;; Define encoding and encode text if necessary.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1911 (or encoding ;Encoding is not specified.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1912 (let* ((encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1913 (cdr
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1914 (assq charset
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1915 mime-editor/charset-default-encoding-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1916 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1917 (beg (mime-editor/content-beginning))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1918 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1919 (encode-mime-charset-region beg (mime-editor/content-end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1920 charset)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1921 (mime-encode-region beg (mime-editor/content-end) encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1922 (mime-editor/define-encoding encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1923 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1924 (goto-char (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1925 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1926 ((null encoding) ;Encoding is not specified.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1927 ;; Application, image, audio, video, and any other
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1928 ;; unknown content-type without encoding should be
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1929 ;; encoded.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1930 (let* ((encoding "base64") ;Encode in BASE64 by default.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1931 (beg (mime-editor/content-beginning))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1932 (end (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1933 (body (buffer-substring beg end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1934 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1935 (mime-encode-region beg end encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1936 (mime-editor/define-encoding encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1937 (forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1938 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1939 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1940
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1941 (defun mime-delete-field (field)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1942 "Delete header FIELD."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1943 (let ((regexp (format "^%s:[ \t]*" field)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1944 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1945 (while (re-search-forward regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1946 (delete-region (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1947 (progn (forward-line 1) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1948 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1949
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1950
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1951 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1952 ;;; Platform dependent functions
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1953 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1954
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1955 ;; Sun implementations
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1956
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1957 (defun mime-editor/voice-recorder-for-sun (encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1958 "Record voice in a buffer using Sun audio device,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1959 and insert data encoded as ENCODING. [tm-edit.el]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1960 (message "Start the recording on %s. Type C-g to finish the recording..."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1961 (system-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1962 (mime-insert-encoded-file "/dev/audio" encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1963 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1964
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1965
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1966 ;;; @ Other useful commands.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1967 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1968
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1969 ;; Message forwarding commands as content-type "message/rfc822".
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1970
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1971 (defun mime-editor/insert-message (&optional message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1972 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1973 (let ((inserter (assoc-value major-mode mime-editor/message-inserter-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1974 (if (and inserter (fboundp inserter))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1975 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1976 (mime-editor/insert-tag "message" "rfc822")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1977 (funcall inserter message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1978 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1979 (message "Sorry, I don't have message inserter for your MUA.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1980 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1981
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1982 (defun mime-editor/insert-mail (&optional message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1983 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1984 (let ((inserter (assoc-value major-mode mime-editor/mail-inserter-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1985 (if (and inserter (fboundp inserter))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1986 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1987 (mime-editor/insert-tag "message" "rfc822")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1988 (funcall inserter message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1989 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1990 (message "Sorry, I don't have mail inserter for your MUA.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1991 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1992
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1993 (defun mime-editor/inserted-message-filter ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1994 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1995 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1996 (let ((header-start (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1997 (case-fold-search t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1998 beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1999 ;; for Emacs 18
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2000 ;; (if (re-search-forward "^$" (marker-position (mark-marker)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2001 (if (re-search-forward "^$" (mark t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2002 (narrow-to-region header-start (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2003 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2004 (goto-char header-start)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2005 (while (and (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2006 mime-editor/yank-ignored-field-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2007 (setq beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2008 (setq end (1+ (std11-field-end)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2009 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2010 (delete-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2011 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2012 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2013
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2014
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2015 ;;; @ multipart enclosure
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2016 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2017
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2018 (defun mime-editor/enclose-region (type beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2019 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2020 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2021 (let ((current (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2022 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2023 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2024 (insert (format "--<<%s>>-{\n" type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2025 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2026 (insert (format "--}-<<%s>>\n" type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2027 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2028 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2029 (or (looking-at mime-editor/beginning-tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2030 (eobp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2031 (insert (mime-make-text-tag) "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2032 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2033 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2034
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2035 (defun mime-editor/enclose-quote-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2036 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2037 (mime-editor/enclose-region "quote" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2038 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2039
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2040 (defun mime-editor/enclose-mixed-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2041 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2042 (mime-editor/enclose-region "mixed" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2043 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2044
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2045 (defun mime-editor/enclose-parallel-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2046 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2047 (mime-editor/enclose-region "parallel" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2048 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2049
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2050 (defun mime-editor/enclose-digest-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2051 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2052 (mime-editor/enclose-region "digest" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2053 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2054
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2055 (defun mime-editor/enclose-alternative-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2056 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2057 (mime-editor/enclose-region "alternative" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2058 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2059
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2060 (defun mime-editor/enclose-signed-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2061 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2062 (if mime-editor/signing-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2063 (mime-editor/enclose-region "signed" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2064 (message "Please specify signing type.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2065 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2066
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2067 (defun mime-editor/enclose-encrypted-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2068 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2069 (if mime-editor/signing-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2070 (mime-editor/enclose-region "encrypted" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2071 (message "Please specify encrypting type.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2072 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2073
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2074 (defun mime-editor/insert-key (&optional arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2075 "Insert a pgp public key."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2076 (interactive "P")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2077 (mime-editor/insert-tag "application" "pgp-keys")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2078 (mime-editor/define-encoding "7bit")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
2079 (funcall mime-editor/pgp-insert-public-key-function)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2080 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2081
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2082
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2083 ;;; @ flag setting
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2084 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2085
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2086 (defun mime-editor/set-split (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2087 (interactive
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2088 (list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2089 (y-or-n-p "Do you want to enable split?")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2090 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2091 (setq mime-editor/split-message arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2092 (if arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2093 (message "This message is enabled to split.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2094 (message "This message is not enabled to split.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2095 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2096
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2097 (defun mime-editor/toggle-transfer-level (&optional transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2098 "Toggle transfer-level is 7bit or 8bit through.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2099
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2100 Optional TRANSFER-LEVEL is a number of transfer-level, 7 or 8."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2101 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2102 (if (numberp transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2103 (setq mime-editor/transfer-level transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2104 (if (< mime-editor/transfer-level 8)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2105 (setq mime-editor/transfer-level 8)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2106 (setq mime-editor/transfer-level 7)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2107 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2108 (setq mime-editor/charset-default-encoding-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2109 (mime-editor/make-charset-default-encoding-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2110 mime-editor/transfer-level))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2111 (message (format "Current transfer-level is %d bit"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2112 mime-editor/transfer-level))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2113 (setq mime-editor/transfer-level-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2114 (mime/encoding-name mime-editor/transfer-level 'not-omit))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2115 (force-mode-line-update)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2116 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2117
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2118 (defun mime-editor/set-transfer-level-7bit ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2119 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2120 (mime-editor/toggle-transfer-level 7)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2121 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2122
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2123 (defun mime-editor/set-transfer-level-8bit ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2124 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2125 (mime-editor/toggle-transfer-level 8)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2126 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2127
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2128
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2129 ;;; @ pgp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2130 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2131
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2132 (defun mime-editor/set-sign (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2133 (interactive
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2134 (list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2135 (y-or-n-p "Do you want to sign?")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2136 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2137 (if arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2138 (if mime-editor/signing-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2139 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2140 (setq mime-editor/pgp-processing 'sign)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2141 (message "This message will be signed.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2142 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2143 (message "Please specify signing type.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2144 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2145 (if (eq mime-editor/pgp-processing 'sign)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2146 (setq mime-editor/pgp-processing nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2147 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2148 (message "This message will not be signed.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2149 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2150
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2151 (defun mime-editor/set-encrypt (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2152 (interactive
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2153 (list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2154 (y-or-n-p "Do you want to encrypt?")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2155 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2156 (if arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2157 (if mime-editor/encrypting-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2158 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2159 (setq mime-editor/pgp-processing 'encrypt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2160 (message "This message will be encrypt.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2161 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2162 (message "Please specify encrypting type.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2163 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2164 (if (eq mime-editor/pgp-processing 'encrypt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2165 (setq mime-editor/pgp-processing nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2166 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2167 (message "This message will not be encrypt.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2168 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2169
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2170 (defvar mime-editor/pgp-processing nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2171 (make-variable-buffer-local 'mime-editor/pgp-processing)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2172
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2173 (defun mime-editor/pgp-enclose-buffer ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2174 (let ((beg (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2175 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2176 (if (search-forward (concat "\n" mail-header-separator "\n"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2177 (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2178 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2179 (end (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2180 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2181 (if beg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2182 (cond ((eq mime-editor/pgp-processing 'sign)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2183 (mime-editor/enclose-signed-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2184 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2185 ((eq mime-editor/pgp-processing 'encrypt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2186 (mime-editor/enclose-encrypted-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2187 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2188 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2189
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2190
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2191 ;;; @ split
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2192 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2193
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2194 (defun mime-editor/insert-partial-header
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2195 (fields subject id number total separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2196 (insert fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2197 (insert (format "Subject: %s (%d/%d)\n" subject number total))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2198 (insert (format "Mime-Version: 1.0 (split by %s)\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2199 mime-editor/version-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2200 (insert (format "\
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2201 Content-Type: message/partial; id=%s; number=%d; total=%d\n%s\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2202 id number total separator))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2203 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2204
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2205 (defun mime-editor/split-and-send
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2206 (&optional cmd lines mime-editor/message-max-length)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2207 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2208 (or lines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2209 (setq lines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2210 (count-lines (point-min) (point-max)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2211 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2212 (or mime-editor/message-max-length
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2213 (setq mime-editor/message-max-length
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2214 (or (cdr (assq major-mode mime-editor/message-max-lines-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2215 mime-editor/message-default-max-lines))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2216 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2217 (let* ((mime-editor/draft-file-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2218 (or (buffer-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2219 (make-temp-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2220 (expand-file-name "tm-draft" mime/tmp-dir))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2221 (separator mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2222 (id (concat "\""
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2223 (replace-space-with-underline (current-time-string))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2224 "@" (system-name) "\"")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2225 (run-hooks 'mime-editor/before-split-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2226 (let ((the-buf (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2227 (copy-buf (get-buffer-create " *Original Message*"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2228 (header (std11-header-string-except
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2229 mime-editor/split-ignored-field-regexp separator))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2230 (subject (mail-fetch-field "subject"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2231 (total (+ (/ lines mime-editor/message-max-length)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2232 (if (> (mod lines mime-editor/message-max-length) 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2233 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2234 (command
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2235 (or cmd
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2236 (cdr
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2237 (assq major-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2238 mime-editor/split-message-sender-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2239 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2240 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2241 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2242 (error "Split sender is not specified for `%s'." major-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2243 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2244 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2245 (mime-editor/partial-number 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2246 data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2247 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2248 (set-buffer copy-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2249 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2250 (insert-buffer the-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2251 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2252 (if (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2253 (concat "^" (regexp-quote separator) "$") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2254 (let ((he (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2255 (replace-match "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2256 (narrow-to-region (point-min) he)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2257 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2258 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2259 (while (re-search-forward mime-editor/split-blind-field-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2260 (delete-region (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2261 (1+ (std11-field-end)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2262 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2263 (while (< mime-editor/partial-number total)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2264 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2265 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2266 (set-buffer copy-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2267 (setq data (buffer-substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2268 (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2269 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2270 (goto-line mime-editor/message-max-length)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2271 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2272 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2273 (delete-region (point-min)(point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2274 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2275 (mime-editor/insert-partial-header
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2276 header subject id mime-editor/partial-number total separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2277 (insert data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2278 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2279 (message (format "Sending %d/%d..."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2280 mime-editor/partial-number total))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2281 (call-interactively command)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2282 (message (format "Sending %d/%d... done"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2283 mime-editor/partial-number total))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2284 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2285 (setq mime-editor/partial-number
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2286 (1+ mime-editor/partial-number))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2287 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2288 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2289 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2290 (set-buffer copy-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2291 (setq data (buffer-string))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2292 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2293 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2294 (mime-editor/insert-partial-header
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2295 header subject id mime-editor/partial-number total separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2296 (insert data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2297 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2298 (message (format "Sending %d/%d..."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2299 mime-editor/partial-number total))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2300 (message (format "Sending %d/%d... done"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2301 mime-editor/partial-number total))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2302 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2303 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2304
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2305 (defun mime-editor/maybe-split-and-send (&optional cmd)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2306 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2307 (run-hooks 'mime-editor/before-send-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2308 (let ((mime-editor/message-max-length
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2309 (or (cdr (assq major-mode mime-editor/message-max-lines-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2310 mime-editor/message-default-max-lines))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2311 (lines (count-lines (point-min) (point-max)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2312 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2313 (if (and (> lines mime-editor/message-max-length)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2314 mime-editor/split-message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2315 (mime-editor/split-and-send cmd lines mime-editor/message-max-length)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2316 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2317
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2318
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2319 ;;; @ preview message
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2320 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2321
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2322 (defun mime-editor/preview-message ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2323 "preview editing MIME message. [tm-edit.el]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2324 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2325 (let* ((str (buffer-string))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2326 (separator mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2327 (the-buf (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2328 (buf-name (buffer-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2329 (temp-buf-name (concat "*temp-article:" buf-name "*"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2330 (buf (get-buffer temp-buf-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2331 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2332 (if buf
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2333 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2334 (switch-to-buffer buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2335 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2336 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2337 (setq buf (get-buffer-create temp-buf-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2338 (switch-to-buffer buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2339 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2340 (insert str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2341 (setq major-mode 'mime/temporary-message-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2342 (make-local-variable 'mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2343 (setq mail-header-separator separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2344 (make-local-variable 'mime/editing-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2345 (setq mime/editing-buffer the-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2346
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2347 (run-hooks 'mime-editor/translate-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2348 (mime-editor/translate-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2349 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2350 (if (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2351 (concat "^" (regexp-quote separator) "$"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2352 (replace-match "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2353 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2354 (mime/viewer-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2355 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2356
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2357 (defun mime-editor/quitting-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2358 (let ((temp mime::preview/article-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2359 buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2360 (mime-viewer/kill-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2361 (set-buffer temp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2362 (setq buf mime/editing-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2363 (kill-buffer temp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2364 (switch-to-buffer buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2365 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2366
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2367 (set-alist 'mime-viewer/quitting-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2368 'mime/temporary-message-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2369 (function mime-editor/quitting-method)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2370 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2371
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2372
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2373 ;;; @ draft preview
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2374 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2375 ;; by "OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2376 ;; Mon, 10 Apr 1995 20:03:07 +0900
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2377
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2378 (defvar mime-editor/draft-header-separator-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2379 '((news-reply-mode . mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2380 (mh-letter-mode . mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2381 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2382
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2383 (defvar mime::article/draft-header-separator nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2384
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2385 (defun mime-editor/draft-preview ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2386 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2387 (let ((sep (cdr (assq major-mode mime-editor/draft-header-separator-alist))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2388 (or (stringp sep) (setq sep (eval sep)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2389 (make-variable-buffer-local 'mime::article/draft-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2390 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2391 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2392 (concat "^\\(" (regexp-quote sep) "\\)?$"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2393 (setq mime::article/draft-header-separator
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2394 (buffer-substring (match-beginning 0) (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2395 (replace-match "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2396 (mime/viewer-mode (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2397 (pop-to-buffer (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2398 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2399
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2400 (defun mime-viewer::quitting-method/draft-preview ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2401 (let ((mother mime::preview/mother-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2402 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2403 (switch-to-buffer mother)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2404 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2405 (if (and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2406 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2407 (concat "^\\("
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2408 (regexp-quote mime::article/draft-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2409 "\\)?$") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2410 (bolp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2411 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2412 (insert mime::article/draft-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2413 (set-buffer-modified-p (buffer-modified-p))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2414 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2415 (mime-viewer/kill-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2416 (pop-to-buffer mother)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2417 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2418
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2419 (set-alist 'mime-viewer/quitting-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2420 'mh-letter-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2421 (function mime-viewer::quitting-method/draft-preview)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2422 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2423
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2424 (set-alist 'mime-viewer/quitting-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2425 'news-reply-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2426 (function mime-viewer::quitting-method/draft-preview)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2427 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2428
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2429
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2430 ;;; @ edit again
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2431 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2432
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2433 (defun mime-editor::edit-again (code-conversion)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2434 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2435 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2436 (let ((ctl (mime/Content-Type)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2437 (if ctl
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2438 (let ((ctype (car ctl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2439 (params (cdr ctl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2440 type stype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2441 (if (string-match "/" ctype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2442 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2443 (setq type (substring ctype 0 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2444 (setq stype (substring ctype (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2445 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2446 (setq type ctype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2447 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2448 (cond
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
2449 ((string-equal type "multipart")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2450 (let* ((boundary (assoc-value "boundary" params))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2451 (boundary-pat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2452 (concat "\n--" (regexp-quote boundary) "[ \t]*\n"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2453 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2454 (re-search-forward boundary-pat nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2455 (let ((bb (match-beginning 0)) eb tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2456 (setq tag (format "\n--<<%s>>-{\n" stype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2457 (goto-char bb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2458 (insert tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2459 (setq bb (+ bb (length tag)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2460 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2461 (concat "\n--" (regexp-quote boundary) "--[ \t]*\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2462 nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2463 (setq eb (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2464 (replace-match (format "--}-<<%s>>\n" stype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2465 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2466 (narrow-to-region bb eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2467 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2468 (while (re-search-forward boundary-pat nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2469 (let ((beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2470 end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2471 (delete-region beg (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2472 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2473 (if (re-search-forward boundary-pat nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2474 (setq end (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2475 (setq end (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2476 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2477 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2478 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2479 (mime-editor::edit-again code-conversion)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2480 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2481 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2482 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2483 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2484 (or (= (point-min) 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2485 (delete-region (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2486 (if (search-forward "\n\n" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2487 (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2488 (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2489 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2490 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2491 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2492 (let* (charset
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2493 (pstr
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2494 (let ((bytes (+ 14 (length ctype))))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2495 (mapconcat (function
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2496 (lambda (attr)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2497 (if (string-equal (car attr) "charset")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2498 (progn
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2499 (setq charset (cdr attr))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2500 "")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2501 (let* ((str
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2502 (concat (car attr)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2503 "=" (cdr attr))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2504 )
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2505 (bs (length str))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2506 )
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2507 (setq bytes (+ bytes bs 2))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2508 (if (< bytes 76)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2509 (concat "; " str)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2510 (setq bytes (+ bs 1))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2511 (concat ";\n " str)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2512 )
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2513 ))))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2514 params "")))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2515 encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2516 encoded)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2517 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2518 (if (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2519 "Content-Transfer-Encoding:" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2520 (let ((beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2521 (hbeg (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2522 (end (std11-field-end)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2523 (setq encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2524 (eliminate-top-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2525 (std11-unfold-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2526 (buffer-substring hbeg end))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2527 (if (or charset (string-equal type "text"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2528 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2529 (delete-region beg (1+ end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2530 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2531 (if (search-forward "\n\n" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2532 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2533 (mime-decode-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2534 (match-end 0)(point-max) encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2535 (setq encoded t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2536 encoding nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2537 )))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2538 (if (or code-conversion encoded)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2539 (decode-mime-charset-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2540 (point-min)(point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2541 (or charset default-mime-charset))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2542 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2543 (let ((he
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2544 (if (re-search-forward "^$" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2545 (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2546 (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2547 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2548 (if (= (point-min) 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2549 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2550 (goto-char he)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2551 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2552 (concat "\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2553 (mime-create-tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2554 (concat type "/" stype pstr) encoding)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2555 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2556 (delete-region (point-min) he)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2557 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2558 (mime-create-tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2559 (concat type "/" stype pstr) encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2560 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2561 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2562 (if code-conversion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2563 (decode-mime-charset-region (point-min) (point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2564 default-mime-charset)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2565 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2566 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2567
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2568 (defun mime/edit-again (&optional code-conversion no-separator no-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2569 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2570 (mime-editor::edit-again code-conversion)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2571 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2572 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2573 (narrow-to-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2574 (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2575 (if (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2576 (concat "^\\(" (regexp-quote mail-header-separator) "\\)?$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2577 nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2578 (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2579 (point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2580 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2581 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2582 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2583 "^\\(Content-.*\\|Mime-Version\\):" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2584 (delete-region (match-beginning 0) (1+ (std11-field-end)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2585 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2586 (or no-separator
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2587 (and (re-search-forward "^$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2588 (replace-match mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2589 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2590 (or no-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2591 (mime/editor-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2592 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2593
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2594
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2595 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2596 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2597
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2598 (provide 'tm-edit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2599
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2600 (run-hooks 'tm-edit-load-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2601
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2602 ;;; tm-edit.el ends here