annotate lisp/vm/vm-digest.el @ 147:e186c2b7192d xemacs-20-2

Added tag r20-2p1 for changeset 2af401a6ecca
author cvs
date Mon, 13 Aug 2007 09:34:48 +0200
parents 2af401a6ecca
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; Message encapsulation
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2 ;;; Copyright (C) 1989, 1990, 1993, 1994, 1997 Kyle E. Jones
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 (provide 'vm-digest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (defun vm-no-frills-encapsulate-message (m keep-list discard-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 "Encapsulate a message M for forwarding, simply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 No message encapsulation standard is used. The message is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 inserted at point in the current buffer, surrounded by two dashed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 start/end separator lines. Point is not moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 M should be a message struct for a real message, not a virtual message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 This is the message that will be encapsulated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 KEEP-LIST should be a list of regexps matching headers to keep.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 DISCARD-REGEXP should be a regexp that matches headers to be discarded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 KEEP-LIST and DISCARD-REGEXP are used to order and trim the headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 to be forwarded. See the docs for vm-reorder-message-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 to find out how KEEP-LIST and DISCARD-REGEXP are used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (let ((target-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 source-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; narrow to a zero length region to avoid interacting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; with anything that might have already been inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; into the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (insert "------- start of forwarded message -------\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (setq source-buffer (vm-buffer-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (set-buffer source-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (set-buffer target-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (insert-buffer-substring source-buffer (vm-headers-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (vm-text-end-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (vm-reorder-message-headers nil nil "\\(X-VM-\\|Status:\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (vm-reorder-message-headers nil keep-list discard-regexp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (insert "------- end of forwarded message -------\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
57 (defun vm-mime-encapsulate-messages (message-list keep-list discard-regexp
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
58 always-use-digest)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
59 "Encapsulate the messages in MESSAGE-LIST as per the MIME spec.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
60 The resulting digest is inserted at point in the current buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
61 Point is not moved.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
62
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
63 MESSAGE-LIST should be a list of message structs (real or virtual).
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
64 These are the messages that will be encapsulated.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
65 KEEP-LIST should be a list of regexps matching headers to keep.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
66 DISCARD-REGEXP should be a regexp that matches headers to be discarded.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
67 KEEP-LIST and DISCARD-REGEXP are used to order and trim the headers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
68 to be forwarded. See the docs for vm-reorder-message-headers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
69 to find out how KEEP-LIST and DISCARD-REGEXP are used.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
70
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
71 If ALWAYS-USE-DIGEST is non-nil, always encapsulate for a multipart/digest.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
72 Otherwise if there are fewer than two messages to be encapsulated
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
73 leave off the multipart boundary strings. The caller is assumed to
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
74 be using message/rfc822 or message/news encoding instead.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
75
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
76 If multipart/digest encapsulation is done, the function returns
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
77 the multipart boundary parameter (string) that should be used in
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
78 the Content-Type header. Otherwise nil is returned."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
79 (if message-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
80 (let ((target-buffer (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
81 (boundary-positions nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
82 (mlist message-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
83 (mime-keep-list (append keep-list vm-mime-header-list))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
84 (boundary nil)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
85 source-buffer m start n beg)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
86 (save-restriction
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
87 ;; narrow to a zero length region to avoid interacting
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
88 ;; with anything that might have already been inserted
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
89 ;; into the buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
90 (narrow-to-region (point) (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
91 (setq start (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
92 (while mlist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
93 (setq boundary-positions (cons (point-marker) boundary-positions))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
94 (setq m (vm-real-message-of (car mlist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
95 source-buffer (vm-buffer-of m))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
96 (setq beg (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
97 (vm-insert-region-from-buffer source-buffer (vm-headers-of m)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
98 (vm-text-end-of m))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
99 (goto-char beg)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
100 (vm-reorder-message-headers nil nil "\\(X-VM-\\|Status:\\)")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
101 (vm-reorder-message-headers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
102 nil (if (vm-mime-plain-message-p m)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
103 keep-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
104 mime-keep-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
105 discard-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
106 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
107 (setq mlist (cdr mlist)))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
108 (if (and (< (length message-list) 2) (not always-use-digest))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
109 nil
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
110 (goto-char start)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
111 (setq boundary (vm-mime-make-multipart-boundary))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
112 (while (re-search-forward (concat "^--"
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
113 (regexp-quote boundary)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
114 "\\(--\\)?$")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
115 nil t)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
116 (setq boundary (vm-mime-make-multipart-boundary))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
117 (goto-char start))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
118 (goto-char (point-max))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
119 (insert "\n--" boundary "--\n")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
120 (while boundary-positions
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
121 (goto-char (car boundary-positions))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
122 (insert "\n--" boundary "\n\n")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
123 (setq boundary-positions (cdr boundary-positions)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
124 (goto-char start)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
125 (setq n (length message-list))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
126 (insert
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
127 (format "This is a digest, %d messages, MIME encapsulation.\n"
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 118
diff changeset
128 n)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
129 (goto-char start))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
130 boundary )))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
131
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
132 (defun vm-mime-burst-message (m)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
133 "Burst messages from the digest message M.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
134 M should be a message struct for a real message.
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
135 MIME encoding is expected. Somewhere within the MIME layout
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
136 there must be at least one part of type message/news, message/rfc822 or
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
137 multipart/digest. If there are multiple parts matching those types,
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
138 all of them will be burst."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
139 (let ((ident-header nil)
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
140 (did-burst nil)
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
141 (list (vm-mime-find-digests-in-layout (vm-mm-layout m))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
142 (if vm-digest-identifier-header-format
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
143 (setq ident-header (vm-sprintf 'vm-digest-identifier-header-format m)))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
144 (while list
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
145 (setq did-burst (or did-burst
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
146 (vm-mime-burst-layout (car list) ident-header)))
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
147 (setq list (cdr list)))
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
148 did-burst))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
149
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
150 (defun vm-mime-burst-layout (layout ident-header)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
151 (let ((work-buffer nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
152 (folder-buffer (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
153 start part-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
154 (folder-type vm-folder-type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
155 (unwind-protect
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
156 (vm-save-restriction
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
157 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
158 (widen)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
159 (setq work-buffer (generate-new-buffer "*vm-work*"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
160 (buffer-disable-undo work-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
161 (set-buffer work-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
162 (cond ((not (vectorp layout))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
163 (error "Not a MIME message"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
164 ((vm-mime-types-match "message"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
165 (car (vm-mm-layout-type layout)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
166 (insert (vm-leading-message-separator folder-type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
167 (and ident-header (insert ident-header))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
168 (setq start (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
169 (vm-mime-insert-mime-body layout)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
170 (vm-munge-message-separators folder-type start (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
171 (insert (vm-trailing-message-separator folder-type)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
172 ((vm-mime-types-match "multipart/digest"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
173 (car (vm-mm-layout-type layout)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
174 (setq part-list (vm-mm-layout-parts layout))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
175 (while part-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
176 ;; Maybe we should verify that each part is
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
177 ;; of type message/rfc822 or message/news in
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
178 ;; here. But it seems more useful to just
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
179 ;; copy whatever the contents are and let the
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
180 ;; user see the goop, whatever type it really
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
181 ;; is.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
182 (insert (vm-leading-message-separator folder-type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
183 (and ident-header (insert ident-header))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
184 (setq start (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
185 (vm-mime-insert-mime-body (car part-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
186 (vm-munge-message-separators folder-type start (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
187 (insert (vm-trailing-message-separator folder-type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
188 (setq part-list (cdr part-list))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
189 (t (error
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
190 "MIME type is not multipart/digest or message/rfc822 or message/news")))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
191 ;; do header conversions.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
192 (let ((vm-folder-type folder-type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
193 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
194 (while (vm-find-leading-message-separator)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
195 (vm-skip-past-leading-message-separator)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
196 (vm-convert-folder-type-headers folder-type folder-type)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
197 (vm-find-trailing-message-separator)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
198 (vm-skip-past-trailing-message-separator)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
199 ;; now insert the messages into the folder buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
200 (cond ((not (zerop (buffer-size)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
201 (set-buffer folder-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
202 (let ((old-buffer-modified-p (buffer-modified-p))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
203 (buffer-read-only nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
204 (inhibit-quit t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
205 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
206 (insert-buffer-substring work-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
207 (set-buffer-modified-p old-buffer-modified-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
208 ;; return non-nil so caller knows we found some messages
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
209 t ))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
210 ;; return nil so the caller knows we didn't find anything
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
211 (t nil))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
212 (and work-buffer (kill-buffer work-buffer)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
213
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defun vm-rfc934-char-stuff-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "Quote RFC 934 message separators between START and END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 START and END are buffer positions in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 Lines beginning with `-' in the region have `- ' prepended to them."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (setq end (vm-marker end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (while (and (< (point) end) (re-search-forward "^-" end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (replace-match "- -" t t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (set-marker end nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (defun vm-rfc934-char-unstuff-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 "Unquote lines in between START and END as per RFC 934.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 START and END are buffer positions in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 Lines beginning with `- ' in the region have that string stripped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 from them."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (setq end (vm-marker end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (while (and (< (point) end) (re-search-forward "^- " end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (replace-match "" t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (forward-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (set-marker end nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defun vm-rfc934-encapsulate-messages (message-list keep-list discard-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "Encapsulate the messages in MESSAGE-LIST as per RFC 934.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 The resulting digest is inserted at point in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 Point is not moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 MESSAGE-LIST should be a list of message structs (real or virtual).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 These are the messages that will be encapsulated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 KEEP-LIST should be a list of regexps matching headers to keep.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 DISCARD-REGEXP should be a regexp that matches headers to be discarded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 KEEP-LIST and DISCARD-REGEXP are used to order and trim the headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 to be forwarded. See the docs for vm-reorder-message-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 to find out how KEEP-LIST and DISCARD-REGEXP are used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (if message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (let ((target-buffer (current-buffer))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
252 (mime-keep-list (append keep-list vm-mime-header-list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (mlist message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 source-buffer m start n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; narrow to a zero length region to avoid interacting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; with anything that might have already been inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; into the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (while mlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (insert "---------------\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (setq m (vm-real-message-of (car mlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 source-buffer (vm-buffer-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (set-buffer source-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (set-buffer target-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (insert-buffer-substring source-buffer (vm-headers-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (vm-text-end-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (vm-reorder-message-headers nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 "\\(X-VM-\\|Status:\\)")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
277 (vm-reorder-message-headers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
278 nil (if (vm-mime-plain-message-p m)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
279 keep-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
280 mime-keep-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
281 discard-regexp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (vm-rfc934-char-stuff-region beg (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (insert "---------------")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (setq mlist (cdr mlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (delete-region (point) (progn (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (insert "------- end -------\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (delete-region (point) (progn (forward-line 1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (setq n (length message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (insert (format "------- start of %s%s(RFC 934 encapsulation) -------\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (if (cdr message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 "digest "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 "forwarded message ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (if (cdr message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (format "(%d messages) " n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (goto-char start)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defun vm-rfc1153-char-stuff-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "Quote RFC 1153 message separators between START and END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 START and END are buffer positions in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 Lines consisting only of 30 hyphens have the first hyphen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 converted to a space."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (setq end (vm-marker end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (while (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (re-search-forward "^------------------------------$" end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (replace-match " -----------------------------" t t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (set-marker end nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (defun vm-rfc1153-char-unstuff-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "Unquote lines in between START and END as per RFC 1153.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 START and END are buffer positions in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 Lines consisting only of a space following by 29 hyphens have the space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 converted to a hyphen."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (setq end (vm-marker end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (while (and (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (re-search-forward "^ -----------------------------$" end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (replace-match "------------------------------" t t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (set-marker end nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (defun vm-rfc1153-encapsulate-messages (message-list keep-list discard-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 "Encapsulate the messages in MESSAGE-LIST as per RFC 1153.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 The resulting digest is inserted at point in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 Point is not moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 MESSAGE-LIST should be a list of message structs (real or virtual).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 These are the messages that will be encapsulated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 KEEP-LIST should be a list of regexps matching headers to keep.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 DISCARD-REGEXP should be a regexp that matches headers to be discarded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 KEEP-LIST and DISCARD-REGEXP are used to order and trim the headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 to be forwarded. See the docs for vm-reorder-message-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 to find out how KEEP-LIST and DISCARD-REGEXP are used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (if message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (let ((target-buffer (current-buffer))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
340 (mime-keep-list (append keep-list vm-mime-header-list))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (mlist message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 source-buffer m start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;; narrow to a zero length region to avoid interacting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; with anything that might have already been inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; into the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (narrow-to-region (point) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (while mlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (insert "---------------\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (setq m (vm-real-message-of (car mlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 source-buffer (vm-buffer-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (set-buffer source-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (set-buffer target-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (insert-buffer-substring source-buffer (vm-headers-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (vm-text-end-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (vm-reorder-message-headers nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "\\(X-VM-\\|Status:\\)")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
365 (vm-reorder-message-headers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
366 nil (if (vm-mime-plain-message-p m)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
367 keep-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
368 mime-keep-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
369 discard-regexp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (vm-rfc1153-char-stuff-region beg (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (insert "\n---------------")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (setq mlist (cdr mlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (insert "---------------\n\nEnd of this Digest\n******************\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (delete-region (point) (progn (forward-line 1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (insert (format "This is an RFC 1153 digest.\n(%d message%s)\n----------------------------------------------------------------------\n" (length message-list) (if (cdr message-list) "s" "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (goto-char start)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defun vm-rfc1153-or-rfc934-burst-message (m rfc1153)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "Burst messages from the digest message M.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 M should be a message struct for a real message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 If RFC1153 is non-nil, assume the digest is of the form specified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 RFC 1153. Otherwise assume RFC 934 digests."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (let ((work-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (match t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (prev-sep nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (ident-header nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 after-prev-sep prologue-separator-regexp separator-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (folder-type vm-folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (if vm-digest-identifier-header-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (setq ident-header (vm-sprintf 'vm-digest-identifier-header-format m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (if rfc1153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (setq prologue-separator-regexp "^----------------------------------------------------------------------\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 separator-regexp "^------------------------------\n")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
396 (setq prologue-separator-regexp "\\(^-[^ ].*\n+\\)+"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
397 separator-regexp "\\(^-[^ ].*\n+\\)+"))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
398 (vm-save-restriction
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
399 (save-excursion
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (setq work-buffer (generate-new-buffer "*vm-work*"))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
404 (buffer-disable-undo work-buffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (set-buffer work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (insert-buffer-substring (vm-buffer-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (vm-text-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (vm-text-end-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (if (not (re-search-forward prologue-separator-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (throw 'done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;; think of this as a do-while loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (while match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (cond ((null prev-sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 ;; from (point-min) to end of match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;; is the digest prologue, devour it and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ;; carry on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (delete-region (point-min) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;; munge previous messages message separators
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (let ((md (match-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (vm-munge-message-separators
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 after-prev-sep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (match-beginning 0))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 108
diff changeset
427 (store-match-data md)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
428 ;; there should be at least one valid header at
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
429 ;; the beginning of an encapsulated message. If
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
430 ;; there isn't a valid header, then assume that
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
431 ;; the digest was packed improperly and that this
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
432 ;; isn't a real boundary.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
433 (if (not
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
434 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
435 (save-match-data
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
436 (skip-chars-forward "\n")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
437 (or (and (vm-match-header)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
438 (vm-digest-get-header-contents "From"))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
439 (not (re-search-forward separator-regexp
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
440 nil t))))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
441 (setq prev-sep (point)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
442 after-prev-sep (point))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
443 ;; if this isn't the first message, delete the
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
444 ;; digest separator goop and insert a trailing message
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
445 ;; separator of the proper type.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
446 (if prev-sep
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
447 (progn
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
448 ;; eat preceding newlines
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
449 (while (= (preceding-char) ?\n)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
450 (delete-char -1))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
451 ;; put one back
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
452 (insert ?\n)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
453 ;; delete the digest separator
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 108
diff changeset
454 (delete-region (match-beginning 0) (point))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
455 ;; insert a trailing message separator
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
456 (insert (vm-trailing-message-separator folder-type))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
457 (setq prev-sep (point))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
458 ;; insert the leading separator
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
459 (insert (vm-leading-message-separator folder-type))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
460 (setq after-prev-sep (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
461 ;; eat trailing newlines
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
462 (while (= (following-char) ?\n)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
463 (delete-char 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
464 (insert ident-header))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ;; try to match message separator and repeat.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (setq match (re-search-forward separator-regexp nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; from the last separator to eof is the digest epilogue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; discard it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (delete-region (or prev-sep (point-min)) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;; Undo the quoting of the embedded message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;; separators. This must be done before header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;; conversions, else the Content-Length offsets might be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;; rendered invalid by buffer size changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (if rfc1153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (vm-rfc1153-char-unstuff-region (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (vm-rfc934-char-unstuff-region (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;; do header conversions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (let ((vm-folder-type folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (while (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (vm-convert-folder-type-headers folder-type folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (vm-find-trailing-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (vm-skip-past-trailing-message-separator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; now insert the messages into the folder buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (cond ((not (zerop (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (set-buffer (vm-buffer-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (insert-buffer-substring work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (set-buffer-modified-p old-buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; return non-nil so caller knows we found some messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 t ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;; return nil so the caller knows we didn't find anything
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (and work-buffer (kill-buffer work-buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (defun vm-rfc934-burst-message (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 "Burst messages from the RFC 934 digest message M.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 M should be a message struct for a real message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (vm-rfc1153-or-rfc934-burst-message m nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (defun vm-rfc1153-burst-message (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 "Burst messages from the RFC 1153 digest message M.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 M should be a message struct for a real message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (vm-rfc1153-or-rfc934-burst-message m t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (defun vm-burst-digest (&optional digest-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 "Burst the current message (a digest) into its individual messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 The digest's messages are assimilated into the folder as new mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 would be.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 Optional argument DIGEST-TYPE is a string that tells VM what kind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 of digest the current message is. If it is not given the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 defaults to the value of vm-digest-burst-type. When called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 interactively DIGEST-TYPE will be read from the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 If invoked on marked messages (via vm-next-command-uses-marks),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 all marked messages will be burst."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (let ((type nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (this-command this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (last-command last-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (setq type (completing-read (format "Digest type: (default %s) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 vm-digest-burst-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (append vm-digest-type-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (list '("guess")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 'identity nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (if (string= type "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 vm-digest-burst-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 type ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (or digest-type (setq digest-type vm-digest-burst-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (vm-follow-summary-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (let ((start-buffer (current-buffer)) m totals-blurb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (mlist (vm-select-marked-or-prefixed-messages 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (while mlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (if (vm-virtual-message-p (car mlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (setq m (vm-real-message-of (car mlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (set-buffer (vm-buffer-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (setq m (car mlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (vm-error-if-folder-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (if (equal digest-type "guess")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (setq digest-type (vm-guess-digest-type m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (if (null digest-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (error "Couldn't guess digest type."))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
554 (message "Bursting %s digest..." digest-type)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (cond
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
556 ((cond ((equal digest-type "mime")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
557 (vm-mime-burst-message m))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
558 ((equal digest-type "rfc934")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (vm-rfc934-burst-message m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 ((equal digest-type "rfc1153")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (vm-rfc1153-burst-message m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (t (error "Unknown digest type: %s" digest-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (message "Bursting %s digest... done" digest-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (vm-clear-modification-flag-undos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (vm-set-buffer-modified-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (vm-increment vm-modification-counter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (and vm-delete-after-bursting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; if start folder was virtual, we're now in the wrong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;; buffer. switch back.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (set-buffer start-buffer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
572 ;; don't move message pointer when deleting the message
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
573 (let ((vm-move-after-deleting nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
574 (vm-delete-message 1))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
575 (vm-assimilate-new-messages t nil (vm-labels-of (car mlist)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ;; do this now so if we error later in another iteration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 ;; of the loop the summary and mode line will be correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (vm-update-summary-and-mode-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (setq mlist (cdr mlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; collect this data NOW, before the non-previewers read a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 ;; message, alter the new message count and confuse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;; themselves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (setq totals-blurb (vm-emit-totals-blurb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (vm-display nil nil '(vm-burst-digest
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
585 vm-burst-mime-digest
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 vm-burst-rfc934-digest
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
587 vm-burst-rfc1153-digest)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (list this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (if (vm-thoughtfully-select-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (vm-preview-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (message totals-blurb)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (defun vm-burst-rfc934-digest ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 "Burst an RFC 934 style digest"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (vm-burst-digest "rfc934"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (defun vm-burst-rfc1153-digest ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 "Burst an RFC 1153 style digest"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (vm-burst-digest "rfc1153"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
604 (defun vm-burst-mime-digest ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
605 "Burst a MIME digest"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
606 (interactive)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
607 (vm-burst-digest "mime"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
608
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (defun vm-guess-digest-type (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 "Guess the digest type of the message M.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 M should be the message struct of a real message.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
612 Returns either \"rfc934\", \"rfc1153\" or \"mime\"."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
613 (catch 'return-value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
614 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
615 (set-buffer (vm-buffer-of m))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
616 (let ((layout (vm-mm-layout m)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
617 (if (and (vectorp layout)
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
618 (or (vm-mime-layout-contains-type
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
619 layout
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
620 "multipart/digest")
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
621 (vm-mime-layout-contains-type
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
622 layout
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
623 "message/rfc822")
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
624 (vm-mime-layout-contains-type
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
625 layout
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
626 "message/news")))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
627 (throw 'return-value "mime"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (widen)
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
631 (goto-char (vm-text-of m))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
632 (cond ((search-forward "\n----------------------------------------------------------------------\n" (vm-text-end-of m) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
633 "rfc1153")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
634 (t "rfc934"))))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
635
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
636 (defun vm-digest-get-header-contents (header-name-regexp)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
637 (let ((contents nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
638 regexp)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
639 (setq regexp (concat "^\\(" header-name-regexp "\\)\\|\\(^$\\)"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
640 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
641 (let ((case-fold-search t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
642 (if (and (re-search-forward regexp nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
643 (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
644 (progn (goto-char (match-beginning 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
645 (vm-match-header)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
646 (vm-matched-header-contents)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
647 nil )))))