annotate lisp/vm/vm-digest.el @ 2:ac2d302a0011 r19-15b2

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