annotate lisp/tm/tm-edit.el @ 10:49a24b4fd526 r19-15b6

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