annotate lisp/tm/tm-edit.el @ 88:821dec489c24 r20-0

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