annotate lisp/tm/tm-edit.el @ 74:54cc21c15cbb r20-0b32

Import from CVS: tag r20-0b32
author cvs
date Mon, 13 Aug 2007 09:04:33 +0200
parents 131b0175ea99
children c0c698873ce1
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
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
9 ;; Version: $Revision: 1.1.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
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
123 "$Id: tm-edit.el,v 1.1.1.2 1996/12/21 20:50:44 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"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
295 nil
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"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
300 nil
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"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
305 nil
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"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
310 nil
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"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
315 nil
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"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
320 nil
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"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
325 nil
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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
330 nil
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
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
653 ;;;###autoload
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
654 (defun mime/editor-mode ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
655 "MIME minor mode for editing the tagged MIME message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
656
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
657 In this mode, basically, the message is composed in the tagged MIME
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
658 format. The message tag looks like:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
659
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
660 `--[[text/plain; charset=ISO-2022-JP][7bit]]'.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
661
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
662 The tag specifies the MIME content type, subtype, optional parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
663 and transfer encoding of the message following the tag. Messages
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
664 without any tag are treated as `text/plain' by default. Charset and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
665 transfer encoding are automatically defined unless explicitly
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
666 specified. Binary messages such as audio and image are usually hidden.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
667 The messages in the tagged MIME format are automatically translated
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
668 into a MIME compliant message when exiting this mode.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
669
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
670 Available charsets depend on Emacs version being used. The following
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
671 lists the available charsets of each emacs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
672
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
673 EMACS 18: US-ASCII is only available.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
674 NEmacs: US-ASCII and ISO-2022-JP are available.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
675 EMACS 19: US-ASCII and ISO-8859-1 (or other charset) are available.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
676 XEmacs 19: US-ASCII and ISO-8859-1 (or other charset) are available.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
677 Mule: US-ASCII, ISO-8859-* (except for ISO-8859-5), KOI8-R,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
678 ISO-2022-JP, ISO-2022-JP-2, ISO-2022-KR, BIG5 and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
679 ISO-2022-INT-1 are available.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
680
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
681 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
682 be used to represent multilingual text in intermixed manner. Any
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
683 languages that has no registered charset are represented as either
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
684 ISO-2022-JP-2 or ISO-2022-INT-1 in mule.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
685
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
686 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
687 please set variable `default-mime-charset'. This variable must be
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
688 symbol of which name is a MIME charset.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
689
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
690 If you want to add more charsets in mule, please set variable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
691 `charsets-mime-charset-alist'. This variable must be alist of which
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
692 key is list of leading-char/charset and value is symbol of MIME
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
693 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
694 term of XEmacs/mule, mule merged EMACS and MULE 3.*) If name of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
695 coding-system is different as MIME charset, please set variable
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
696 `mime-charset-coding-system-alist'. This variable must be alist of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
697 which key is MIME charset and value is coding-system.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
698
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
699 Following commands are available in addition to major mode commands:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
700 \\[mime-editor/insert-text] insert a text message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
701 \\[mime-editor/insert-file] insert a (binary) file.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
702 \\[mime-editor/insert-external] insert a reference to external body.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
703 \\[mime-editor/insert-voice] insert a voice message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
704 \\[mime-editor/insert-message] insert a mail or news message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
705 \\[mime-editor/insert-mail] insert a mail message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
706 \\[mime-editor/insert-signature] insert a signature file at end.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
707 \\[mime-editor/insert-tag] insert a new MIME tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
708 \\[mime-editor/enclose-alternative-region] enclose as multipart/alternative.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
709 \\[mime-editor/enclose-parallel-region] enclose as multipart/parallel.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
710 \\[mime-editor/enclose-mixed-region] enclose as multipart/mixed.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
711 \\[mime-editor/enclose-digest-region] enclose as multipart/digest.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
712 \\[mime-editor/enclose-signed-region] enclose as PGP signed.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
713 \\[mime-editor/enclose-encrypted-region] enclose as PGP encrypted.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
714 \\[mime-editor/insert-key] insert PGP public key.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
715 \\[mime-editor/preview-message] preview editing MIME message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
716 \\[mime-editor/exit] exit and translate into a MIME compliant message.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
717 \\[mime-editor/maybe-translate] exit and translate if in MIME mode, then split.
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 8
diff changeset
718 \\[mime-editor/help] show this help.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
719
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
720 Additional commands are available in some major modes:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
721 C-c C-c exit, translate and run the original command.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
722 C-c C-s exit, translate and run the original command.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
723
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
724 The following is a message example written in the tagged MIME format.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
725 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
726
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
727 This is a conventional plain text. It should be translated
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
728 into text/plain.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
729 --[[text/plain]]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
730 This is also a plain text. But, it is explicitly specified as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
731 is.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
732 --[[text/plain; charset=ISO-2022-JP]]
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
733 これは charset を ISO-2022-JP に指定した日本語の plain テキス
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
734 トです.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
735 --[[text/richtext]]
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
736 <center>This is a richtext.</center>
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
737 --[[image/gif][base64]]^M...image encoded in base64 here...
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
738 --[[audio/basic][base64]]^M...audio encoded in base64 here...
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 User customizable variables (not documented all of them):
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
741 mime-prefix
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
742 Specifies a key prefix for MIME minor mode commands.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
743
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
744 mime-ignore-preceding-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
745 Preceding white spaces in a message body are ignored if non-nil.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
746
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
747 mime-ignore-trailing-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
748 Trailing white spaces in a message body are ignored if non-nil.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
749
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
750 mime-auto-fill-header
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
751 Fill header fields that contain encoded-words if non-nil.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
752
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
753 mime-auto-hide-body
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
754 Hide a non-textual body message encoded in base64 after insertion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
755 if non-nil.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
756
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
757 mime-editor/voice-recorder
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
758 Specifies a function to record a voice message and encode it.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
759 The function `mime-editor/voice-recorder-for-sun' is for Sun
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
760 SparcStations.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
761
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
762 mime/editor-mode-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
763 Turning on MIME mode calls the value of mime/editor-mode-hook, if
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
764 it is non-nil.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
765
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
766 mime-editor/translate-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
767 The value of mime-editor/translate-hook is called just before translating
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
768 the tagged MIME format into a MIME compliant message if it is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
769 non-nil. If the hook call the function mime-editor/insert-signature,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
770 the signature file will be inserted automatically.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
771
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
772 mime-editor/exit-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
773 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
774 non-nil."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
775 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
776 (if mime/editor-mode-flag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
777 (error "You are already editing a MIME message.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
778 (setq mime/editor-mode-flag t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
779 ;; Remember old key bindings.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
780 (if running-xemacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
781 (use-local-map (or (current-local-map) (make-sparse-keymap)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
782 (make-local-variable 'mime/editor-mode-old-local-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
783 (setq mime/editor-mode-old-local-map (current-local-map))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
784 ;; Add MIME commands to current local map.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
785 (use-local-map (copy-keymap (or (current-local-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
786 (make-sparse-keymap))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
787 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
788 (if (not (lookup-key (current-local-map) mime-prefix))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
789 (define-key (current-local-map) mime-prefix mime-editor/mime-map))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
790
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
791 ;; Set transfer level into mode line
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
792 ;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
793 (setq mime-editor/transfer-level-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
794 (mime/encoding-name mime-editor/transfer-level 'not-omit))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
795 (force-mode-line-update)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
796
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
797 ;; Define menu. Menus for other emacs implementations are
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
798 ;; welcome.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
799 (cond (running-xemacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
800 (mime-editor/define-menu-for-xemacs))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
801 ((>= emacs-major-version 19)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
802 (mime-editor/define-menu-for-emacs19)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
803 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
804 ;; end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
805
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
806 (enable-invisible)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
807
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
808 ;; I don't care about saving these.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
809 (setq paragraph-start
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
810 (regexp-or mime-editor/single-part-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
811 paragraph-start))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
812 (setq paragraph-separate
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
813 (regexp-or mime-editor/single-part-tag-regexp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
814 paragraph-separate))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
815 (run-hooks 'mime/editor-mode-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
816 (message
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
817 (substitute-command-keys
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
818 "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
819 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
820
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
821 ;;;###autoload
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
822 (defalias 'edit-mime 'mime/editor-mode) ; for convenience
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
823 (defalias 'mime-mode 'mime/editor-mode) ; for convenience
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
824
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
825 (defun mime-editor/exit (&optional nomime no-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
826 "Translate the tagged MIME message into a MIME compliant message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
827 With no argument encode a message in the buffer into MIME, otherwise
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
828 just return to previous mode."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
829 (interactive "P")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
830 (if (not mime/editor-mode-flag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
831 (if (null no-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
832 (error "You aren't editing a MIME message.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
833 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
834 (if (not nomime)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
835 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
836 (run-hooks 'mime-editor/translate-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
837 (mime-editor/translate-buffer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
838 ;; Restore previous state.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
839 (setq mime/editor-mode-flag nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
840 (cond (running-xemacs
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
841 (delete-menu-item (list mime-editor/menu-title)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
842 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
843 (use-local-map mime/editor-mode-old-local-map)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
844
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
845 (end-of-invisible)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
846 (set-buffer-modified-p (buffer-modified-p))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
847 (run-hooks 'mime-editor/exit-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
848 (message "Exit MIME editor mode.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
849 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
850
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
851 (defun mime-editor/maybe-translate ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
852 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
853 (mime-editor/exit nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
854 (call-interactively 'mime-editor/maybe-split-and-send)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
855 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
856
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
857 (defun mime-editor/help ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
858 "Show help message about MIME mode."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
859 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
860 (with-output-to-temp-buffer "*Help*"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
861 (princ "MIME editor mode:\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
862 (princ (documentation 'mime/editor-mode))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
863 (print-help-return-message)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
864
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
865 (defun mime-editor/insert-text ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
866 "Insert a text message.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
867 Charset is automatically obtained from the `mime/lc-charset-alist'."
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
868 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
869 (let ((ret (mime-editor/insert-tag "text" nil nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
870 (if ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
871 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
872 (if (looking-at mime-editor/single-part-tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
873 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
874 ;; Make a space between the following message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
875 (insert "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
876 (forward-char -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
877 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
878 (if (and (member (second ret) '("enriched" "richtext"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
879 (fboundp 'enriched-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
880 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
881 (enriched-mode t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
882 (if (boundp 'enriched-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
883 (enriched-mode nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
884 ))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
885
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
886 (defun mime-editor/insert-file (file)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
887 "Insert a message from a file."
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
888 (interactive "fInsert file as MIME message: ")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
889 (let* ((guess (mime-find-file-type file))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
890 (pritype (nth 0 guess))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
891 (subtype (nth 1 guess))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
892 (parameters (nth 2 guess))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
893 (default (nth 3 guess)) ;Guess encoding from its file name.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
894 (disposition-type (nth 4 guess))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
895 (disposition-params (nth 5 guess))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
896 (encoding
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
897 (if (not (interactive-p))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
898 default
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
899 (completing-read
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
900 (concat "What transfer encoding"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
901 (if default
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
902 (concat " (default "
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
903 (if (string-equal default "")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
904 "\"\""
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
905 default)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
906 ")"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
907 ))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
908 ": ")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
909 mime-file-encoding-method-alist nil t nil))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
910 (if (string-equal encoding "")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
911 (setq encoding default))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
912 (if (or (consp parameters) (stringp disposition-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
913 (let ((rest parameters) cell attribute value)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
914 (setq parameters "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
915 (while rest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
916 (setq cell (car rest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
917 (setq attribute (car cell))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
918 (setq value (cdr cell))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
919 (if (eq value 'file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
920 (setq value (std11-wrap-as-quoted-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
921 (file-name-nondirectory file)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
922 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
923 (setq parameters (concat parameters "; " attribute "=" value))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
924 (setq rest (cdr rest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
925 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
926 (if disposition-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
927 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
928 (setq parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
929 (concat parameters "\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
930 "Content-Disposition: " disposition-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
931 (setq rest disposition-params)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
932 (while rest
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
933 (setq cell (car rest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
934 (setq attribute (car cell))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
935 (setq value (cdr cell))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
936 (if (eq value 'file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
937 (setq value (std11-wrap-as-quoted-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
938 (file-name-nondirectory file)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
939 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
940 (setq parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
941 (concat parameters "; " attribute "=" value))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
942 (setq rest (cdr rest))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
943 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
944 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
945 ))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
946 (mime-editor/insert-tag pritype subtype parameters)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
947 (mime-editor/insert-binary-file file encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
948 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
949
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
950 (defun mime-editor/insert-external ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
951 "Insert a reference to external body."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
952 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
953 (mime-editor/insert-tag "message" "external-body" nil ";\n\t")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
954 ;;(forward-char -1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
955 ;;(insert "Content-Description: " (read-string "Content-Description: ") "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
956 ;;(forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
957 (let* ((pritype (mime-prompt-for-type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
958 (subtype (mime-prompt-for-subtype pritype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
959 (parameters (mime-prompt-for-parameters pritype subtype ";\n\t")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
960 (and pritype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
961 subtype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
962 (insert "Content-Type: "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
963 pritype "/" subtype (or parameters "") "\n")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
964 (if (and (not (eobp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
965 (not (looking-at mime-editor/single-part-tag-regexp)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
966 (insert (mime-make-text-tag) "\n")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
967
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
968 (defun mime-editor/insert-voice ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
969 "Insert a voice message."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
970 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
971 (let ((encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
972 (completing-read
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
973 "What transfer encoding: "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
974 mime-file-encoding-method-alist nil t nil)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
975 (mime-editor/insert-tag "audio" "basic" nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
976 (mime-editor/define-encoding encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
977 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
978 (narrow-to-region (1- (point))(point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
979 (unwind-protect
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
980 (funcall mime-editor/voice-recorder encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
981 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
982 (insert "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
983 (invisible-region (point-min)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
984 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
985 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
986
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
987 (defun mime-editor/insert-signature (&optional arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
988 "Insert a signature file."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
989 (interactive "P")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
990 (let ((signature-insert-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
991 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
992 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
993 (apply (function mime-editor/insert-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
994 (mime-find-file-type signature-file-name))
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 (insert-signature arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
998 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
999
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1000
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1001 ;; Insert a new tag around a point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1002
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1003 (defun mime-editor/insert-tag (&optional pritype subtype parameters delimiter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1004 "Insert new MIME tag and return a list of PRITYPE, SUBTYPE, and PARAMETERS.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1005 If nothing is inserted, return nil."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1006 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1007 (let ((p (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1008 (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1009 (if (and (re-search-forward mime-editor/tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1010 (< (match-beginning 0) p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1011 (< p (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1012 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1013 (goto-char (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1014 (goto-char p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1015 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1016 (let ((oldtag nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1017 (newtag nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1018 (current (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1019 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1020 (setq pritype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1021 (or pritype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1022 (mime-prompt-for-type)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1023 (setq subtype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1024 (or subtype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1025 (mime-prompt-for-subtype pritype)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1026 (setq parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1027 (or parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1028 (mime-prompt-for-parameters pritype subtype delimiter)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1029 ;; Make a new MIME tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1030 (setq newtag (mime-make-tag pritype subtype parameters))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1031 ;; Find an current MIME tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1032 (setq oldtag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1033 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1034 (if (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1035 (buffer-substring (match-beginning 0) (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1036 ;; Assume content type is 'text/plan'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1037 (mime-make-tag "text" "plain")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1038 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1039 ;; We are only interested in TEXT.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1040 (if (and oldtag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1041 (not (mime-test-content-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1042 (mime-editor/get-contype oldtag) "text")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1043 (setq oldtag nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1044 ;; Make a new tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1045 (if (or (not oldtag) ;Not text
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1046 (or mime-ignore-same-text-tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1047 (not (string-equal oldtag newtag))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1048 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1049 ;; Mark the beginning of the tag for convenience.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1050 (push-mark (point) 'nomsg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1051 (insert newtag "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1052 (list pritype subtype parameters) ;New tag is created.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1053 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1054 ;; Restore previous point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1055 (goto-char current)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1056 nil ;Nothing is created.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1057 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1058 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1059
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1060 (defun mime-editor/insert-binary-file (file &optional encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1061 "Insert binary FILE at point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1062 Optional argument ENCODING specifies an encoding method such as base64."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1063 (let* ((tagend (1- (point))) ;End of the tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1064 (hide-p (and mime-auto-hide-body
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1065 (stringp encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1066 (not
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1067 (let ((en (downcase encoding)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1068 (or (string-equal en "7bit")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1069 (string-equal en "8bit")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1070 (string-equal en "binary")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1071 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1072 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1073 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1074 (narrow-to-region tagend (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1075 (mime-insert-encoded-file file encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1076 (if hide-p
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1077 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1078 (invisible-region (point-min) (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1079 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1080 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1081 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1082 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1083 (or hide-p
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1084 (looking-at mime-editor/tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1085 (= (point)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1086 (mime-editor/insert-tag "text" "plain")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1087 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1088 ;; Define encoding even if it is 7bit.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1089 (if (stringp encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1090 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1091 (goto-char tagend) ; Make sure which line the tag is on.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1092 (mime-editor/define-encoding encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1093 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1094 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1095
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1096
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1097 ;; Commands work on a current message flagment.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1098
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1099 (defun mime-editor/goto-tag ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1100 "Search for the beginning of the tagged MIME message."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1101 (let ((current (point)) multipart)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1102 (if (looking-at mime-editor/tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1103 t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1104 ;; At first, go to the end.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1105 (cond ((re-search-forward mime-editor/beginning-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1106 (goto-char (1- (match-beginning 0))) ;For multiline tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1107 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1108 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1109 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1110 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1111 ;; Then search for the beginning.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1112 (re-search-backward mime-editor/end-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1113 (or (looking-at mime-editor/beginning-tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1114 ;; Restore previous point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1115 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1116 (goto-char current)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1117 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1118 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1119 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1120
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1121 (defun mime-editor/content-beginning ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1122 "Return the point of the beginning of content."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1123 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1124 (let ((beg (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1125 (beginning-of-line) (point))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1126 (if (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1127 (let ((top (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1128 (goto-char (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1129 (if (and (= beg top)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1130 (= (following-char) ?\^M))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1131 (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1132 (forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1133 (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1134 ;; Default text/plain tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1135 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1136 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1137 (concat "\n" (regexp-quote mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1138 (if mime-ignore-preceding-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1139 "[ \t\n]*\n" "\n")) nil 'move)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1140 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1141 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1142
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1143 (defun mime-editor/content-end ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1144 "Return the point of the end of content."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1145 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1146 (let ((beg (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1147 (if (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1148 (let ((top (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1149 (goto-char (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1150 (if (invisible-p (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1151 (next-visible-point (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1152 ;; Move to the end of this text.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1153 (if (re-search-forward mime-editor/tag-regexp nil 'move)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1154 ;; Don't forget a multiline tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1155 (goto-char (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1156 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1157 (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1158 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1159 ;; Assume the message begins with text/plain.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1160 (goto-char (mime-editor/content-beginning))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1161 (if (re-search-forward mime-editor/tag-regexp nil 'move)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1162 ;; Don't forget a multiline tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1163 (goto-char (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1164 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1165 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1166
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1167 (defun mime-editor/define-charset (charset)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1168 "Set charset of current tag to CHARSET."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1169 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1170 (if (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1171 (let ((tag (buffer-substring (match-beginning 0) (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1172 (delete-region (match-beginning 0) (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1173 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1174 (mime-create-tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1175 (mime-editor/set-parameter
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1176 (mime-editor/get-contype tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1177 "charset" (upcase (symbol-name charset)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1178 (mime-editor/get-encoding tag)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1179 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1180
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1181 (defun mime-editor/define-encoding (encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1182 "Set encoding of current tag to ENCODING."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1183 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1184 (if (mime-editor/goto-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1185 (let ((tag (buffer-substring (match-beginning 0) (match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1186 (delete-region (match-beginning 0) (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1187 (insert (mime-create-tag (mime-editor/get-contype tag) encoding)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1188 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1189
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1190 (defun mime-editor/choose-charset ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1191 "Choose charset of a text following current point."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1192 (detect-mime-charset-region (point) (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1193 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1194
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1195 (defun mime-make-text-tag (&optional subtype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1196 "Make a tag for a text after current point.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1197 Subtype of text type can be specified by an optional argument SUBTYPE.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1198 Otherwise, it is obtained from mime-content-types."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1199 (let* ((pritype "text")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1200 (subtype (or subtype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1201 (car (car (cdr (assoc pritype mime-content-types)))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1202 ;; Charset should be defined later.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1203 (mime-make-tag pritype subtype)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1204
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1205
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1206 ;; Tag handling functions
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1207
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1208 (defun mime-make-tag (pritype subtype &optional parameters encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1209 "Make a tag of MIME message of PRITYPE, SUBTYPE and optional PARAMETERS."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1210 (mime-create-tag (concat (or pritype "") "/" (or subtype "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1211 (or parameters ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1212 encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1213
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1214 (defun mime-create-tag (contype &optional encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1215 "Make a tag with CONTENT-TYPE and optional ENCODING."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1216 (format (if encoding mime-tag-format-with-encoding mime-tag-format)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1217 contype encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1218
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1219 (defun mime-editor/get-contype (tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1220 "Return Content-Type (including parameters) of TAG."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1221 (and (stringp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1222 (or (string-match mime-editor/single-part-tag-regexp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1223 (string-match mime-editor/multipart-beginning-regexp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1224 (string-match mime-editor/multipart-end-regexp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1225 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1226 (substring tag (match-beginning 1) (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1227 ))
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-encoding (tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1230 "Return encoding 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 (string-match mime-editor/single-part-tag-regexp tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1233 (match-beginning 3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1234 (not (= (match-beginning 3) (match-end 3)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1235 (substring tag (match-beginning 3) (match-end 3))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1236
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1237 (defun mime-get-parameter (contype parameter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1238 "For given CONTYPE return value for PARAMETER.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1239 Nil if no such parameter."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1240 (if (string-match
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1241 (concat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1242 ";[ \t\n]*"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1243 (regexp-quote parameter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1244 "[ \t\n]*=[ \t\n]*\\([^\" \t\n;]*\\|\"[^\"]*\"\\)\\([ \t\n]*;\\|$\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1245 contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1246 (substring contype (match-beginning 1) (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1247 nil ;No such parameter
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1248 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1249
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1250 (defun mime-editor/set-parameter (contype parameter value)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1251 "For given CONTYPE set PARAMETER to VALUE."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1252 (let (ctype opt-fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1253 (if (string-match "\n[^ \t\n\r]+:" contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1254 (setq ctype (substring contype 0 (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1255 opt-fields (substring contype (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1256 (setq ctype contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1257 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1258 (if (string-match
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1259 (concat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1260 ";[ \t\n]*\\("
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1261 (regexp-quote parameter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1262 "[ \t\n]*=[ \t\n]*\\([^\" \t\n;]*\\|\"[^\"]*\"\\)\\)[ \t\n]*\\(;\\|$\\)")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1263 ctype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1264 ;; Change value
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1265 (concat (substring ctype 0 (match-beginning 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1266 parameter "=" value
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1267 (substring contype (match-end 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1268 opt-fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1269 (concat ctype "; " parameter "=" value opt-fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1270 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1271
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1272 (defun mime-strip-parameters (contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1273 "Return primary content-type and subtype without parameters for CONTYPE."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1274 (if (string-match "^[ \t]*\\([^; \t\n]*\\)" contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1275 (substring contype (match-beginning 1) (match-end 1)) nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1276
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1277 (defun mime-test-content-type (contype type &optional subtype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1278 "Test if CONTYPE is a TYPE and an optional SUBTYPE."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1279 (and (stringp contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1280 (stringp type)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1281 (string-match
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1282 (concat "^[ \t]*" (downcase type) "/" (downcase (or subtype "")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1283 (downcase contype))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1284
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1285
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1286 ;; Basic functions
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1287
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1288 (defun mime-find-file-type (file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1289 "Guess Content-Type, subtype, and parameters from FILE."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1290 (let ((guess nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1291 (guesses mime-file-types))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1292 (while (and (not guess) guesses)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1293 (if (string-match (car (car guesses)) file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1294 (setq guess (cdr (car guesses))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1295 (setq guesses (cdr guesses)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1296 guess
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1297 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1298
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1299 (defun mime-prompt-for-type ()
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1300 "Ask for Content-type."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1301 (let ((type ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1302 ;; Repeat until primary content type is specified.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1303 (while (string-equal type "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1304 (setq type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1305 (completing-read "What content type: "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1306 mime-content-types
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1307 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1308 'require-match ;Type must be specified.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1309 nil
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1310 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1311 (if (string-equal type "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1312 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1313 (message "Content type is required.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1314 (beep)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1315 (sit-for 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1316 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1317 )
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1318 type
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1319 ))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1320
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1321 (defun mime-prompt-for-subtype (pritype)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1322 "Ask for Content-type subtype of Content-Type PRITYPE."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1323 (let* ((default (car (car (cdr (assoc pritype mime-content-types)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1324 (answer
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1325 (completing-read
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1326 (if default
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1327 (concat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1328 "What content subtype: (default " default ") ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1329 "What content subtype: ")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1330 (cdr (assoc pritype mime-content-types))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1331 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1332 'require-match ;Subtype must be specified.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1333 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1334 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1335 (if (string-equal answer "") default answer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1336
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1337 (defun mime-prompt-for-parameters (pritype subtype &optional delimiter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1338 "Ask for Content-type parameters of Content-Type PRITYPE and SUBTYPE.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1339 Optional DELIMITER specifies parameter delimiter (';' by default)."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1340 (let* ((delimiter (or delimiter "; "))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1341 (parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1342 (mapconcat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1343 (function identity)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1344 (delq nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1345 (mime-prompt-for-parameters-1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1346 (cdr (assoc subtype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1347 (cdr (assoc pritype mime-content-types))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1348 delimiter
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1349 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1350 (if (and (stringp parameters)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1351 (not (string-equal parameters "")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1352 (concat delimiter parameters)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1353 "" ;"" if no parameters
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1354 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1355
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1356 (defun mime-prompt-for-parameters-1 (optlist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1357 (apply (function append)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1358 (mapcar (function mime-prompt-for-parameter) optlist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1359
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1360 (defun mime-prompt-for-parameter (parameter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1361 "Ask for PARAMETER.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1362 Parameter must be '(PROMPT CHOICE1 (CHOISE2 ...))."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1363 (let* ((prompt (car parameter))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1364 (choices (mapcar (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1365 (lambda (e)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1366 (if (consp e) e (list e))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1367 (cdr parameter)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1368 (default (car (car choices)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1369 (answer nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1370 (if choices
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1371 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1372 (setq answer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1373 (completing-read
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1374 (concat "What " prompt
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1375 ": (default "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1376 (if (string-equal default "") "\"\"" default)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1377 ") ")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1378 choices nil nil ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1379 ;; If nothing is selected, use default.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1380 (if (string-equal answer "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1381 (setq answer default)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1382 (setq answer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1383 (read-string (concat "What " prompt ": "))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1384 (cons (if (and answer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1385 (not (string-equal answer "")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1386 (concat prompt "="
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1387 ;; Note: control characters ignored!
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1388 (if (string-match mime-tspecials-regexp answer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1389 (concat "\"" answer "\"") answer)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1390 (mime-prompt-for-parameters-1 (cdr (assoc answer (cdr parameter)))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1391 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1392
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1393 (defun mime-flag-region (from to flag)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1394 "Hides or shows lines from FROM to TO, according to FLAG.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1395 If FLAG is `\\n' (newline character) then text is shown,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1396 while if FLAG is `\\^M' (control-M) the text is hidden."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1397 (let ((buffer-read-only nil) ;Okay even if write protected.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1398 (modp (buffer-modified-p)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1399 (unwind-protect
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1400 (subst-char-in-region from to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1401 (if (= flag ?\n) ?\^M ?\n)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1402 flag t)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1403 (set-buffer-modified-p modp))))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1404
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1405
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1406 ;;; @ Translate the tagged MIME messages into a MIME compliant message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1407 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1408
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1409 (defvar mime-editor/translate-buffer-hook
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1410 '(mime-editor/pgp-enclose-buffer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1411 mime-editor/translate-header
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1412 mime-editor/translate-body))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1413
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1414 (defun mime-editor/translate-header ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1415 "Encode the message header into network representation."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1416 (mime/encode-message-header 'code-conversion)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1417 (run-hooks 'mime-editor/translate-header-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1418 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1419
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1420 (defun mime-editor/translate-buffer ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1421 "Encode the tagged MIME message in current buffer in MIME compliant message."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1422 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1423 (if (catch 'mime-editor/error
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1424 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1425 (run-hooks 'mime-editor/translate-buffer-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1426 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1427 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1428 (undo)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1429 (error "Translation error!")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1430 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1431
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1432 (defun mime-editor/find-inmost ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1433 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1434 (if (re-search-forward mime-editor/multipart-beginning-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1435 (let ((bb (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1436 (be (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1437 (type (buffer-substring (match-beginning 1)(match-end 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1438 end-exp eb ee)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1439 (setq end-exp (format "--}-<<%s>>\n" type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1440 (widen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1441 (if (re-search-forward end-exp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1442 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1443 (setq eb (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1444 (setq ee (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1445 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1446 (setq eb (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1447 (setq ee (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1448 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1449 (narrow-to-region be eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1450 (goto-char be)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1451 (if (re-search-forward mime-editor/multipart-beginning-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1452 (let (ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1453 (narrow-to-region (match-beginning 0)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1454 (mime-editor/find-inmost)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1455 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1456 (widen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1457 (list type bb be eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1458 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1459
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1460 (defun mime-editor/process-multipart-1 (boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1461 (let ((ret (mime-editor/find-inmost)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1462 (if ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1463 (let ((type (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1464 (bb (nth 1 ret))(be (nth 2 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1465 (eb (nth 3 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1466 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1467 (narrow-to-region bb eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1468 (delete-region bb be)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1469 (setq bb (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1470 (setq eb (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1471 (widen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1472 (goto-char eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1473 (if (looking-at mime-editor/multipart-end-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1474 (let ((beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1475 (end (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1476 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1477 (delete-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1478 (or (looking-at mime-editor/beginning-tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1479 (eobp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1480 (insert (concat (mime-make-text-tag) "\n"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1481 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1482 (cond ((string-equal type "quote")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1483 (mime-editor/enquote-region bb eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1484 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1485 ((string-equal type "signed")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1486 (cond ((eq mime-editor/signing-type 'pgp-elkins)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1487 (mime-editor/sign-pgp-elkins bb eb boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1488 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1489 ((eq mime-editor/signing-type 'pgp-kazu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1490 (mime-editor/sign-pgp-kazu bb eb boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1491 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1492 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1493 ((string-equal type "encrypted")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1494 (cond ((eq mime-editor/encrypting-type 'pgp-elkins)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1495 (mime-editor/encrypt-pgp-elkins bb eb boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1496 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1497 ((eq mime-editor/encrypting-type 'pgp-kazu)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1498 (mime-editor/encrypt-pgp-kazu bb eb boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1499 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1500 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1501 (setq boundary
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1502 (nth 2 (mime-editor/translate-region bb eb
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1503 boundary t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1504 (goto-char bb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1505 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1506 (format "--[[multipart/%s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1507 boundary=\"%s\"][7bit]]\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1508 type 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 boundary))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1511
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1512 (defun mime-editor/enquote-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1513 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1514 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1515 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1516 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1517 (while (re-search-forward mime-editor/single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1518 (let ((tag (buffer-substring (match-beginning 0)(match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1519 (replace-match (concat "- " (substring tag 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1520 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1521
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1522 (defun mime-editor/dequote-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1523 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1524 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1525 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1526 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1527 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1528 mime-editor/quoted-single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1529 (let ((tag (buffer-substring (match-beginning 0)(match-end 0))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1530 (replace-match (concat "-" (substring tag 2)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1531 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1532
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1533 (defun mime-editor/sign-pgp-elkins (beg end boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1534 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1535 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1536 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1537 (let* ((ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1538 (mime-editor/translate-region beg end boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1539 (ctype (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1540 (encoding (nth 1 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1541 (parts (nth 3 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1542 (pgp-boundary (concat "pgp-sign-" boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1543 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1544 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1545 (insert (format "Content-Type: %s\n" ctype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1546 (if encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1547 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1548 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1549 (insert "\n")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1550 (or (funcall mime-editor/pgp-sign-function
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1551 (point-min)(point-max) nil nil pgp-boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1552 (throw 'mime-editor/error 'pgp-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1553 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1554 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1555
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1556 (defvar mime-editor/encrypt-recipient-fields-list '("To" "cc"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1557
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1558 (defun mime-editor/make-encrypt-recipient-header ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1559 (let* ((names mime-editor/encrypt-recipient-fields-list)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1560 (values
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1561 (std11-field-bodies (cons "From" names)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1562 nil mail-header-separator))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1563 (from (prog1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1564 (car values)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1565 (setq values (cdr values))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1566 (header (and (stringp from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1567 (if (string-equal from "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1568 ""
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1569 (format "From: %s\n" from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1570 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1571 recipients)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1572 (while (and names values)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1573 (let ((name (car names))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1574 (value (car values))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1575 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1576 (and (stringp value)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1577 (or (string-equal value "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1578 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1579 (setq header (concat header name ": " value "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1580 recipients (if recipients
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1581 (concat recipients " ," value)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1582 value))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1583 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1584 (setq names (cdr names)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1585 values (cdr values))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1586 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1587 (vector from recipients header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1588 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1589
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1590 (defun mime-editor/encrypt-pgp-elkins (beg end boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1591 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1592 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1593 (let (from recipients header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1594 (let ((ret (mime-editor/make-encrypt-recipient-header)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1595 (setq from (aref ret 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1596 recipients (aref ret 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1597 header (aref ret 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1598 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1599 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1600 (let* ((ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1601 (mime-editor/translate-region beg end boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1602 (ctype (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1603 (encoding (nth 1 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1604 (parts (nth 3 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1605 (pgp-boundary (concat "pgp-" boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1606 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1607 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1608 (insert header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1609 (insert (format "Content-Type: %s\n" ctype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1610 (if encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1611 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1612 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1613 (insert "\n")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1614 (or (funcall mime-editor/pgp-encrypt-function
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1615 recipients (point-min) (point-max) from)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1616 (throw 'mime-editor/error 'pgp-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1617 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1618 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1619 (insert (format "--[[multipart/encrypted;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1620 boundary=\"%s\";
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1621 protocol=\"application/pgp-encrypted\"][7bit]]
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1622 --%s
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1623 Content-Type: application/pgp-encrypted
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1624
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1625 --%s
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1626 Content-Type: application/octet-stream
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1627 Content-Transfer-Encoding: 7bit
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1628
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1629 " pgp-boundary pgp-boundary pgp-boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1630 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1631 (insert (format "\n--%s--\n" pgp-boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1632 )))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1633
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1634 (defun mime-editor/sign-pgp-kazu (beg end boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1635 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1636 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1637 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1638 (let* ((ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1639 (mime-editor/translate-region beg end boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1640 (ctype (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1641 (encoding (nth 1 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1642 (parts (nth 3 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1643 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1644 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1645 (insert (format "Content-Type: %s\n" ctype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1646 (if encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1647 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1648 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1649 (insert "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1650 (or (as-binary-process
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1651 (funcall mime-editor/traditional-pgp-sign-function
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1652 beg (point-max)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1653 (throw 'mime-editor/error 'pgp-error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1654 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1655 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1656 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1657 "--[[application/pgp; format=mime][7bit]]\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1658 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1659 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1660
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1661 (defun mime-editor/encrypt-pgp-kazu (beg end boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1662 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1663 (let (from recipients header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1664 (let ((ret (mime-editor/make-encrypt-recipient-header)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1665 (setq from (aref ret 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1666 recipients (aref ret 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1667 header (aref ret 2))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1668 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1669 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1670 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1671 (let* ((ret
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1672 (mime-editor/translate-region beg end boundary))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1673 (ctype (car ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1674 (encoding (nth 1 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1675 (parts (nth 3 ret))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1676 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1677 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1678 (insert header)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1679 (insert (format "Content-Type: %s\n" ctype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1680 (if encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1681 (insert (format "Content-Transfer-Encoding: %s\n" encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1682 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1683 (insert "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1684 (or (as-binary-process
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1685 (funcall mime-editor/pgp-encrypt-function
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1686 recipients beg (point-max) nil 'maybe)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1687 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1688 (throw 'mime-editor/error 'pgp-error)
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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1692 "--[[application/pgp; format=mime][7bit]]\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1693 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1694 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1695
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1696 (defun mime-editor/translate-body ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1697 "Encode the tagged MIME body in current buffer in MIME compliant message."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1698 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1699 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1700 (let ((boundary
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1701 (concat mime-multipart-boundary "_"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1702 (replace-space-with-underline (current-time-string))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1703 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1704 (i 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1705 ret)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1706 (while (mime-editor/process-multipart-1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1707 (format "%s-%d" boundary i))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1708 (setq i (1+ i))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1709 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1710 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1711 ;; We are interested in message body.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1712 (let* ((beg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1713 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1714 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1715 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1716 (concat "\n" (regexp-quote mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1717 (if mime-ignore-preceding-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1718 "[ \t\n]*\n" "\n")) nil 'move)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1719 (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1720 (end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1721 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1722 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1723 (and mime-ignore-trailing-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1724 (re-search-backward "[^ \t\n]\n" beg t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1725 (forward-char 1))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1726 (point))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1727 (setq ret (mime-editor/translate-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1728 beg end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1729 (format "%s-%d" boundary i)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1730 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1731 (mime-editor/dequote-region (point-min)(point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1732 (let ((contype (car ret)) ;Content-Type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1733 (encoding (nth 1 ret)) ;Content-Transfer-Encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1734 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1735 ;; Make primary MIME headers.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1736 (or (mail-position-on-field "Mime-Version")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1737 (insert mime-editor/mime-version-value))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1738 ;; Remove old Content-Type and other fields.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1739 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1740 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1741 (search-forward (concat "\n" mail-header-separator "\n") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1742 (narrow-to-region (point-min) (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1743 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1744 (mime-delete-field "Content-Type")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1745 (mime-delete-field "Content-Transfer-Encoding"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1746 ;; Then, insert Content-Type and Content-Transfer-Encoding fields.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1747 (mail-position-on-field "Content-Type")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1748 (insert contype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1749 (if encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1750 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1751 (mail-position-on-field "Content-Transfer-Encoding")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1752 (insert encoding)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1753 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1754
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1755 (defun mime-editor/translate-single-part-tag (&optional prefix)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1756 (if (re-search-forward mime-editor/single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1757 (let* ((beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1758 (end (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1759 (tag (buffer-substring beg end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1760 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1761 (delete-region beg end)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1762 (setq contype (mime-editor/get-contype tag))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1763 (setq encoding (mime-editor/get-encoding tag))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1764 (insert (concat prefix "--" boundary "\n"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1765 (save-restriction
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1766 (narrow-to-region (point)(point))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1767 (insert "Content-Type: " contype "\n")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1768 (if encoding
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1769 (insert "Content-Transfer-Encoding: " encoding "\n"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1770 (mime/encode-message-header)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
1771 )
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1772 t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1773
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1774 (defun mime-editor/translate-region (beg end &optional boundary multipart)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1775 (if (null boundary)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1776 (setq boundary
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1777 (concat mime-multipart-boundary "_"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1778 (replace-space-with-underline (current-time-string))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1779 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1780 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1781 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1782 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1783 (let ((tag nil) ;MIME tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1784 (contype nil) ;Content-Type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1785 (encoding nil) ;Content-Transfer-Encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1786 (nparts 0)) ;Number of body parts
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1787 ;; Normalize the body part by inserting appropriate message
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1788 ;; tags for every message contents.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1789 (mime-editor/normalize-body)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1790 ;; Counting the number of Content-Type.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1791 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1792 (while (re-search-forward mime-editor/single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1793 (setq nparts (1+ nparts)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1794 ;; Begin translation.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1795 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1796 ((and (<= nparts 1)(not multipart))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1797 ;; It's a singular message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1798 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1799 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1800 mime-editor/single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1801 (setq tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1802 (buffer-substring (match-beginning 0) (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1803 (delete-region (match-beginning 0) (1+ (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1804 (setq contype (mime-editor/get-contype tag))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1805 (setq encoding (mime-editor/get-encoding tag))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1806 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1807 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1808 ;; It's a multipart message.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1809 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1810 (and (mime-editor/translate-single-part-tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1811 (while (mime-editor/translate-single-part-tag "\n"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1812 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1813 ;; Define Content-Type as "multipart/mixed".
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1814 (setq contype
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1815 (concat "multipart/mixed;\n boundary=\"" boundary "\""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1816 ;; Content-Transfer-Encoding must be "7bit".
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1817 ;; The following encoding can be `nil', but is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1818 ;; specified as is since there is no way that a user
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1819 ;; specifies it.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1820 (setq encoding "7bit")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1821 ;; Insert the trailer.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1822 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1823 (insert "\n--" boundary "--\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1824 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1825 (list contype encoding boundary nparts)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1826 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1827
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1828 (defun mime-editor/normalize-body ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1829 "Normalize the body part by inserting appropriate message tags."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1830 ;; Insert the first MIME tags if necessary.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1831 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1832 (if (not (looking-at mime-editor/single-part-tag-regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1833 (insert (mime-make-text-tag) "\n"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1834 ;; Check each tag, and add new tag or correct it if necessary.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1835 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1836 (while (re-search-forward mime-editor/single-part-tag-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1837 (let* ((tag (buffer-substring (match-beginning 0) (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1838 (contype (mime-editor/get-contype tag))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1839 (charset (mime-get-parameter contype "charset"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1840 (encoding (mime-editor/get-encoding tag)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1841 ;; Remove extra whitespaces after the tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1842 (if (looking-at "[ \t]+$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1843 (delete-region (match-beginning 0) (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1844 (let ((beg (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1845 (end (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1846 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1847 (if (= end (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1848 nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1849 (goto-char end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1850 (or (looking-at mime-editor/beginning-tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1851 (eobp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1852 (insert (mime-make-text-tag) "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1853 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1854 (visible-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1855 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1856 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1857 (cond
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1858 ((mime-test-content-type contype "message")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1859 ;; Content-type "message" should be sent as is.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1860 (forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1861 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1862 ((mime-test-content-type contype "text")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1863 ;; Define charset for text if necessary.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1864 (setq charset (if charset
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1865 (intern (downcase charset))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1866 (mime-editor/choose-charset)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1867 (mime-editor/define-charset charset)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1868 (cond ((string-equal contype "text/x-rot13-47")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1869 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1870 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1871 (set-mark (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1872 (goto-char (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1873 (tm:caesar-region)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1874 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1875 ((string-equal contype "text/enriched")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1876 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1877 (let ((beg (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1878 (forward-line)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1879 (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1880 (end (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1881 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1882 ;; Patch for hard newlines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1883 ;; (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1884 ;; (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1885 ;; (while (search-forward "\n" end t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1886 ;; (put-text-property (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1887 ;; (point)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1888 ;; 'hard t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1889 ;; End patch for hard newlines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1890 (enriched-encode beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1891 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1892 (if (search-forward "\n\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1893 (delete-region beg (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1894 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1895 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1896 ;; Point is now on current tag.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1897 ;; Define encoding and encode text if necessary.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1898 (or encoding ;Encoding is not specified.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1899 (let* ((encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1900 (cdr
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1901 (assq charset
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1902 mime-editor/charset-default-encoding-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1903 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1904 (beg (mime-editor/content-beginning))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1905 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1906 (encode-mime-charset-region beg (mime-editor/content-end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1907 charset)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1908 (mime-encode-region beg (mime-editor/content-end) encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1909 (mime-editor/define-encoding encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1910 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1911 (goto-char (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1912 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1913 ((null encoding) ;Encoding is not specified.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1914 ;; Application, image, audio, video, and any other
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1915 ;; unknown content-type without encoding should be
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1916 ;; encoded.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1917 (let* ((encoding "base64") ;Encode in BASE64 by default.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1918 (beg (mime-editor/content-beginning))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1919 (end (mime-editor/content-end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1920 (body (buffer-substring beg end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1921 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1922 (mime-encode-region beg end encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1923 (mime-editor/define-encoding encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1924 (forward-line 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1925 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1926 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1927
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1928 (defun mime-delete-field (field)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1929 "Delete header FIELD."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1930 (let ((regexp (format "^%s:[ \t]*" field)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1931 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1932 (while (re-search-forward regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1933 (delete-region (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1934 (progn (forward-line 1) (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1935 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1936
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1937
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1938 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1939 ;;; Platform dependent functions
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1940 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1941
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1942 ;; Sun implementations
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1943
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1944 (defun mime-editor/voice-recorder-for-sun (encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1945 "Record voice in a buffer using Sun audio device,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1946 and insert data encoded as ENCODING. [tm-edit.el]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1947 (message "Start the recording on %s. Type C-g to finish the recording..."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1948 (system-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1949 (mime-insert-encoded-file "/dev/audio" encoding)
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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1953 ;;; @ Other useful commands.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1954 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1955
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1956 ;; Message forwarding commands as content-type "message/rfc822".
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1957
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1958 (defun mime-editor/insert-message (&optional message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1959 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1960 (let ((inserter (assoc-value major-mode mime-editor/message-inserter-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1961 (if (and inserter (fboundp inserter))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1962 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1963 (mime-editor/insert-tag "message" "rfc822")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1964 (funcall inserter message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1965 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1966 (message "Sorry, I don't have message inserter for your MUA.")
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 (defun mime-editor/insert-mail (&optional message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1970 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1971 (let ((inserter (assoc-value major-mode mime-editor/mail-inserter-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1972 (if (and inserter (fboundp inserter))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1973 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1974 (mime-editor/insert-tag "message" "rfc822")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1975 (funcall inserter message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1976 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1977 (message "Sorry, I don't have mail inserter for your MUA.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1978 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1979
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1980 (defun mime-editor/inserted-message-filter ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1981 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1982 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1983 (let ((header-start (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1984 (case-fold-search t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1985 beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1986 ;; for Emacs 18
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1987 ;; (if (re-search-forward "^$" (marker-position (mark-marker)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1988 (if (re-search-forward "^$" (mark t))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1989 (narrow-to-region header-start (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1990 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1991 (goto-char header-start)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1992 (while (and (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1993 mime-editor/yank-ignored-field-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1994 (setq beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1995 (setq end (1+ (std11-field-end)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1996 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1997 (delete-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1998 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1999 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2000
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2001
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2002 ;;; @ multipart enclosure
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2003 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2004
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2005 (defun mime-editor/enclose-region (type beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2006 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2007 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2008 (let ((current (point)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2009 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2010 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2011 (insert (format "--<<%s>>-{\n" type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2012 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2013 (insert (format "--}-<<%s>>\n" type))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2014 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2015 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2016 (or (looking-at mime-editor/beginning-tag-regexp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2017 (eobp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2018 (insert (mime-make-text-tag) "\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2019 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2020 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2021
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2022 (defun mime-editor/enclose-quote-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2023 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2024 (mime-editor/enclose-region "quote" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2025 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2026
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2027 (defun mime-editor/enclose-mixed-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2028 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2029 (mime-editor/enclose-region "mixed" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2030 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2031
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2032 (defun mime-editor/enclose-parallel-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2033 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2034 (mime-editor/enclose-region "parallel" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2035 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2036
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2037 (defun mime-editor/enclose-digest-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2038 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2039 (mime-editor/enclose-region "digest" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2040 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2041
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2042 (defun mime-editor/enclose-alternative-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2043 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2044 (mime-editor/enclose-region "alternative" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2045 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2046
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2047 (defun mime-editor/enclose-signed-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2048 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2049 (if mime-editor/signing-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2050 (mime-editor/enclose-region "signed" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2051 (message "Please specify signing type.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2052 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2053
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2054 (defun mime-editor/enclose-encrypted-region (beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2055 (interactive "*r")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2056 (if mime-editor/signing-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2057 (mime-editor/enclose-region "encrypted" beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2058 (message "Please specify encrypting type.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2059 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2060
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2061 (defun mime-editor/insert-key (&optional arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2062 "Insert a pgp public key."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2063 (interactive "P")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2064 (mime-editor/insert-tag "application" "pgp-keys")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2065 (mime-editor/define-encoding "7bit")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
2066 (funcall mime-editor/pgp-insert-public-key-function)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2067 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2068
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2069
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2070 ;;; @ flag setting
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2071 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2072
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2073 (defun mime-editor/set-split (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2074 (interactive
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2075 (list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2076 (y-or-n-p "Do you want to enable split?")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2077 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2078 (setq mime-editor/split-message arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2079 (if arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2080 (message "This message is enabled to split.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2081 (message "This message is not enabled to split.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2082 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2083
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2084 (defun mime-editor/toggle-transfer-level (&optional transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2085 "Toggle transfer-level is 7bit or 8bit through.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2086
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2087 Optional TRANSFER-LEVEL is a number of transfer-level, 7 or 8."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2088 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2089 (if (numberp transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2090 (setq mime-editor/transfer-level transfer-level)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2091 (if (< mime-editor/transfer-level 8)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2092 (setq mime-editor/transfer-level 8)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2093 (setq mime-editor/transfer-level 7)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2094 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2095 (setq mime-editor/charset-default-encoding-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2096 (mime-editor/make-charset-default-encoding-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2097 mime-editor/transfer-level))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2098 (message (format "Current transfer-level is %d bit"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2099 mime-editor/transfer-level))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2100 (setq mime-editor/transfer-level-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2101 (mime/encoding-name mime-editor/transfer-level 'not-omit))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2102 (force-mode-line-update)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2103 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2104
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2105 (defun mime-editor/set-transfer-level-7bit ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2106 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2107 (mime-editor/toggle-transfer-level 7)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2108 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2109
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2110 (defun mime-editor/set-transfer-level-8bit ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2111 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2112 (mime-editor/toggle-transfer-level 8)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2113 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2114
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2115
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2116 ;;; @ pgp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2117 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2118
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2119 (defun mime-editor/set-sign (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2120 (interactive
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2121 (list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2122 (y-or-n-p "Do you want to sign?")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2123 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2124 (if arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2125 (if mime-editor/signing-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2126 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2127 (setq mime-editor/pgp-processing 'sign)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2128 (message "This message will be signed.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2129 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2130 (message "Please specify signing type.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2131 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2132 (if (eq mime-editor/pgp-processing 'sign)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2133 (setq mime-editor/pgp-processing nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2134 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2135 (message "This message will not be signed.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2136 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2137
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2138 (defun mime-editor/set-encrypt (arg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2139 (interactive
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2140 (list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2141 (y-or-n-p "Do you want to encrypt?")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2142 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2143 (if arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2144 (if mime-editor/encrypting-type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2145 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2146 (setq mime-editor/pgp-processing 'encrypt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2147 (message "This message will be encrypt.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2148 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2149 (message "Please specify encrypting type.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2150 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2151 (if (eq mime-editor/pgp-processing 'encrypt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2152 (setq mime-editor/pgp-processing nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2153 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2154 (message "This message will not be 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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2157 (defvar mime-editor/pgp-processing nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2158 (make-variable-buffer-local 'mime-editor/pgp-processing)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2159
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2160 (defun mime-editor/pgp-enclose-buffer ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2161 (let ((beg (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2162 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2163 (if (search-forward (concat "\n" mail-header-separator "\n"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2164 (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2165 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2166 (end (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2167 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2168 (if beg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2169 (cond ((eq mime-editor/pgp-processing 'sign)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2170 (mime-editor/enclose-signed-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2171 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2172 ((eq mime-editor/pgp-processing 'encrypt)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2173 (mime-editor/enclose-encrypted-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2174 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2175 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2176
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2177
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2178 ;;; @ split
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2179 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2180
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2181 (defun mime-editor/insert-partial-header
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2182 (fields subject id number total separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2183 (insert fields)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2184 (insert (format "Subject: %s (%d/%d)\n" subject number total))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2185 (insert (format "Mime-Version: 1.0 (split by %s)\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2186 mime-editor/version-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2187 (insert (format "\
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2188 Content-Type: message/partial; id=%s; number=%d; total=%d\n%s\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2189 id number total separator))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2190 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2191
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2192 (defun mime-editor/split-and-send
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2193 (&optional cmd lines mime-editor/message-max-length)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2194 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2195 (or lines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2196 (setq lines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2197 (count-lines (point-min) (point-max)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2198 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2199 (or mime-editor/message-max-length
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2200 (setq mime-editor/message-max-length
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2201 (or (cdr (assq major-mode mime-editor/message-max-lines-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2202 mime-editor/message-default-max-lines))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2203 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2204 (let* ((mime-editor/draft-file-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2205 (or (buffer-file-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2206 (make-temp-name
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2207 (expand-file-name "tm-draft" mime/tmp-dir))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2208 (separator mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2209 (id (concat "\""
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2210 (replace-space-with-underline (current-time-string))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2211 "@" (system-name) "\"")))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2212 (run-hooks 'mime-editor/before-split-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2213 (let ((the-buf (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2214 (copy-buf (get-buffer-create " *Original Message*"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2215 (header (std11-header-string-except
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2216 mime-editor/split-ignored-field-regexp separator))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2217 (subject (mail-fetch-field "subject"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2218 (total (+ (/ lines mime-editor/message-max-length)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2219 (if (> (mod lines mime-editor/message-max-length) 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2220 1)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2221 (command
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2222 (or cmd
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2223 (cdr
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2224 (assq major-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2225 mime-editor/split-message-sender-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2226 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2227 (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2228 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2229 (error "Split sender is not specified for `%s'." major-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2230 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2231 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2232 (mime-editor/partial-number 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2233 data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2234 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2235 (set-buffer copy-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2236 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2237 (insert-buffer the-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2238 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2239 (if (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2240 (concat "^" (regexp-quote separator) "$") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2241 (let ((he (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2242 (replace-match "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2243 (narrow-to-region (point-min) he)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2244 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2245 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2246 (while (re-search-forward mime-editor/split-blind-field-regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2247 (delete-region (match-beginning 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2248 (1+ (std11-field-end)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2249 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2250 (while (< mime-editor/partial-number total)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2251 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2252 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2253 (set-buffer copy-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2254 (setq data (buffer-substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2255 (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2256 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2257 (goto-line mime-editor/message-max-length)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2258 (point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2259 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2260 (delete-region (point-min)(point))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2261 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2262 (mime-editor/insert-partial-header
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2263 header subject id mime-editor/partial-number total separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2264 (insert data)
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 (message (format "Sending %d/%d..."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2267 mime-editor/partial-number total))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2268 (call-interactively command)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2269 (message (format "Sending %d/%d... done"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2270 mime-editor/partial-number total))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2271 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2272 (setq mime-editor/partial-number
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2273 (1+ mime-editor/partial-number))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2274 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2275 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2276 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2277 (set-buffer copy-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2278 (setq data (buffer-string))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2279 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2280 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2281 (mime-editor/insert-partial-header
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2282 header subject id mime-editor/partial-number total separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2283 (insert data)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2284 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2285 (message (format "Sending %d/%d..."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2286 mime-editor/partial-number total))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2287 (message (format "Sending %d/%d... done"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2288 mime-editor/partial-number total))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2289 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2290 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2291
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2292 (defun mime-editor/maybe-split-and-send (&optional cmd)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2293 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2294 (run-hooks 'mime-editor/before-send-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2295 (let ((mime-editor/message-max-length
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2296 (or (cdr (assq major-mode mime-editor/message-max-lines-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2297 mime-editor/message-default-max-lines))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2298 (lines (count-lines (point-min) (point-max)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2299 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2300 (if (and (> lines mime-editor/message-max-length)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2301 mime-editor/split-message)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2302 (mime-editor/split-and-send cmd lines mime-editor/message-max-length)
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
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2306 ;;; @ preview message
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2307 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2308
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2309 (defun mime-editor/preview-message ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2310 "preview editing MIME message. [tm-edit.el]"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2311 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2312 (let* ((str (buffer-string))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2313 (separator mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2314 (the-buf (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2315 (buf-name (buffer-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2316 (temp-buf-name (concat "*temp-article:" buf-name "*"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2317 (buf (get-buffer temp-buf-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2318 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2319 (if buf
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2320 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2321 (switch-to-buffer buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2322 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2323 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2324 (setq buf (get-buffer-create temp-buf-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2325 (switch-to-buffer buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2326 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2327 (insert str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2328 (setq major-mode 'mime/temporary-message-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2329 (make-local-variable 'mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2330 (setq mail-header-separator separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2331 (make-local-variable 'mime/editing-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2332 (setq mime/editing-buffer the-buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2333
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2334 (run-hooks 'mime-editor/translate-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2335 (mime-editor/translate-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2336 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2337 (if (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2338 (concat "^" (regexp-quote separator) "$"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2339 (replace-match "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2340 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2341 (mime/viewer-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2342 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2343
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2344 (defun mime-editor/quitting-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2345 (let ((temp mime::preview/article-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2346 buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2347 (mime-viewer/kill-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2348 (set-buffer temp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2349 (setq buf mime/editing-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2350 (kill-buffer temp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2351 (switch-to-buffer buf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2352 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2353
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2354 (set-alist 'mime-viewer/quitting-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2355 'mime/temporary-message-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2356 (function mime-editor/quitting-method)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2357 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2358
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2359
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2360 ;;; @ draft preview
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2361 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2362 ;; by "OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2363 ;; Mon, 10 Apr 1995 20:03:07 +0900
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2364
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2365 (defvar mime-editor/draft-header-separator-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2366 '((news-reply-mode . mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2367 (mh-letter-mode . mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2368 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2369
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2370 (defvar mime::article/draft-header-separator nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2371
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2372 (defun mime-editor/draft-preview ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2373 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2374 (let ((sep (cdr (assq major-mode mime-editor/draft-header-separator-alist))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2375 (or (stringp sep) (setq sep (eval sep)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2376 (make-variable-buffer-local 'mime::article/draft-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2377 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2378 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2379 (concat "^\\(" (regexp-quote sep) "\\)?$"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2380 (setq mime::article/draft-header-separator
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2381 (buffer-substring (match-beginning 0) (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2382 (replace-match "")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2383 (mime/viewer-mode (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2384 (pop-to-buffer (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2385 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2386
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2387 (defun mime-viewer::quitting-method/draft-preview ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2388 (let ((mother mime::preview/mother-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2389 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2390 (switch-to-buffer mother)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2391 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2392 (if (and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2393 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2394 (concat "^\\("
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2395 (regexp-quote mime::article/draft-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2396 "\\)?$") nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2397 (bolp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2398 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2399 (insert mime::article/draft-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2400 (set-buffer-modified-p (buffer-modified-p))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2401 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2402 (mime-viewer/kill-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2403 (pop-to-buffer mother)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2404 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2405
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2406 (set-alist 'mime-viewer/quitting-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2407 'mh-letter-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2408 (function mime-viewer::quitting-method/draft-preview)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2409 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2410
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2411 (set-alist 'mime-viewer/quitting-method-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2412 'news-reply-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2413 (function mime-viewer::quitting-method/draft-preview)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2414 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2415
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2416
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2417 ;;; @ edit again
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2418 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2419
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2420 (defun mime-editor::edit-again (code-conversion)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2421 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2422 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2423 (let ((ctl (mime/Content-Type)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2424 (if ctl
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2425 (let ((ctype (car ctl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2426 (params (cdr ctl))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2427 type stype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2428 (if (string-match "/" ctype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2429 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2430 (setq type (substring ctype 0 (match-beginning 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2431 (setq stype (substring ctype (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2432 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2433 (setq type ctype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2434 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2435 (cond
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
2436 ((string-equal type "multipart")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2437 (let* ((boundary (assoc-value "boundary" params))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2438 (boundary-pat
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2439 (concat "\n--" (regexp-quote boundary) "[ \t]*\n"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2440 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2441 (re-search-forward boundary-pat nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2442 (let ((bb (match-beginning 0)) eb tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2443 (setq tag (format "\n--<<%s>>-{\n" stype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2444 (goto-char bb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2445 (insert tag)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2446 (setq bb (+ bb (length tag)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2447 (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2448 (concat "\n--" (regexp-quote boundary) "--[ \t]*\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2449 nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2450 (setq eb (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2451 (replace-match (format "--}-<<%s>>\n" stype))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2452 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2453 (narrow-to-region bb eb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2454 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2455 (while (re-search-forward boundary-pat nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2456 (let ((beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2457 end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2458 (delete-region beg (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2459 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2460 (if (re-search-forward boundary-pat nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2461 (setq end (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2462 (setq end (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2463 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2464 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2465 (narrow-to-region beg end)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2466 (mime-editor::edit-again code-conversion)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2467 (goto-char (point-max))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2468 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2469 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2470 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2471 (or (= (point-min) 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2472 (delete-region (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2473 (if (search-forward "\n\n" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2474 (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2475 (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2476 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2477 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2478 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2479 (let* (charset
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2480 (pstr
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2481 (let ((bytes (+ 14 (length ctype))))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2482 (mapconcat (function
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2483 (lambda (attr)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2484 (if (string-equal (car attr) "charset")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2485 (progn
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2486 (setq charset (cdr attr))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2487 "")
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2488 (let* ((str
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2489 (concat (car attr)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2490 "=" (cdr attr))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2491 )
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2492 (bs (length str))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2493 )
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2494 (setq bytes (+ bytes bs 2))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2495 (if (< bytes 76)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2496 (concat "; " str)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2497 (setq bytes (+ bs 1))
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2498 (concat ";\n " str)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
2499 )
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 params "")))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2502 encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2503 encoded)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2504 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2505 (if (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2506 "Content-Transfer-Encoding:" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2507 (let ((beg (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2508 (hbeg (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2509 (end (std11-field-end)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2510 (setq encoding
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2511 (eliminate-top-spaces
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2512 (std11-unfold-string
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2513 (buffer-substring hbeg end))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2514 (if (or charset (string-equal type "text"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2515 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2516 (delete-region beg (1+ end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2517 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2518 (if (search-forward "\n\n" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2519 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2520 (mime-decode-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2521 (match-end 0)(point-max) encoding)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2522 (setq encoded t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2523 encoding nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2524 )))))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2525 (if (or code-conversion encoded)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2526 (decode-mime-charset-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2527 (point-min)(point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2528 (or charset default-mime-charset))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2529 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2530 (let ((he
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2531 (if (re-search-forward "^$" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2532 (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2533 (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2534 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2535 (if (= (point-min) 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2536 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2537 (goto-char he)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2538 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2539 (concat "\n"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2540 (mime-create-tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2541 (concat type "/" stype pstr) encoding)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2542 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2543 (delete-region (point-min) he)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2544 (insert
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2545 (mime-create-tag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2546 (concat type "/" stype pstr) encoding))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2547 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2548 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2549 (if code-conversion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2550 (decode-mime-charset-region (point-min) (point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2551 default-mime-charset)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2552 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2553 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2554
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2555 (defun mime/edit-again (&optional code-conversion no-separator no-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2556 (interactive)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2557 (mime-editor::edit-again code-conversion)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2558 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2559 (save-restriction
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2560 (narrow-to-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2561 (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2562 (if (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2563 (concat "^\\(" (regexp-quote mail-header-separator) "\\)?$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2564 nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2565 (match-end 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2566 (point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2567 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2568 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2569 (while (re-search-forward
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2570 "^\\(Content-.*\\|Mime-Version\\):" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2571 (delete-region (match-beginning 0) (1+ (std11-field-end)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2572 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2573 (or no-separator
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2574 (and (re-search-forward "^$")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2575 (replace-match mail-header-separator)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2576 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2577 (or no-mode
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2578 (mime/editor-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2579 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2580
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2581
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2582 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2583 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2584
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2585 (provide 'tm-edit)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2586
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2587 (run-hooks 'tm-edit-load-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2588
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2589 ;;; tm-edit.el ends here