annotate lisp/vm/vm-digest.el @ 100:4be1180a9e89 r20-1b2

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