annotate lisp/tm/tm-edit.el @ 22:8fc7fe29b841 r19-15b94

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