annotate lisp/vm/vm-folder.el @ 114:8619ce7e4c50 r20-1b9

Import from CVS: tag r20-1b9
author cvs
date Mon, 13 Aug 2007 09:21:54 +0200
parents 360340f9fd5f
children 9f59509498e1
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 ;;; VM folder related functions
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2 ;;; Copyright (C) 1989-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-folder)
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-number-messages (&optional start-point end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 "Set the number-of and padded-number-of slots of messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 in vm-message-list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 If non-nil, START-POINT should point to a cons cell in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 vm-message-list and the numbering will begin there, else the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 numbering will begin at the head of vm-message-list. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 START-POINT is non-nil the reverse-link-of slot of the message in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 the cons must be valid and the message pointed to (if any) must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 have a non-nil number-of slot, because it is used to determine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 what the starting message number should be.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 If non-nil, END-POINT should point to a cons cell in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 vm-message-list and the numbering will end with the message just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 before this cell. A nil value means numbering will be done until
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 the end of vm-message-list is reached."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (let ((n 1) (message-list (or start-point vm-message-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (if (and start-point (vm-reverse-link-of (car start-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (setq n (1+ (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (vm-number-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (vm-reverse-link-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (car start-point))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (while (not (eq message-list end-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (vm-set-number-of (car message-list) (int-to-string n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (vm-set-padded-number-of (car message-list) (format "%3d" n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (setq n (1+ n) message-list (cdr message-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (or end-point (setq vm-ml-highest-message-number (int-to-string (1- n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (if vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (vm-copy-local-variables vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 'vm-ml-highest-message-number))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defun vm-set-numbering-redo-start-point (start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "Set vm-numbering-redo-start-point to START-POINT if appropriate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 Also mark the current buffer as needing a display update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 START-POINT should be a cons in vm-message-list or just t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (t means start from the beginning of vm-message-list.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 If START-POINT is closer to the head of vm-message-list than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 vm-numbering-redo-start-point or is equal to t, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 vm-numbering-redo-start-point is set to match it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (intern (buffer-name) vm-buffers-needing-display-update)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
62 (if (eq vm-numbering-redo-start-point t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
63 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
64 (if (and (consp start-point) (consp vm-numbering-redo-start-point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
65 (let ((mp vm-message-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
66 (while (and mp (not (or (eq mp start-point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
67 (eq mp vm-numbering-redo-start-point))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
68 (setq mp (cdr mp)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
69 (if (null mp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
70 (error "Something is wrong in vm-set-numbering-redo-start-point"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
71 (if (eq mp start-point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
72 (setq vm-numbering-redo-start-point start-point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
73 (setq vm-numbering-redo-start-point start-point))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defun vm-set-numbering-redo-end-point (end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "Set vm-numbering-redo-end-point to END-POINT if appropriate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 Also mark the current buffer as needing a display update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 END-POINT should be a cons in vm-message-list or just t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (t means number all the way to the end of vm-message-list.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 If END-POINT is closer to the end of vm-message-list or is equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 to t, then vm-numbering-redo-start-point is set to match it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 The number-of slot is used to determine proximity to the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 vm-message-list, so this slot must be valid in END-POINT's message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 and the message in the cons pointed to by vm-numbering-redo-end-point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (cond ((eq end-point t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (setq vm-numbering-redo-end-point t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ((and (consp end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (> (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (vm-number-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (car end-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (vm-number-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (car vm-numbering-redo-end-point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (setq vm-numbering-redo-end-point end-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ((null end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (setq vm-numbering-redo-end-point end-point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defun vm-do-needed-renumbering ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 "Number messages in vm-message-list as specified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 vm-numbering-redo-start-point and vm-numbering-redo-end-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 vm-numbering-redo-start-point = t means start at the head
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 of vm-message-list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 vm-numbering-redo-end-point = t means number all the way to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 end of vm-message-list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 Otherwise the variables' values should be conses in vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 or nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (if vm-numbering-redo-start-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (vm-number-messages (and (consp vm-numbering-redo-start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 vm-numbering-redo-start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 vm-numbering-redo-end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (setq vm-numbering-redo-start-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 vm-numbering-redo-end-point nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defun vm-set-summary-redo-start-point (start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 "Set vm-summary-redo-start-point to START-POINT if appropriate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 Also mark the current buffer as needing a display update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 START-POINT should be a cons in vm-message-list or just t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (t means start from the beginning of vm-message-list.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 If START-POINT is closer to the head of vm-message-list than
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
126 vm-summary-redo-start-point or is equal to t, then
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
127 vm-summary-redo-start-point is set to match it."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (intern (buffer-name) vm-buffers-needing-display-update)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
129 (if (eq vm-summary-redo-start-point t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
130 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
131 (if (and (consp start-point) (consp vm-summary-redo-start-point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
132 (let ((mp vm-message-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
133 (while (and mp (not (or (eq mp start-point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
134 (eq mp vm-summary-redo-start-point))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
135 (setq mp (cdr mp)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
136 (if (null mp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
137 (error "Something is wrong in vm-set-summary-redo-start-point"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
138 (if (eq mp start-point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
139 (setq vm-summary-redo-start-point start-point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
140 (setq vm-summary-redo-start-point start-point))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (defun vm-mark-for-summary-update (m &optional dont-kill-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 "Mark message M for a summary update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 Also mark M's buffer as needing a display update. Any virtual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 messages of M and their buffers are similarly marked for update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 If M is a virtual message and virtual mirroring is in effect for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 M (i.e. attribute-of eq attributes-of M's real message), M's real
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 message and its buffer are scheduled for an update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 Optional arg DONT-KILL-CACHE non-nil means don't invalidate the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 summary-of slot for any messages marked for update. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 meant to be used by functions that update message information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 that is not cached in the summary-of slot, e.g. message numbers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 and thread indentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (cond ((eq m (vm-real-message-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; this is a real message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; its summary and modeline need to be updated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (if (not dont-kill-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; toss the cache. this also tosses the cache of any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; virtual messages mirroring this message. the summary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; entry cache must be cleared when an attribute of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; message that could appear in the summary has changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (vm-set-summary-of m nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (if (vm-su-start-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (setq vm-messages-needing-summary-update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (cons m vm-messages-needing-summary-update)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (intern (buffer-name (vm-buffer-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; find the virtual messages of this real message that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; need a summary update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (let ((m-list (vm-virtual-messages-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (while m-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (if (eq (vm-attributes-of m) (vm-attributes-of (car m-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (and (vm-su-start-of (car m-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (setq vm-messages-needing-summary-update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (cons (car m-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 vm-messages-needing-summary-update)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (intern (buffer-name (vm-buffer-of (car m-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 vm-buffers-needing-display-update)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (setq m-list (cdr m-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; this is a virtual message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; if this message has virtual messages then we need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; schedule updates for all the virtual messages that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; share a cache with this message and we need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; schedule an update for the underlying real message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; since we are mirroring it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; if there are no virtual messages, then this virtual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; message is not mirroring its real message so we need
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; only take care of this one message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (if (vm-virtual-messages-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (let ((m-list (vm-virtual-messages-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; schedule updates for all the virtual message who share
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; the same cache as this message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (while m-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (if (eq (vm-attributes-of m) (vm-attributes-of (car m-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (and (vm-su-start-of (car m-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (setq vm-messages-needing-summary-update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (cons (car m-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 vm-messages-needing-summary-update)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (intern (buffer-name (vm-buffer-of (car m-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 vm-buffers-needing-display-update)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (setq m-list (cdr m-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; now take care of the real message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (if (not dont-kill-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; toss the cache. this also tosses the cache of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; any virtual messages sharing the same cache as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;; this message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (vm-set-summary-of m nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (and (vm-su-start-of (vm-real-message-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (setq vm-messages-needing-summary-update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (cons (vm-real-message-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 vm-messages-needing-summary-update)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (intern (buffer-name (vm-buffer-of (vm-real-message-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 vm-buffers-needing-display-update))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (if (not dont-kill-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (vm-set-virtual-summary-of m nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (and (vm-su-start-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (setq vm-messages-needing-summary-update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (cons m vm-messages-needing-summary-update)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (intern (buffer-name (vm-buffer-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 vm-buffers-needing-display-update)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (defun vm-force-mode-line-update ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 "Force a mode line update in all frames."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (if (fboundp 'force-mode-line-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (force-mode-line-update t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (set-buffer (other-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (set-buffer-modified-p (buffer-modified-p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defun vm-do-needed-mode-line-update ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 "Do a modeline update for the current folder buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 This means setting up all the various vm-ml attribute variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 in the folder buffer and copying necessary variables to the
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
240 folder buffer's summary and presentation buffers, and then
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
241 forcing Emacs to update all modelines.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
243 If a virtual folder being updated has no messages, then
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
244 erase-buffer is called on its buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
245
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
246 If any type of folder is empty, erase-buffer is called
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
247 on its presentation buffer, if any."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;; XXX This last bit should probably should be moved to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;; XXX vm-expunge-folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (if (null vm-message-pointer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
252 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
253 ;; erase the leftover message if the folder is really empty.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
254 (if (eq major-mode 'vm-virtual-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
255 (let ((buffer-read-only nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
256 (omodified (buffer-modified-p)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
257 (unwind-protect
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
258 (erase-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
259 (set-buffer-modified-p omodified))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
260 (if vm-presentation-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
261 (let ((omodified (buffer-modified-p)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
262 (unwind-protect
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
263 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
264 (set-buffer vm-presentation-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
265 (let ((buffer-read-only nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
266 (erase-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
267 (set-buffer-modified-p omodified)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; try to avoid calling vm-su-labels if possible so as to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;; avoid loading vm-summary.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (if (vm-labels-of (car vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (setq vm-ml-labels (vm-su-labels (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (setq vm-ml-labels nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (setq vm-ml-message-number (vm-number-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq vm-ml-message-new (vm-new-flag (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (setq vm-ml-message-unread (vm-unread-flag (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (setq vm-ml-message-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (and (not (vm-new-flag (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (not (vm-unread-flag (car vm-message-pointer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (setq vm-ml-message-edited (vm-edited-flag (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (setq vm-ml-message-filed (vm-filed-flag (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (setq vm-ml-message-written (vm-written-flag (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (setq vm-ml-message-replied (vm-replied-flag (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (setq vm-ml-message-forwarded (vm-forwarded-flag (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq vm-ml-message-redistributed (vm-redistributed-flag (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (setq vm-ml-message-deleted (vm-deleted-flag (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (setq vm-ml-message-marked (vm-mark-of (car vm-message-pointer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (if vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (let ((modified (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (vm-copy-local-variables vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 'vm-ml-message-new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 'vm-ml-message-unread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 'vm-ml-message-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 'vm-ml-message-edited
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 'vm-ml-message-replied
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 'vm-ml-message-forwarded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 'vm-ml-message-filed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 'vm-ml-message-written
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 'vm-ml-message-deleted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 'vm-ml-message-marked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 'vm-ml-message-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 'vm-ml-highest-message-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 'vm-folder-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 'vm-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 'vm-virtual-folder-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 'vm-virtual-mirror
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 'vm-ml-sort-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 'vm-ml-labels
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
309 'vm-spooled-mail-waiting
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 'vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (set-buffer vm-summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (set-buffer-modified-p modified))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
313 (if vm-presentation-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
314 (let ((modified (buffer-modified-p)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
315 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
316 (vm-copy-local-variables vm-presentation-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
317 'vm-ml-message-new
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
318 'vm-ml-message-unread
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
319 'vm-ml-message-read
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
320 'vm-ml-message-edited
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
321 'vm-ml-message-replied
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
322 'vm-ml-message-forwarded
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
323 'vm-ml-message-filed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
324 'vm-ml-message-written
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
325 'vm-ml-message-deleted
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
326 'vm-ml-message-marked
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
327 'vm-ml-message-number
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
328 'vm-ml-highest-message-number
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
329 'vm-folder-read-only
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
330 'vm-folder-type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
331 'vm-virtual-folder-definition
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
332 'vm-virtual-mirror
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
333 'vm-ml-labels
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
334 'vm-spooled-mail-waiting
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
335 'vm-message-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
336 (set-buffer vm-presentation-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
337 (set-buffer-modified-p modified))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (vm-force-mode-line-update))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (defun vm-update-summary-and-mode-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 "Update summary and mode line for all VM folder and summary buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 Really this updates all the visible status indicators.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 Message lists are renumbered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 Summary entries are wiped and regenerated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 Mode lines are updated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 Toolbars are updated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (mapatoms (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (lambda (b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (setq b (get-buffer (symbol-name b)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (if b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (set-buffer b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (and vm-use-toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (vm-toolbar-support-possible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (vm-toolbar-update-toolbar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (vm-do-needed-renumbering)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (if vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (vm-do-needed-summary-rebuild))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (vm-do-needed-mode-line-update)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (fillarray vm-buffers-needing-display-update 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (if vm-messages-needing-summary-update
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (mapcar (function vm-update-message-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 vm-messages-needing-summary-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (setq vm-messages-needing-summary-update nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (vm-force-mode-line-update))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defun vm-reverse-link-messages ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 "Set reverse links for all messages in vm-message-list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (let ((mp vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (prev nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (vm-set-reverse-link-of (car mp) prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (setq prev mp mp (cdr mp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defun vm-match-ordered-header (alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "Try to match a header in ALIST and return the matching cell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 This is used by header ordering code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ALIST looks like this ((\"From\") (\"To\")). This function returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 the alist element whose car matches the header starting at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 The header ordering code uses the cdr of the element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 returned to hold headers to be output later."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (catch 'match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (if (looking-at (car (car alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (throw 'match (car alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (setq alist (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 nil)))
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-match-header (&optional header-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 "Match a header and save some state information about the matched header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 Optional first arg HEADER-NAME means match the header only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 if it matches HEADER-NAME. HEADER-NAME should be a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 containing a header name. The string should end with a colon if just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 that name should be matched. A string that does not end in a colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 will match all headers that begin with that string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 State information is stored in vm-matched-header-vector bound to a vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 of this form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 [ header-start header-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 header-name-start header-name-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 header-contents-start header-contents-end ]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 Elements are integers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 There are functions to access and use this info."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (header-name-regexp "\\([^ \t\n:]+\\):"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if (if header-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (and (looking-at header-name) (looking-at header-name-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (looking-at header-name-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (aset vm-matched-header-vector 0 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (aset vm-matched-header-vector 2 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (aset vm-matched-header-vector 3 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;; skip leading whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (aset vm-matched-header-vector 4 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (while (looking-at "[ \t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (aset vm-matched-header-vector 1 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;; drop the trailing newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (aset vm-matched-header-vector 5 (1- (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (defun vm-matched-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 "Returns the header last matched by vm-match-header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 Trailing newline is included."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (vm-buffer-substring-no-properties (aref vm-matched-header-vector 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (aref vm-matched-header-vector 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (defun vm-matched-header-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 "Returns the name of the header last matched by vm-match-header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (vm-buffer-substring-no-properties (aref vm-matched-header-vector 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (aref vm-matched-header-vector 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (defun vm-matched-header-contents ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 "Returns the contents of the header last matched by vm-match-header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 Trailing newline is not included."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (vm-buffer-substring-no-properties (aref vm-matched-header-vector 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (aref vm-matched-header-vector 5)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (defun vm-matched-header-start ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "Returns the start position of the header last matched by vm-match-header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (aref vm-matched-header-vector 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (defun vm-matched-header-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 "Returns the end position of the header last matched by vm-match-header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (aref vm-matched-header-vector 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (defun vm-matched-header-name-start ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 "Returns the start position of the name of the header last matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 by vm-match-header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (aref vm-matched-header-vector 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defun vm-matched-header-name-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 "Returns the end position of the name of the header last matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 by vm-match-header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (aref vm-matched-header-vector 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (defun vm-matched-header-contents-start ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 "Returns the start position of the contents of the header last matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 by vm-match-header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (aref vm-matched-header-vector 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (defun vm-matched-header-contents-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 "Returns the end position of the contents of the header last matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 by vm-match-header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (aref vm-matched-header-vector 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (defun vm-get-folder-type (&optional file start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 "Return a symbol indicating the folder type of the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 This function works by examining the beginning of a folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 If optional arg FILE is present the type of FILE is returned instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 If optional second and third arg START and END are provided,
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
483 vm-get-folder-type will examine the text between those buffer
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 positions. START and END default to 1 and (buffer-size) + 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 Returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 nil if folder has no type (empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 unknown if the type is not known to VM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 mmdf for MMDF folders
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 babyl for BABYL folders
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 From_ for UNIX From_ folders
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 If vm-trust-From_-with-Content-Length is non-nil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 From_-with-Content-Length is returned if the first message in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 folder has a Content-Length header and the folder otherwise looks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 like a From_ folder."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (let ((temp-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (setq b (vm-get-file-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (if b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (set-buffer b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (setq temp-buffer (generate-new-buffer "*vm-work*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (set-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (if (file-readable-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (condition-case nil
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
511 (let ((coding-system-for-read 'binary))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
512 (insert-file-contents file nil 0 4096))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (wrong-number-of-arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (call-process "sed" file temp-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 "-n" "1,/^$/p")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (or start (setq start 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (or end (setq end (1+ (buffer-size))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (cond ((zerop (buffer-size)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ((looking-at "\n*From ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (if (not vm-trust-From_-with-Content-Length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 'From_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (re-search-forward vm-content-length-search-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (cond ((match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 'From_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ((match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 'From_-with-Content-Length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (t 'From_))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 ((looking-at "\001\001\001\001\n") 'mmdf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ((looking-at "BABYL OPTIONS:") 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (t 'unknown)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (and temp-buffer (kill-buffer temp-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (defun vm-convert-folder-type (old-type new-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 "Convert buffer from OLD-TYPE to NEW-TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 OLD-TYPE and NEW-TYPE should be symbols returned from vm-get-folder-type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 This should be called on non-live buffers like crash boxes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 This will confuse VM if called on a folder buffer in vm-mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (let ((vm-folder-type old-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (pos-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (while (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (setq pos-list (cons (point-marker) pos-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (setq pos-list (cons (point-marker) pos-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (vm-find-trailing-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (setq pos-list (cons (point-marker) pos-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (vm-skip-past-trailing-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (setq pos-list (cons (point-marker) pos-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (setq pos-list (nreverse pos-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (vm-convert-folder-header old-type new-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (while pos-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (setq beg (car pos-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (goto-char (car pos-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (insert-before-markers (vm-leading-message-separator new-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (delete-region (car pos-list) (car (cdr pos-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (vm-convert-folder-type-headers old-type new-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (setq pos-list (cdr (cdr pos-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (setq end (marker-position (car pos-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (goto-char (car pos-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (insert-before-markers (vm-trailing-message-separator new-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (delete-region (car pos-list) (car (cdr pos-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (vm-munge-message-separators new-type beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (setq pos-list (cdr (cdr pos-list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (defun vm-convert-folder-header (old-type new-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 "Convert the folder header form OLD-TYPE to NEW-TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 The folder header is the text at the beginning of a folder that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 is a legal part of the folder but is not part of the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 message. This is for dealing with BABYL files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (if (eq old-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (let ((beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (cond ((and (looking-at "BABYL OPTIONS:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (search-forward "\037" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (delete-region beg (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (if (eq new-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;; insert before markers so that message location markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; for the first message get moved forward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (insert-before-markers "BABYL OPTIONS:\nVersion: 5\n\037")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (defun vm-skip-past-folder-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 "Move point past the folder header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 The folder header is the text at the beginning of a folder that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 is a legal part of the folder but is not part of the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 message. This is for dealing with BABYL files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (cond ((eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (search-forward "\037" nil 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (defun vm-convert-folder-type-headers (old-type new-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 "Convert headers in the message around point from OLD-TYPE to NEW-TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 This means to add/delete Content-Length and any other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 headers related to folder-type as needed for folder type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 conversions. This function expects point to be at the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 of the header section of a message, and it only deals with that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (let (length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 ;; get the length now before the content-length headers are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;; removed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (if (eq new-type 'From_-with-Content-Length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (let (start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (search-forward "\n\n" nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (setq start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (let ((vm-folder-type old-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (vm-find-trailing-message-separator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (setq length (- (point) start)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ;; chop out content-length header if new format doesn't need
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; it or if the new format computed his own copy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (if (or (eq old-type 'From_-with-Content-Length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (eq new-type 'From_-with-Content-Length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (while (and (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (re-search-forward vm-content-length-search-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (null (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (vm-match-header vm-content-length-header)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;; insert the content-length header if needed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (if (eq new-type 'From_-with-Content-Length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (insert vm-content-length-header " " (int-to-string length) "\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (defun vm-munge-message-separators (folder-type start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 "Munge message separators of FOLDER-TYPE found between START and END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 This function is used to eliminate message separators for a particular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 folder type that happen to occur in a message. \">\" is prepended to such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 separators."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (let ((vm-folder-type folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (cond ((memq folder-type '(From_ From_-with-Content-Length mmdf babyl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (setq end (vm-marker end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (while (and (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (< (point) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (insert ">"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (set-marker end nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (defun vm-compatible-folder-p (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 "Return non-nil if FILE is a compatible folder with the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 The current folder must have vm-folder-type initialized.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 FILE is compatible if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 - it is empty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 - the current folder is empty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 - the two folder types are equal"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (let ((type (vm-get-folder-type file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (or (not (and vm-folder-type type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (eq vm-folder-type type))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (defun vm-leading-message-separator (&optional folder-type message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 for-other-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 "Returns a leading message separator for the current folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 Defaults to returning a separator for the current folder type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 Optional first arg FOLDER-TYPE means return a separator for that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 folder type instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 Optional second arg MESSAGE should be a message struct. This is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 generating BABYL separators, because they contain message attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 and labels that must must be copied from the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 Optional third arg FOR-OTHER-FOLDER non-nil means that this separator will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 be used a `foreign' folder. This means that the `deleted'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 attributes should not be copied for BABYL folders."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (let ((type (or folder-type vm-folder-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (cond ((memq type '(From_ From_-with-Content-Length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (concat "From VM " (current-time-string) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 ((eq type 'mmdf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 "\001\001\001\001\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 ((eq type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (cond (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (concat "\014\n0,"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (vm-babyl-attributes-string message for-other-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ",\n*** EOOH ***\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (t "\014\n0, recent, unseen,,\n*** EOOH ***\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (defun vm-trailing-message-separator (&optional folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 "Returns a leading message separator for the current folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 Defaults to returning a separator for the current folder type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 Optional first arg FOLDER-TYPE means return a separator for that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 folder type instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (let ((type (or folder-type vm-folder-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (cond ((eq type 'From_) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ((eq type 'From_-with-Content-Length) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ((eq type 'mmdf) "\001\001\001\001\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ((eq type 'babyl) "\037"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (defun vm-folder-header (&optional folder-type label-obarray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 "Returns a folder header for the current folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 Defaults to returning a folder header for the current folder type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 Optional first arg FOLDER-TYPE means return a folder header for that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 folder type instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 Optional second arg LABEL-OBARRAY should be an obarray of labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 that have been used in this folder. This is used for BABYL folders."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (let ((type (or folder-type vm-folder-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (cond ((eq type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (let ((list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (if label-obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (mapatoms (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (lambda (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (setq list (cons sym list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 label-obarray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (if list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (format "BABYL OPTIONS:\nVersion: 5\nLabels: %s\n\037"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (mapconcat (function symbol-name) list ", "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 "BABYL OPTIONS:\nVersion: 5\n\037")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (t ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (defun vm-find-leading-message-separator ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 "Find the next leading message separator in a folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 Returns non-nil if the separator is found, nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 ((eq vm-folder-type 'From_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (let ((reg1 "^From ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (reg2 "^>From ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (while (re-search-forward reg1 nil 'no-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ;; remove the requirement that there be two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;; consecutive newlines (or the beginning of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ;; buffer) before "From ". Hopefully this will not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 ;; break more than it fixes. (18 August 1995)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (if ;; (and (or (< (point) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 ;; (equal (char-after (- (point) 2)) ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (and (= 0 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (or (vm-match-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (looking-at reg2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (throw 'done t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 nil )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ((eq vm-folder-type 'From_-with-Content-Length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (let ((reg1 "\\(^\\|\n+\\)From ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (if (re-search-forward reg1 nil 'no-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (progn (goto-char (match-end 1)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 nil )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ((eq vm-folder-type 'mmdf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (let ((reg1 "^\001\001\001\001")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (if (re-search-forward reg1 nil 'no-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 nil )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 ((eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (let ((reg1 "\014\n[01],")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (while (re-search-forward reg1 nil 'no-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (if (and (not (bobp)) (= (preceding-char) ?\037))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (throw 'done t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 nil )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (defun vm-find-trailing-message-separator ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 "Find the next trailing message separator in a folder."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 ((eq vm-folder-type 'From_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 ((eq vm-folder-type 'From_-with-Content-Length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (let ((reg1 "^From ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 content-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (start-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (if (and (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (re-search-forward vm-content-length-search-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (null (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (vm-match-header vm-content-length-header)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (setq content-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (string-to-int (vm-matched-header-contents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ;; if search fails, we'll be at point-max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 ;; if specified content-length is too long, go to point-max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (if (search-forward "\n\n" nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (if (>= (- (point-max) (point)) content-length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (forward-char content-length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (goto-char (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 ;; Some systems seem to add a trailing newline that's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 ;; not counted in the Content-Length header. Allow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 ;; any number of them to avoid trouble.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (skip-chars-forward "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (if (or (eobp) (looking-at reg1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (goto-char start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (if (re-search-forward reg1 nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (forward-char -5)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 ((eq vm-folder-type 'mmdf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (vm-find-leading-message-separator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 ((eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (defun vm-skip-past-leading-message-separator ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 "Move point past a leading message separator at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ((memq vm-folder-type '(From_ From_-with-Content-Length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (let ((reg1 "^>From ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (while (looking-at reg1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ((eq vm-folder-type 'mmdf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (forward-char 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;; skip >From. Either SCO's MMDF implementation leaves this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 ;; stuff in the message, or many sysadmins have screwed up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; their mail configuration. Either way I'm tired of getting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 ;; bug reports about it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (let ((reg1 "^>From ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (while (looking-at reg1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ((eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (search-forward "\n*** EOOH ***\n" nil 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (defun vm-skip-past-trailing-message-separator ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 "Move point past a trailing message separator at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ((eq vm-folder-type 'From_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 ((eq vm-folder-type 'From_-with-Content-Length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 ((eq vm-folder-type 'mmdf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (forward-char 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ((eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (forward-char 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (defun vm-build-message-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 "Build a chain of message structures, stored them in vm-message-list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 Finds the start and end of each message and fills in the relevant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 fields in the message structures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 Also finds the beginning of the header section and the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 text section and fills in these fields in the message structures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 vm-text-of and vm-vheaders-of field don't get filled until they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 are needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 If vm-message-list already contained messages, the end of the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 known message is found and then the parsing of new messages begins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 there and the message are appended to vm-message-list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 vm-folder-type is initialized here."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (setq vm-folder-type (vm-get-folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (let ((tail-cons nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 ;; Just for yucks, make the update interval vary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (modulus (+ (% (vm-abs (random)) 11) 25))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 message last-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (if vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 ;; there are already messages, therefore we're supposed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 ;; to add to this list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (let ((mp vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (end (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ;; first we have to find physical end of the folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ;; prior to the new messages that just came in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (if (< end (vm-end-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (setq end (vm-end-of (car mp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (if (not (consp (cdr mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (setq tail-cons mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (setq mp (cdr mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (goto-char end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 ;; there are no messages so we're building the whole list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 ;; start from the beginning of the folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ;; whine about newlines at the beginning of the folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ;; technically I think this is corruption, but there are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 ;; too many busted mail-do-fcc's installed out there to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 ;; do more than whine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (if (and (memq vm-folder-type '(From_ From_-with-Content-Length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (= (following-char) ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (message "Warning: newline found at beginning of folder, %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (or buffer-file-name (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (sleep-for 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (vm-skip-past-folder-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (setq last-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 ;; parse the messages, set the markers that specify where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 ;; things are.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (while (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (setq message (vm-make-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (vm-set-message-type-of message vm-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (vm-set-start-of message (vm-marker (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (vm-set-headers-of message (vm-marker (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (vm-find-trailing-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (vm-set-text-end-of message (vm-marker (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (vm-skip-past-trailing-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (setq last-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (vm-set-end-of message (vm-marker (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (vm-set-reverse-link-of message tail-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (if (null tail-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (setq vm-message-list (list message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 tail-cons vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (setcdr tail-cons (list message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (setq tail-cons (cdr tail-cons)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (vm-increment n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (if (zerop (% n modulus))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
922 (message "Parsing messages... %d" n)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (if (>= n modulus)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
924 (message "Parsing messages... done"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (if (and (not (= last-end (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (not (eq vm-folder-type 'unknown)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (message "Warning: garbage found at end of folder, %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (or buffer-file-name (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (sleep-for 2))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (defun vm-build-header-order-alist (vheaders)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (let ((order-alist (cons nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (setq list order-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (while vheaders
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (setcdr list (cons (cons (car vheaders) nil) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (setq list (cdr list) vheaders (cdr vheaders)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (cdr order-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ;; Reorder the headers in a message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 ;; If a message struct is passed into this function, then we're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 ;; operating on a message in a folder buffer. Headers are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 ;; grouped so that the headers that the user wants to see are at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ;; the end of the headers section so we can narrow to them. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 ;; is done according to the preferences specified in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 ;; vm-visible-header and vm-invisible-header-regexp. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ;; vheaders field of the message struct is also set. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 ;; function is called on demand whenever a vheaders field is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 ;; discovered to be nil for a particular message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 ;; If the message argument is nil, then we are operating on a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 ;; freestanding message that is not part of a folder buffer. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 ;; keep-list and discard-regexp parameters are used in this case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ;; Headers not matched by the keep list or matched by the discard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 ;; list are stripped from the message. The remaining headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 ;; are ordered according to the order of the keep list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (defun vm-reorder-message-headers (message keep-list discard-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (if message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (set-buffer (vm-buffer-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (setq keep-list vm-visible-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 discard-regexp vm-invisible-header-regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ;; if there is a cached regexp that points to the already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 ;; ordered headers then use it and avoid a lot of work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (if (and message (vm-vheaders-regexp-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (goto-char (vm-headers-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (re-search-forward (vm-vheaders-regexp-of message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (vm-text-of message) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (vm-set-vheaders-of message (vm-marker (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 ;; oh well, we gotta do it the hard way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 ;; header-alist will contain an assoc list version of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ;; keep-list. For messages associated with a folder
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
983 ;; buffer: when a matching header is found, the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
984 ;; header's start and end positions are added to its
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
985 ;; corresponding assoc cell. The positions of unwanted
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
986 ;; headers are remember also so that they can be copied
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
987 ;; to the top of the message, to be out of sight after
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
988 ;; narrowing. Once the positions have all been
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
989 ;; recorded a new copy of the headers is inserted in
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
990 ;; the proper order and the old headers are deleted.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 ;;
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
992 ;; For free standing messages, unwanted headers are
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
993 ;; stripped from the message, unremembered.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (let ((header-alist (vm-build-header-order-alist keep-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (work-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (extras nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 list end-of-header vheader-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (folder-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ;; locking can speed things noticeably if the lock directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 ;; is on a slow device. We don't need locking here because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 ;; in a mail context reordering headers is harmless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (case-fold-search t)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1007 (unwanted-list nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1008 unwanted-tail
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1009 new-header-start
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1010 old-header-start
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (old-buffer-modified-p (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (if message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 ;; for babyl folders, keep an untouched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ;; copy of the headers between the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 ;; attributes line and the *** EOOH ***
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ;; line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (if (and (eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (null (vm-babyl-frob-flag-of message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (goto-char (vm-start-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (forward-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (vm-set-babyl-frob-flag-of message t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (insert-buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (vm-headers-of message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (1- (vm-text-of message)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (setq work-buffer (generate-new-buffer "*vm-work*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (set-buffer work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (insert-buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 folder-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (vm-headers-of message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (vm-text-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (goto-char (point-min))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1037 (setq old-header-start (point))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
1038 ;; as we loop through the headers, skip >From
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
1039 ;; lines. these can occur anywhere in the
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
1040 ;; header section if the message has been
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
1041 ;; manhandled by some dumb delivery agents
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
1042 ;; (SCO and Solaris are the usual suspects.)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
1043 ;; it's a tough ol' world.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
1044 (while (progn (while (looking-at ">From ")
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
1045 (forward-line))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
1046 (and (not (= (following-char) ?\n))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
1047 (vm-match-header)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (setq end-of-header (vm-matched-header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 list (vm-match-ordered-header header-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 ;; don't display/keep this header if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 ;; keep-list not matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 ;; and discard-regexp is nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 ;; or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 ;; discard-regexp is matched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (if (or (and (null list) (null discard-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (and discard-regexp (looking-at discard-regexp)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1057 ;; delete the unwanted header if not doing
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 ;; work for a folder buffer, otherwise
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1059 ;; remember the start and end of the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1060 ;; unwanted header so we can copy it
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1061 ;; later.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1062 (if (not message)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1063 (delete-region (point) end-of-header)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1064 (if (null unwanted-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1065 (setq unwanted-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1066 (cons (point) (cons end-of-header nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1067 unwanted-tail unwanted-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1068 (if (= (point) (car (cdr unwanted-tail)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1069 (setcar (cdr unwanted-tail)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1070 end-of-header)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1071 (setcdr (cdr unwanted-tail)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1072 (cons (point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1073 (cons end-of-header nil)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1074 (setq unwanted-tail (cdr (cdr unwanted-tail)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1075 (goto-char end-of-header))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 ;; got a match
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1077 ;; stuff the start and end of the header
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1078 ;; into the cdr of the returned alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1079 ;; element.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (if list
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1081 ;; reverse point and end-of-header.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1082 ;; list will be nreversed later.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1083 (setcdr list (cons end-of-header
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1084 (cons (point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1085 (cdr list))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1086 ;; reverse point and end-of-header.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1087 ;; list will be nreversed later.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (setq extras
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1089 (cons end-of-header
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1090 (cons (point) extras))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1091 (goto-char end-of-header)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1092 (setq new-header-start (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1093 (while unwanted-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1094 (insert-buffer-substring (current-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1095 (car unwanted-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1096 (car (cdr unwanted-list)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1097 (setq unwanted-list (cdr (cdr unwanted-list))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;; remember the offset of where the visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;; header start so we can initialize the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 ;; vm-vheaders-of field later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (if message
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1102 (setq vheader-offset (- (point) new-header-start)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1103 (while header-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1104 (setq list (nreverse (cdr (car header-alist))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1105 (while list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1106 (insert-buffer-substring (current-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1107 (car list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1108 (car (cdr list)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1109 (setq list (cdr (cdr list))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1110 (setq header-alist (cdr header-alist)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 ;; now the headers that were not explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 ;; undesirable, if any.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1113 (setq extras (nreverse extras))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1114 (while extras
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1115 (insert-buffer-substring (current-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1116 (car extras)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1117 (car (cdr extras)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1118 (setq extras (cdr (cdr extras))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1119 (delete-region old-header-start new-header-start)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 ;; update the folder buffer if we're supposed to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 ;; lock out interrupts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (if message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (set-buffer (vm-buffer-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (goto-char (vm-headers-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (insert-buffer-substring work-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (delete-region (point) (vm-text-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (set-buffer-modified-p old-buffer-modified-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (and work-buffer (kill-buffer work-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (if message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (vm-set-vheaders-of message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (vm-marker (+ (vm-headers-of message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 vheader-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 ;; cache a regular expression that can be used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 ;; find the start of the reordered header the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 ;; time this folder is visited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (goto-char (vm-vheaders-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (if (vm-match-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (vm-set-vheaders-regexp-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (concat "^" (vm-matched-header-name) ":"))))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 ;; Reads the message attributes and cached header information from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 ;; header portion of the each message, if our X-VM- attributes header is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 ;; present. If the header is not present, assume the message is new,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 ;; unless we are being compatible with Berkeley Mail in which case we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 ;; also check for a Status header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 ;; If a message already has attributes don't bother checking the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 ;; headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 ;; This function also discovers and stores the position where the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 ;; message text begins.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 ;; Totals are gathered for use by vm-emit-totals-blurb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 ;; Supports version 4 format of attribute storage, for backward compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (defun vm-read-attributes (message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (let ((mp (or message-list vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (vm-new-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (vm-unread-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (vm-deleted-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (vm-total-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (modulus (+ (% (vm-abs (random)) 11) 25))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (case-fold-search t)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1169 data)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (vm-increment vm-total-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (if (vm-attributes-of (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (goto-char (vm-headers-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ;; find start of text section and save it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (search-forward "\n\n" (vm-text-end-of (car mp)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (vm-set-text-of (car mp) (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ;; now look for our header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (goto-char (vm-headers-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 ((re-search-forward vm-attributes-header-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (vm-text-of (car mp)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (goto-char (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (condition-case ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1185 (setq data (read (current-buffer)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1186 (error (setq data
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1187 (list
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1188 (make-vector vm-attributes-vector-length nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1189 (make-vector vm-cache-vector-length nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1190 nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1191 ;; In lieu of a valid attributes header
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1192 ;; assume the message is new. avoid
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1193 ;; vm-set-new-flag because it asks for a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1194 ;; summary update.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1195 (vm-set-new-flag-in-vector (car data) t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 ;; support version 4 format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (cond ((vectorp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (setq data (vm-convert-v4-attributes data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 ;; tink the message modflag so that if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;; user saves we get rid of the old v4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 ;; attributes header. otherwise we could be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 ;; dealing with these things for all eternity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (vm-set-modflag-of (car mp) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 ;; extend vectors if necessary to accomodate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 ;; more caching and attributes without alienating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 ;; other version 5 folders.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (cond ((< (length (car data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 vm-attributes-vector-length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 ;; tink the message modflag so that if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 ;; the user saves we get rid of the old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 ;; short vector. otherwise we could be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 ;; dealing with these things for all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 ;; eternity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (vm-set-modflag-of (car mp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (setcar data (vm-extend-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (car data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 vm-attributes-vector-length))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (cond ((< (length (car (cdr data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 vm-cache-vector-length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 ;; tink the message modflag so that if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 ;; the user saves we get rid of the old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 ;; short vector. otherwise we could be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 ;; dealing with these things for all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 ;; eternity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (vm-set-modflag-of (car mp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (setcar (cdr data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (vm-extend-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (car (cdr data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 vm-cache-vector-length))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (vm-set-labels-of (car mp) (nth 2 data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (vm-set-cache-of (car mp) (car (cdr data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (vm-set-attributes-of (car mp) (car data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 ((and vm-berkeley-mail-compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (re-search-forward vm-berkeley-mail-status-header-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (vm-text-of (car mp)) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (vm-set-cache-of (car mp) (make-vector vm-cache-vector-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (vm-set-attributes-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (car mp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (make-vector vm-attributes-vector-length nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (vm-set-unread-flag (car mp) (not (looking-at ".*R.*")) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (vm-set-cache-of (car mp) (make-vector vm-cache-vector-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (vm-set-attributes-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (car mp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (make-vector vm-attributes-vector-length nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 ;; In lieu of a valid attributes header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 ;; assume the message is new. avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 ;; vm-set-new-flag because it asks for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 ;; summary update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (vm-set-new-flag-of (car mp) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 ;; let babyl attributes override the normal VM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 ;; attributes header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (cond ((eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (vm-read-babyl-attributes (car mp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (cond ((vm-deleted-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (vm-increment vm-deleted-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 ((vm-new-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (vm-increment vm-new-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 ((vm-unread-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (vm-increment vm-unread-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (if (zerop (% vm-total-count modulus))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
1266 (message "Reading attributes... %d" vm-total-count))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (setq mp (cdr mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (if (>= vm-total-count modulus)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
1269 (message "Reading attributes... done"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (if (null message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (setq vm-totals (list vm-modification-counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 vm-total-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 vm-new-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 vm-unread-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 vm-deleted-count))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (defun vm-read-babyl-attributes (message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (labels nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (vect (make-vector vm-attributes-vector-length nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (vm-set-attributes-of message vect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (goto-char (vm-start-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 ;; skip past ^L\n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (vm-set-babyl-frob-flag-of message (if (= (following-char) ?1) t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 ;; skip past 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 ;; loop, noting attributes as we go.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (while (and (not (eobp)) (not (looking-at ",")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (cond ((looking-at " unseen,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (vm-set-unread-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 ((looking-at " recent,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (vm-set-new-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 ((looking-at " deleted,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (vm-set-deleted-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 ((looking-at " answered,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (vm-set-replied-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 ((looking-at " forwarded,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (vm-set-forwarded-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 ((looking-at " filed,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (vm-set-filed-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 ((looking-at " redistributed,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (vm-set-redistributed-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 ;; only VM knows about these, as far as I know.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 ((looking-at " edited,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (vm-set-forwarded-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 ((looking-at " written,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (vm-set-forwarded-flag-of message t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (skip-chars-forward "^,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (and (not (eobp)) (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (and (not (eobp)) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (while (looking-at " \\([^\000-\040,\177-\377]+\\),")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (setq labels (cons (vm-buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 labels))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (goto-char (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (vm-set-labels-of message labels))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (defun vm-set-default-attributes (message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (let ((mp (or message-list vm-message-list)) attr cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (setq attr (make-vector vm-attributes-vector-length nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 cache (make-vector vm-cache-vector-length nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (vm-set-cache-of (car mp) cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (vm-set-attributes-of (car mp) attr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 ;; make message be new by default, but avoid vm-set-new-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 ;; because it asks for a summary update for the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (vm-set-new-flag-of (car mp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 ;; since this function is usually called in lieu of reading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 ;; attributes from the buffer, the attributes may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 ;; untrustworthy. tink the message modflag to force the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 ;; new attributes out if the user saves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (vm-set-modflag-of (car mp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (setq mp (cdr mp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (defun vm-emit-totals-blurb ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (if (not (equal (nth 0 vm-totals) vm-modification-counter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (let ((mp vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (vm-new-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (vm-unread-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (vm-deleted-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (vm-total-count 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (vm-increment vm-total-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (cond ((vm-deleted-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (vm-increment vm-deleted-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 ((vm-new-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (vm-increment vm-new-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 ((vm-unread-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (vm-increment vm-unread-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (setq mp (cdr mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (setq vm-totals (list vm-modification-counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 vm-total-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 vm-new-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 vm-unread-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 vm-deleted-count))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (if (equal (nth 1 vm-totals) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (message "No messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (message "%d message%s, %d new, %d unread, %d deleted"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (nth 1 vm-totals) (if (= (nth 1 vm-totals) 1) "" "s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (nth 2 vm-totals)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (nth 3 vm-totals)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (nth 4 vm-totals)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (defun vm-convert-v4-attributes (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (list (apply 'vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (nconc (vm-vector-to-list data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (make-list (- vm-attributes-vector-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (length data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (make-vector vm-cache-vector-length nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (defun vm-gobble-labels ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (if (eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (if (re-search-forward "^Labels:" lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (let (string list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (setq string (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (progn (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 list (vm-parse string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 "[\000-\040,\177-\377]*\\([^\000-\040,\177-\377]+\\)[\000-\040,\177-\377]*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (intern (downcase s) vm-label-obarray)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (if (re-search-forward vm-labels-header-regexp lim t)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1409 (let (list)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1410 (setq list (read (current-buffer)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (intern s vm-label-obarray)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 t ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 ;; Go to the message specified in a bookmark and eat the bookmark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 ;; Returns non-nil if successful, nil otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (defun vm-gobble-bookmark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (let ((case-fold-search t)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1421 n lim)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (if (re-search-forward vm-bookmark-header-regexp lim t)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1434 (setq n (read (current-buffer))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (if n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (vm-record-and-change-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (nthcdr (1- n) vm-message-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 t ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (defun vm-gobble-visible-header-variables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (if (re-search-forward vm-vheader-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (let (vis invis (got nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (setq vis (read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 invis (read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 got t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 ;; if the variables don't match the values stored when this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 ;; folder was saved, then we have to discard any cached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 ;; vheader info so the user will see the right headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (and got (or (not (equal vis vm-visible-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (not (equal invis vm-invisible-header-regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (let ((mp vm-message-list))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
1468 (message "Discarding visible header info...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (vm-set-vheaders-regexp-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (vm-set-vheaders-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (setq mp (cdr mp)))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 ;; Read and delete the header that gives the folder's desired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 ;; message order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (defun vm-gobble-message-order ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 lim v order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (mp vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 list-length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (if (re-search-forward vm-message-order-header-regexp lim t)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1493 (progn
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
1494 (message "Reordering messages...")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1495 (setq order (read (current-buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1496 list-length (length vm-message-list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 v (make-vector (max list-length (length order)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (while (and order mp)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1499 (aset v (1- (car order)) (car mp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (setq order (cdr order) mp (cdr mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 ;; lock out interrupts while the message list is in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 ;; an inconsistent state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (setq vm-message-list (delq nil (append v mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 vm-message-order-changed nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 vm-message-order-header-present t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 vm-message-pointer (memq (car vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (vm-set-numbering-redo-start-point t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (vm-reverse-link-messages))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
1511 (message "Reordering messages... done")))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ;; Read the header that gives the folder's cached summary format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 ;; If the current summary format is different, then the cached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 ;; summary lines are discarded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (defun vm-gobble-summary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 summary lim
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (mp vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (if (re-search-forward vm-summary-header-regexp lim t)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1532 (progn
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
1533 (setq summary (read (current-buffer)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 (if (not (equal summary vm-summary-format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (vm-set-summary-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 ;; force restuffing of cache to clear old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 ;; summary entry cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (vm-set-modflag-of (car mp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (setq mp (cdr mp))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 ;; Stuff the message attributes back into the message as headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (defun vm-stuff-attributes (m &optional for-other-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 attributes cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 opoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (delflag (vm-deleted-flag m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 ;; don't put this folder's summary entry into another folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (if for-other-folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (vm-set-summary-of m nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (if (vm-su-start-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 ;; fill the summary cache if it's not done already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (vm-su-summary m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (setq attributes (vm-attributes-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 cache (vm-cache-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (and delflag for-other-folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (vm-set-deleted-flag-in-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (setq attributes (copy-sequence attributes)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (if (eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (vm-stuff-babyl-attributes m for-other-folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (goto-char (vm-headers-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (while (re-search-forward vm-attributes-header-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (vm-text-of m) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (delete-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (goto-char (vm-headers-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (setq opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (insert-before-markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 vm-attributes-header " ("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 (let ((print-escape-newlines t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (prin1-to-string attributes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 "\n\t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (let ((print-escape-newlines t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (prin1-to-string cache))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 "\n\t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (let ((print-escape-newlines t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (prin1-to-string (vm-labels-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 ")\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (set-marker (vm-headers-of m) opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (cond ((and (eq vm-folder-type 'From_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 vm-berkeley-mail-compatibility)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (goto-char (vm-headers-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 vm-berkeley-mail-status-header-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (vm-text-of m) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (delete-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (goto-char (vm-headers-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (cond ((not (vm-new-flag m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (insert-before-markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 vm-berkeley-mail-status-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (if (vm-unread-flag m) "" "R")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 "O\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (set-marker (vm-headers-of m) opoint)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (vm-set-modflag-of m nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1609 (defun vm-stuff-folder-attributes (&optional abort-if-input-pending)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1610 (let ((newlist nil) mp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1611 ;; stuff the attributes of messages that need it.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1612 ;; build a list of messages that need their attributes stuffed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1613 (setq mp vm-message-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1614 (while mp
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1615 (if (vm-modflag-of (car mp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1616 (setq newlist (cons (car mp) newlist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1617 (setq mp (cdr mp)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1618 ;; now sort the list by physical order so that we
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1619 ;; reduce the amount of gap motion induced by modifying
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1620 ;; the buffer. what we want to avoid is updating
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1621 ;; message 3, then 234, then 10, then 500, thus causing
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1622 ;; large chunks of memory to be copied repeatedly as
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1623 ;; the gap moves to accomodate the insertions.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1624 (let ((vm-key-functions '(vm-sort-compare-physical-order-r)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1625 (setq mp (sort newlist 'vm-sort-compare-xxxxxx)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1626 (while (and mp (or (not abort-if-input-pending) (not (input-pending-p))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1627 (vm-stuff-attributes (car mp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1628 (setq mp (cdr mp)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1629 (if mp nil t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1630
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 ;; we can be a bit lazy in this function since it's only called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 ;; from within vm-stuff-attributes. we don't worry about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 ;; restoring the modified flag, setting buffer-read-only, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ;; about not moving point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (defun vm-stuff-babyl-attributes (m for-other-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (goto-char (vm-start-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (if (vm-babyl-frob-flag-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (insert "1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (insert "0"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (if (looking-at "\\( [^\000-\040,\177-\377]+,\\)+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (delete-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (if (vm-new-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (insert " recent, unseen,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (if (vm-unread-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (insert " unseen,")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (if (and (not for-other-folder) (vm-deleted-flag m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (insert " deleted,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (if (vm-replied-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (insert " answered,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (if (vm-forwarded-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (insert " forwarded,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (if (vm-redistributed-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (insert " redistributed,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (if (vm-filed-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (insert " filed,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (if (vm-edited-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (insert " edited,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (if (vm-written-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (insert " written,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (if (looking-at "\\( [^\000-\040,\177-\377]+,\\)+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (delete-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (mapcar (function (lambda (label) (insert " " label ",")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (vm-labels-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (defun vm-babyl-attributes-string (m for-other-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (if (vm-new-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 " recent, unseen,"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (if (vm-unread-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 " unseen,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (if (and (not for-other-folder) (vm-deleted-flag m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 " deleted,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 (if (vm-replied-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 " answered,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (if (vm-forwarded-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 " forwarded,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (if (vm-redistributed-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 " redistributed,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (if (vm-filed-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 " filed,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (if (vm-edited-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 " edited,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (if (vm-written-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 " written,")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (defun vm-babyl-labels-string (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (let ((list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (labels (vm-labels-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (while labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (setq list (cons "," (cons (car labels) (cons " " list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 labels (cdr labels)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (apply 'concat (nreverse list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (defun vm-stuff-virtual-attributes (message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (let ((virtual (vm-virtual-message-p message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (if (or (not virtual) (and virtual (vm-virtual-messages-of message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (vm-buffer-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (vm-real-message-of message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (vm-stuff-attributes (vm-real-message-of message))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (defun vm-stuff-labels ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (if (eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (delete-region (point) (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (insert-before-markers (vm-folder-header vm-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 vm-label-obarray))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (while (re-search-forward vm-labels-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (if (vm-match-header vm-labels-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 ;; To insert or to insert-before-markers, that is the question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 ;; If we insert-before-markers we push a header behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ;; vm-headers-of, which is clearly undesirable. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 ;; just insert. This will cause the summary header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 ;; to be visible if there are no non-visible headers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 ;; oh well, no way around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (insert vm-labels-header " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (let ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (mapatoms (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (lambda (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (setq list (cons (symbol-name sym) list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 vm-label-obarray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (prin1-to-string list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 ;; Insert a bookmark into the first message in the folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (defun vm-stuff-bookmark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (if (re-search-forward vm-bookmark-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (if (vm-match-header vm-bookmark-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 ;; To insert or to insert-before-markers, that is the question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 ;; If we insert-before-markers we push a header behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 ;; vm-headers-of, which is clearly undesirable. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 ;; just insert. This will cause the bookmark header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 ;; to be visible if there are no non-visible headers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ;; oh well, no way around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (insert vm-bookmark-header " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 (vm-number-of (car vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 ;; Insert the summary format variable header into the first message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (defun vm-stuff-summary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (while (re-search-forward vm-summary-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (if (vm-match-header vm-summary-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 ;; To insert or to insert-before-markers, that is the question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 ;; If we insert-before-markers we push a header behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 ;; vm-headers-of, which is clearly undesirable. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 ;; just insert. This will cause the summary header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 ;; to be visible if there are no non-visible headers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 ;; oh well, no way around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 (insert vm-summary-header " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (let ((print-escape-newlines t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (prin1-to-string vm-summary-format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 ;; stuff the current values of the header variables for future messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (defun vm-stuff-header-variables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 lim
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (buffer-file-name nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (while (re-search-forward vm-vheader-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (if (vm-match-header vm-vheader-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 ;; To insert or to insert-before-markers, that is the question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 ;; If we insert-before-markers we push a header behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 ;; vm-headers-of, which is clearly undesirable. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 ;; just insert. This header will be visible if there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 ;; are no non-visible headers, oh well, no way around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (insert vm-vheader-header " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (prin1-to-string vm-visible-headers) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (prin1-to-string vm-invisible-header-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 ;; Insert a header into the first message of the folder that lists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 ;; the folder's message order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (defun vm-stuff-message-order ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (if (cdr vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 lim n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (mp (copy-sequence vm-message-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 (setq mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (sort mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (lambda (p q)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (< (vm-start-of p) (vm-start-of q))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (while (re-search-forward vm-message-order-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (if (vm-match-header vm-message-order-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 ;; To insert or to insert-before-markers, that is the question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 ;; If we insert-before-markers we push a header behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 ;; vm-headers-of, which is clearly undesirable. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 ;; just insert. This header will be visible if there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 ;; are no non-visible headers, oh well, no way around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (insert vm-message-order-header "\n\t(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (setq n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (insert (vm-number-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (setq n (1+ n) mp (cdr mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (and mp (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (if (zerop (% n 15))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 "\n\t "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 " "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 (insert ")\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 (setq vm-message-order-changed nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 vm-message-order-header-present t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 ;; Remove the message order header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (defun vm-remove-message-order ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (if (cdr vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 lim
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (while (re-search-forward vm-message-order-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (if (vm-match-header vm-message-order-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (setq vm-message-order-header-present nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 (defun vm-change-all-new-to-unread ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (let ((mp vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (if (vm-new-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (vm-set-new-flag (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (vm-set-unread-flag (car mp) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (setq mp (cdr mp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 (defun vm-unread-message (&optional count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 "Set the `unread' attribute for the current message. If the message is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 already new or unread, then it is left unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 Numeric prefix argument N means to unread the current message plus the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 next N-1 messages. A negative N means unread the current message and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 the previous N-1 messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 When invoked on marked messages (via vm-next-command-uses-marks),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 all marked messages are affected, other messages are ignored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (or count (setq count 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (vm-follow-summary-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (let ((mlist (vm-select-marked-or-prefixed-messages count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (while mlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 (if (and (not (vm-unread-flag (car mlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (not (vm-new-flag (car mlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (vm-set-unread-flag (car mlist) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (setq mlist (cdr mlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (vm-display nil nil '(vm-unread-message) '(vm-unread-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (defun vm-quit-just-bury ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 "Bury the current VM folder and summary buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 The folder is not altered and Emacs is still visiting it. You
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 can switch back to it with switch-to-buffer or by using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 Buffer Menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (if (not (memq major-mode '(vm-mode vm-virtual-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 (error "%s must be invoked from a VM buffer." this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 (vm-check-for-killed-summary)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2027 (vm-check-for-killed-presentation)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2029 (save-excursion (run-hooks 'vm-quit-hook))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2030
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2031 (vm-garbage-collect-message)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (vm-display nil nil '(vm-quit-just-bury)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 '(vm-quit-just-bury quitting))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (if vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 (vm-display vm-summary-buffer nil nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 (if vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 (vm-bury-buffer vm-summary-buffer))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2039 (if vm-presentation-buffer-handle
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2040 (vm-display vm-presentation-buffer-handle nil nil nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2041 (if vm-presentation-buffer-handle
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2042 (vm-bury-buffer vm-presentation-buffer-handle))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (vm-display (current-buffer) nil nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 (vm-bury-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 (defun vm-quit-just-iconify ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 "Iconify the frame and bury the current VM folder and summary buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 The folder is not altered and Emacs is still visiting it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 (if (not (memq major-mode '(vm-mode vm-virtual-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (error "%s must be invoked from a VM buffer." this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (vm-check-for-killed-summary)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2054 (vm-check-for-killed-presentation)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2056 (save-excursion (run-hooks 'vm-quit-hook))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2057
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2058 (vm-garbage-collect-message)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 (vm-display nil nil '(vm-quit-just-iconify)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 '(vm-quit-just-iconify quitting))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2062 (let ((summary-buffer vm-summary-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2063 (pres-buffer vm-presentation-buffer-handle))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2064 (vm-bury-buffer (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2065 (if summary-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2066 (vm-bury-buffer summary-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2067 (if pres-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2068 (vm-bury-buffer pres-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2069 (vm-iconify-frame)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (defun vm-quit-no-change ()
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
2072 "Quit visiting the current folder without saving changes made to the folder."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 (vm-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (defun vm-quit (&optional no-change)
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
2077 "Quit visiting the current folder, saving changes. Deleted messages are not expunged."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 (if (not (memq major-mode '(vm-mode vm-virtual-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 (error "%s must be invoked from a VM buffer." this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (vm-check-for-killed-summary)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2083 (vm-check-for-killed-presentation)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (vm-display nil nil '(vm-quit vm-quit-no-change)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (list this-command 'quitting))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 (let ((virtual (eq major-mode 'vm-virtual-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 ((and (not virtual) no-change (buffer-modified-p)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2089 (or buffer-file-name buffer-offer-save)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 (not (zerop vm-messages-not-on-disk))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 ;; Folder may have been saved with C-x C-s and attributes may have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 ;; been changed after that; in that case vm-messages-not-on-disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 ;; would not have been zeroed. However, all modification flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 ;; undos are cleared if VM actually modifies the folder buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 ;; (as opposed to the folder's attributes), so this can be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 ;; to verify that there are indeed unsaved messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (null (assq 'vm-set-buffer-modified-p vm-undo-record-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 "%d message%s have not been saved to disk, quit anyway? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 vm-messages-not-on-disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 (if (= 1 vm-messages-not-on-disk) "" "s")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (error "Aborted"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 ((and (not virtual)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2106 no-change
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2107 (or buffer-file-name buffer-offer-save)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2108 (buffer-modified-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2109 vm-confirm-quit
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (not (y-or-n-p "There are unsaved changes, quit anyway? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (error "Aborted"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 ((and (eq vm-confirm-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (not (y-or-n-p "Do you really want to quit? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (error "Aborted")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2116 (save-excursion (run-hooks 'vm-quit-hook))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2117
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2118 (vm-garbage-collect-message)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2119 (vm-garbage-collect-folder)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 (vm-virtual-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (if (and (not no-change) (not virtual))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 ;; this could take a while, so give the user some feedback
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2125 (message "Quitting...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 (or vm-folder-read-only (eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 (vm-change-all-new-to-unread))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2128 (if (and (buffer-modified-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2129 (or buffer-file-name buffer-offer-save)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2130 (not no-change)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2131 (not virtual))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 (vm-save-folder))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2133 (message "")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 (let ((summary-buffer vm-summary-buffer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2135 (pres-buffer vm-presentation-buffer-handle)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 (mail-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (if summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (progn
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2139 (vm-display summary-buffer nil nil nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 (kill-buffer summary-buffer)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2141 (if pres-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2142 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2143 (vm-display pres-buffer nil nil nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2144 (kill-buffer pres-buffer)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 (set-buffer mail-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 (vm-display mail-buffer nil nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 ;; vm-display is not supposed to change the current buffer.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2148 ;; still it's better to be safe here.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 (set-buffer mail-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (vm-update-summary-and-mode-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 (defun vm-start-itimers-if-needed ()
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2155 (cond ((and (not (natnump vm-flush-interval))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2156 (not (natnump vm-auto-get-new-mail))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2157 (not (natnump vm-mail-check-interval))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2158 ((condition-case data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2159 (progn (require 'itimer) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2160 (error nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2161 (and (natnump vm-flush-interval) (not (get-itimer "vm-flush"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2162 (start-itimer "vm-flush" 'vm-flush-itimer-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2163 vm-flush-interval nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2164 (and (natnump vm-auto-get-new-mail) (not (get-itimer "vm-get-mail"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2165 (start-itimer "vm-get-mail" 'vm-get-mail-itimer-function
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2166 vm-auto-get-new-mail nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2167 (and (natnump vm-mail-check-interval)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2168 (not (get-itimer "vm-check-mail"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2169 (start-itimer "vm-check-mail" 'vm-check-mail-itimer-function
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2170 vm-mail-check-interval nil)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2171 ((condition-case data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2172 (progn (require 'timer) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2173 (error nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2174 (let (timer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2175 (and (natnump vm-flush-interval)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2176 (setq timer (run-at-time vm-flush-interval vm-flush-interval
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2177 'vm-flush-itimer-function nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2178 (timer-set-function timer 'vm-flush-itimer-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2179 (list timer)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2180 (and (natnump vm-mail-check-interval)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2181 (setq timer (run-at-time vm-mail-check-interval
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2182 vm-mail-check-interval
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2183 'vm-check-mail-itimer-function nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2184 (timer-set-function timer 'vm-check-mail-itimer-function
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2185 (list timer)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2186 (and (natnump vm-auto-get-new-mail)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2187 (setq timer (run-at-time vm-auto-get-new-mail
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2188 vm-auto-get-new-mail
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2189 'vm-get-mail-itimer-function nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2190 (timer-set-function timer 'vm-get-mail-itimer-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2191 (list timer)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2192 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2193 (setq vm-flush-interval t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2194 vm-auto-get-new-mail t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2196 ;; support for vm-mail-check-interval
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2197 ;; if timer argument is present, this means we're using the Emacs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2198 ;; 'timer package rather than the 'itimer package.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2199 (defun vm-check-mail-itimer-function (&optional timer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2200 ;; FSF Emacs sets this non-nil, which means the user can't
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2201 ;; interrupt the check. Bogus.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2202 (setq inhibit-quit nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2203 (if (integerp vm-mail-check-interval)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2204 (if timer
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2205 (timer-set-time timer (current-time) vm-mail-check-interval)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2206 (set-itimer-restart current-itimer vm-mail-check-interval))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2207 ;; user has changed the variable value to something that
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2208 ;; isn't a number, make the timer go away.
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2209 (if timer
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2210 (cancel-timer timer)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2211 (set-itimer-restart current-itimer nil)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2212 (let ((b-list (buffer-list))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2213 (found-one nil)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2214 oldval)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2215 (while (and (not (input-pending-p)) b-list)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2216 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2217 (set-buffer (car b-list))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2218 (if (and (eq major-mode 'vm-mode)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2219 (setq found-one t)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2220 ;; to avoid reentrance into the pop code
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2221 (not vm-block-new-mail)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2222 ;; Don't bother checking if we already know from
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2223 ;; a previous check that there's mail waiting
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2224 ;; and the user hasn't retrieved it yet. Not
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2225 ;; completely accurate, but saves network
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2226 ;; connection build and tear down which is slow
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2227 ;; for some users.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2228 (not vm-spooled-mail-waiting))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2229 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2230 (setq oldval vm-spooled-mail-waiting)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2231 (vm-check-for-spooled-mail nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2232 (if (not (eq oldval vm-spooled-mail-waiting))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2233 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2234 (intern (buffer-name) vm-buffers-needing-display-update)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2235 (vm-update-summary-and-mode-line))))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2236 (setq b-list (cdr b-list)))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2237 ;; make the timer go away if we didn't encounter a vm-mode buffer.
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2238 (if (and (not found-one) (null b-list))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2239 (if timer
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2240 (cancel-timer timer)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2241 (set-itimer-restart current-itimer nil)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2242
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
2243 ;; support for numeric vm-auto-get-new-mail
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2244 ;; if timer argument is present, this means we're using the Emacs
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2245 ;; 'timer package rather than the 'itimer package.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2246 (defun vm-get-mail-itimer-function (&optional timer)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2247 ;; FSF Emacs sets this non-nil, which means the user can't
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2248 ;; interrupt mail retrieval. Bogus.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2249 (setq inhibit-quit nil)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
2250 (if (integerp vm-auto-get-new-mail)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2251 (if timer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2252 (timer-set-time timer (current-time) vm-auto-get-new-mail)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2253 (set-itimer-restart current-itimer vm-auto-get-new-mail))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2254 ;; user has changed the variable value to something that
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2255 ;; isn't a number, make the timer go away.
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2256 (if timer
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2257 (cancel-timer timer)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2258 (set-itimer-restart current-itimer nil)))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2259 (let ((b-list (buffer-list))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2260 (found-one nil))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2261 (while (and (not (input-pending-p)) b-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2262 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2263 (set-buffer (car b-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2264 (if (and (eq major-mode 'vm-mode)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2265 (setq found-one t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 (not (and (not (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 (file-newer-than-file-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 (make-auto-save-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 (not vm-block-new-mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 (not vm-folder-read-only)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2273 (vm-get-spooled-mail nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 (vm-assimilate-new-messages t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 ;; don't move the message pointer unless the folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 ;; was empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 (if (and (null vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 (vm-thoughtfully-select-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 (vm-preview-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 (vm-update-summary-and-mode-line)))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2282 (setq b-list (cdr b-list)))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2283 ;; make the timer go away if we didn't encounter a vm-mode buffer.
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2284 (if (and (not found-one) (null b-list))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2285 (if timer
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2286 (cancel-timer timer)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2287 (set-itimer-restart current-itimer nil)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 ;; support for numeric vm-flush-interval
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2290 ;; if timer argument is present, this means we're using the Emacs
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2291 ;; 'timer package rather than the 'itimer package.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2292 (defun vm-flush-itimer-function (&optional timer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 (if (integerp vm-flush-interval)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2294 (if timer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2295 (timer-set-time timer (current-time) vm-flush-interval)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2296 (set-itimer-restart current-itimer vm-flush-interval)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 ;; if no vm-mode buffers are found, we might as well shut down the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 ;; flush itimer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 (if (not (vm-flush-cached-data))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2300 (if timer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2301 (cancel-timer timer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2302 (set-itimer-restart current-itimer nil))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 ;; flush cached data in all vm-mode buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 ;; returns non-nil if any vm-mode buffers were found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 (defun vm-flush-cached-data ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 (let ((buf-list (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 (found-one nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 (while (and buf-list (not (input-pending-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 (set-buffer (car buf-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 (cond ((and (eq major-mode 'vm-mode) vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 (setq found-one t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 (if (not (eq vm-modification-counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 vm-flushed-modification-counter))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2316 (progn
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 (vm-stuff-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 (vm-stuff-labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 (and vm-message-order-changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 (vm-stuff-message-order))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2321 (and (vm-stuff-folder-attributes t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 (setq vm-flushed-modification-counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 vm-modification-counter))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 (setq buf-list (cdr buf-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 ;; if we haven't checked them all return non-nil so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 ;; the flusher won't give up trying.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 (or buf-list found-one) )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 ;; This allows C-x C-s to do the right thing for VM mail buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 ;; Note that deleted messages are not expunged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 (defun vm-write-file-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (if (and (eq major-mode 'vm-mode) (not vm-inhibit-write-file-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 ;; The vm-save-restriction isn't really necessary here, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 ;; the stuff routines clean up after themselves, but should remain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 ;; as a safeguard against the time when other stuff is added here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 (vm-save-restriction
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2337 (let ((buffer-read-only))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2338 (vm-stuff-folder-attributes nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2339 (if vm-message-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2340 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2341 ;; get summary cache up-to-date
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2342 (vm-update-summary-and-mode-line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2343 (vm-stuff-bookmark)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2344 (vm-stuff-header-variables)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2345 (vm-stuff-labels)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2346 (vm-stuff-summary)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2347 (and vm-message-order-changed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2348 (vm-stuff-message-order))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2349 nil ))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 (defun vm-save-buffer (prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 (vm-error-if-virtual-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (save-buffer prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 (setq vm-block-new-mail nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 (vm-display nil nil '(vm-save-buffer) '(vm-save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 (defun vm-write-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 (vm-error-if-virtual-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 (call-interactively 'write-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 (setq vm-block-new-mail nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 (vm-display nil nil '(vm-write-file) '(vm-write-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 (defun vm-save-folder (&optional prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 "Save current folder to disk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 Deleted messages are not expunged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 Prefix arg is handled the same as for the command save-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 When applied to a virtual folder, this command runs itself on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 each of the underlying real folders associated with the virtual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 folder."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 (interactive (list current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 (vm-display nil nil '(vm-save-folder) '(vm-save-folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (if (eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 (vm-virtual-save-folder prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 (if (buffer-modified-p)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2386 (let (mp (newlist nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 ;; stuff the attributes of messages that need it.
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2388 (message "Stuffing attributes...")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2389 (vm-stuff-folder-attributes nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 ;; stuff bookmark and header variable values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (if vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 ;; get summary cache up-to-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 (vm-stuff-bookmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 (vm-stuff-header-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 (vm-stuff-labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (vm-stuff-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 (and vm-message-order-changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 (vm-stuff-message-order))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2401 (message "Saving...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 (let ((vm-inhibit-write-file-hook t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 (save-buffer prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 (vm-set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 (vm-clear-modification-flag-undos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 (setq vm-messages-not-on-disk 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 (setq vm-block-new-mail nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 (and (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 vm-delete-empty-folders
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 (or (eq vm-delete-empty-folders t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 (y-or-n-p (format "%s is empty, remove it? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 (or buffer-file-name (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 (delete-file buffer-file-name)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2417 (clear-visited-file-modtime)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 (message "%s removed" buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 ;; no can do, oh well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 (message "No changes need to be saved"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 (defun vm-save-and-expunge-folder (&optional prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 "Expunge folder, then save it to disk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 Prefix arg is handled the same as for the command save-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 Expunge won't be done if folder is read-only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 When applied to a virtual folder, this command works as if you had
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 run vm-expunge-folder followed by vm-save-folder."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 (interactive (list current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 (vm-display nil nil '(vm-save-and-expunge-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 '(vm-save-and-expunge-folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 (if (not vm-folder-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 (progn
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2438 (message "Expunging...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (vm-expunge-folder t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 (vm-save-folder prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 (defun vm-handle-file-recovery-or-reversion (recovery)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 (if (and vm-summary-buffer (buffer-name vm-summary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 (kill-buffer vm-summary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 (vm-virtual-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 ;; reset major mode, this will cause vm to start from scratch.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 (setq major-mode 'fundamental-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 ;; If this is a recovery, we can't allow the user to get new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 ;; mail until a real save is performed. Until then the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 ;; and the disk don't match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (if recovery
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 (setq vm-block-new-mail t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (vm buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 ;; detect if a recover-file is being performed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 ;; and handle things properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 (defun vm-handle-file-recovery ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 (eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (= (vm-end-of (car vm-message-list)) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (vm-handle-file-recovery-or-reversion t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 ;; detect if a revert-buffer is being performed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 ;; and handle things properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 (defun vm-handle-file-reversion ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 (if (and (not (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 (eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 (= (vm-end-of (car vm-message-list)) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (vm-handle-file-recovery-or-reversion nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 ;; FSF v19.23 revert-buffer doesn't mash all the markers together
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 ;; like v18 and prior v19 versions, so the check in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 ;; vm-handle-file-reversion doesn't work. However v19.23 has a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 ;; hook we can use, after-revert-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (defun vm-after-revert-buffer-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (if (eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 (vm-handle-file-recovery-or-reversion nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (defun vm-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 "Display help for various VM activities."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 (if (eq major-mode 'vm-summary-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (vm-select-folder-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 (let ((pop-up-windows (and pop-up-windows (eq vm-mutable-windows t)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
2487 (pop-up-frames vm-mutable-frames))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 ((eq last-command 'vm-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 (describe-function major-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 ((eq vm-system-state 'previewing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (message "Type SPC to read message, n previews next message (? gives more help)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 ((memq vm-system-state '(showing reading))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 (message "SPC and b scroll, (d)elete, (s)ave, (n)ext, (r)eply (? gives more help)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 ((eq vm-system-state 'editing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 "Type \\[vm-edit-message-end] to end edit, \\[vm-edit-message-abort] to abort with no change.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 ((eq major-mode 'mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 (substitute-command-keys
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
2502 "Type \\[vm-mail-send-and-exit] to send message, \\[kill-buffer] to discard this message")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (t (describe-mode)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (defun vm-spool-move-mail (source destination)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (let ((handler (and (fboundp 'find-file-name-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 (find-file-name-handler source 'vm-spool-move-mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (wrong-number-of-arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 (find-file-name-handler source)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 status error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 (if handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 (funcall handler 'vm-spool-move-mail source destination)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 (setq error-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 (format "*output of %s %s %s*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 vm-movemail-program source destination)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 (set-buffer error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 (setq status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 (call-process vm-movemail-program nil error-buffer t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 source destination))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 (set-buffer error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 (if (and (numberp status) (not (= 0 status)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 (insert (format "\n%s exited with code %s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 vm-movemail-program status)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (if (> (buffer-size) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 (vm-display-buffer error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 (if (and (numberp status) (not (= 0 status)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 (error "Failed getting new mail from %s" source)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 (message "Warning: unexpected output from %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 vm-movemail-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 (sleep-for 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 ;; nag, nag, nag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 (kill-buffer error-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 t ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 (defun vm-gobble-crash-box (crash-box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 (let ((opoint-max (point-max)) crash-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 (inbox-buffer-file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 (inbox-folder-type vm-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 (inbox-empty (zerop (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 got-mail crash-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 (old-buffer-modified-p (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (setq crash-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 ;; crash box could contain a letter bomb...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 ;; force user notification of file variables for v18 Emacses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 ;; enable-local-variables == nil disables them for newer Emacses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 (let ((inhibit-local-variables t)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2557 (enable-local-variables nil)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2558 (coding-system-for-read 'no-conversion))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 (find-file-noselect crash-box)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 (set-buffer crash-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 (setq crash-folder-type (vm-get-folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 (if (and crash-folder-type vm-check-folder-types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 (cond ((eq crash-folder-type 'unknown)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 (error "crash box %s's type is unrecognized" crash-box))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 ((eq inbox-folder-type 'unknown)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 (error "inbox %s's type is unrecognized"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 inbox-buffer-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 ((null inbox-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 (if vm-default-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 (if (not (eq vm-default-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 crash-folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 (if vm-convert-folder-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 (vm-convert-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 crash-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 vm-default-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 ;; so that kill-buffer won't ask a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 ;; question later...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 (error "crash box %s mismatches vm-default-folder-type: %s, %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 crash-box crash-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 vm-default-folder-type)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 ((not (eq inbox-folder-type crash-folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 (if vm-convert-folder-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 (vm-convert-folder-type crash-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 inbox-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 ;; so that kill-buffer won't ask a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 ;; question later...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 (error "crash box %s mismatches %s's folder type: %s, %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 crash-box inbox-buffer-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 crash-folder-type inbox-folder-type)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 ;; toss the folder header if the inbox is not empty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 (if (not inbox-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (vm-convert-folder-header (or inbox-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 vm-default-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 (set-buffer-modified-p nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 (insert-buffer-substring crash-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 1 (1+ (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (set-buffer crash-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (buffer-size))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 (setq got-mail (/= opoint-max (point-max)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2610 (if (not got-mail)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2611 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2612 (write-region opoint-max (point-max) buffer-file-name t t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2613 (vm-increment vm-modification-counter)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2614 (set-buffer-modified-p old-buffer-modified-p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2615 (kill-buffer crash-buf)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2616 (if (not (stringp vm-keep-crash-boxes))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2617 (vm-error-free-call 'delete-file crash-box)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2618 (let ((time (decode-time (current-time)))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2619 name)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2620 (setq name
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2621 (expand-file-name (format "Z-%02d-%02d-%05d"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2622 (nth 4 time)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2623 (nth 3 time)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2624 (% (vm-abs (random)) 100000))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2625 vm-keep-crash-boxes))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2626 (while (file-exists-p name)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2627 (setq name
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2628 (expand-file-name (format "Z-%02d-%02d-%05d"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2629 (nth 4 time)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2630 (nth 3 time)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2631 (% (vm-abs (random)) 100000))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2632 vm-keep-crash-boxes)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2633 (rename-file crash-box name))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 got-mail ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2636 (defun vm-compute-spool-files ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2637 (let ((fallback-triples nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2638 triples)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2639 (cond ((and buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2640 (consp vm-spool-file-suffixes)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2641 (stringp vm-crash-box-suffix))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2642 (setq fallback-triples
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2643 (mapcar (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2644 (lambda (suffix)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2645 (list buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2646 (concat buffer-file-name suffix)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2647 (concat buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2648 vm-crash-box-suffix))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2649 vm-spool-file-suffixes))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2650 (cond ((and buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2651 vm-make-spool-file-name vm-make-crash-box-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2652 (setq fallback-triples
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2653 (nconc fallback-triples
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2654 (list (list buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2655 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2656 (funcall vm-make-spool-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2657 buffer-file-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2658 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2659 (funcall vm-make-crash-box-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2660 buffer-file-name))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 (cond ((null (vm-spool-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 (setq triples (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 (list vm-primary-inbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 (concat vm-spool-directory (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 vm-crash-box))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 ((stringp (car (vm-spool-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 (setq triples
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 (lambda (s) (list vm-primary-inbox s vm-crash-box)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (vm-spool-files))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 ((consp (car (vm-spool-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 (setq triples (vm-spool-files))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2673 (setq triples (append triples fallback-triples))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2674 triples ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2675
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2676 (defun vm-spool-check-mail (source)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2677 (let ((handler (and (fboundp 'find-file-name-handler)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2678 (condition-case ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2679 (find-file-name-handler source 'vm-spool-check-mail)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2680 (wrong-number-of-arguments
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2681 (find-file-name-handler source))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2682 (if handler
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2683 (funcall handler 'vm-spool-check-mail source)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2684 (and (not (equal 0 (nth 7 (file-attributes source))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2685 (file-readable-p source)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2686
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2687 (defun vm-check-for-spooled-mail (&optional interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2688 (if vm-block-new-mail
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2689 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2690 (let ((triples (vm-compute-spool-files))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2691 ;; since we could accept-process-output here (POP code),
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2692 ;; a timer process might try to start retrieving mail
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2693 ;; before we finish. block these attempts.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2694 (vm-block-new-mail t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2695 (vm-pop-ok-to-ask interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2696 (done nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2697 crash in maildrop popdrop
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2698 (mail-waiting nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2699 (while (and triples (not done))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2700 (setq in (expand-file-name (nth 0 (car triples)) vm-folder-directory)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2701 maildrop (nth 1 (car triples))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2702 crash (nth 2 (car triples)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2703 (if (eq (current-buffer) (vm-get-file-buffer in))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2704 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2705 (if (file-exists-p crash)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2706 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2707 (setq mail-waiting t
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2708 done t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2709 (setq popdrop (and vm-recognize-pop-maildrops
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2710 (string-match vm-recognize-pop-maildrops
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2711 maildrop)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2712 (if (not interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2713 ;; allow no error to be signaled
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2714 (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2715 (setq mail-waiting
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2716 (or mail-waiting
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2717 (if popdrop
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2718 (vm-pop-check-mail maildrop)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2719 (vm-spool-check-mail maildrop))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2720 (error nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2721 (setq mail-waiting (or mail-waiting
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2722 (if popdrop
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2723 (vm-pop-check-mail maildrop)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2724 (vm-spool-check-mail maildrop)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2725 (if mail-waiting
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2726 (setq done t)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2727 (setq triples (cdr triples)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2728 (setq vm-spooled-mail-waiting mail-waiting)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2729 mail-waiting )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2730
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2731 (defun vm-get-spooled-mail (&optional interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2732 (if vm-block-new-mail
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2733 (error "Can't get new mail until you save this folder."))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2734 (let ((triples (vm-compute-spool-files))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2735 ;; since we could accept-process-output here (POP code),
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2736 ;; a timer process might try to start retrieving mail
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2737 ;; before we finish. block these attempts.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2738 (vm-block-new-mail t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2739 (vm-pop-ok-to-ask interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2740 crash in maildrop popdrop
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2741 (got-mail nil))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2742 (if (and (not (verify-visited-file-modtime (current-buffer)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2743 (or (null interactive)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2744 (not (yes-or-no-p
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2745 (format
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2746 "Folder %s changed on disk, discard those changes? "
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2747 (buffer-name (current-buffer)))))))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2748 (progn
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2749 (message "Folder %s changed on disk, consider M-x revert-buffer"
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2750 (buffer-name (current-buffer)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2751 (sleep-for 1)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2752 nil )
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2753 (while triples
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2754 (setq in (expand-file-name (nth 0 (car triples)) vm-folder-directory)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2755 maildrop (nth 1 (car triples))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2756 crash (nth 2 (car triples)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2757 (if (eq (current-buffer) (vm-get-file-buffer in))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2758 (let (retrieval-function)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2759 (if (file-exists-p crash)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2760 (progn
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2761 (message "Recovering messages from %s..." crash)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2762 (setq got-mail (or (vm-gobble-crash-box crash) got-mail))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2763 (message "Recovering messages from %s... done" crash)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2764 (setq popdrop (and vm-recognize-pop-maildrops
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2765 (string-match vm-recognize-pop-maildrops
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2766 maildrop)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2767 ;; maildrop with password clipped
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2768 (vm-safe-popdrop-string maildrop)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2769 (if (or popdrop
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2770 (and (not (equal 0 (nth 7 (file-attributes maildrop))))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2771 (file-readable-p maildrop)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2772 (progn
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2773 (setq crash (expand-file-name crash vm-folder-directory))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2774 (if (not popdrop)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2775 (setq maildrop (expand-file-name maildrop)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2776 retrieval-function 'vm-spool-move-mail)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2777 (setq retrieval-function 'vm-pop-move-mail))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2778 (if (if got-mail
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2779 ;; don't allow errors to be signaled unless no
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2780 ;; mail has been appended to the incore
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2781 ;; copy of the folder. otherwise the
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2782 ;; user will wonder where the mail is,
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2783 ;; since it is not in the crash box or
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2784 ;; the spool file and doesn't _appear_ to
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2785 ;; be in the folder either.
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2786 (condition-case error-data
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2787 (funcall retrieval-function maildrop crash)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2788 (error (message "%s signaled: %s"
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2789 (if popdrop
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2790 'vm-pop-move-mail
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2791 'vm-spool-move-mail)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2792 error-data)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2793 (sleep-for 2)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2794 ;; we don't know if mail was
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2795 ;; put into the crash box or
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2796 ;; not, so return t just to be
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2797 ;; safe.
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2798 t )
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2799 (quit (message "quitting from %s..."
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2800 (if popdrop
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2801 'vm-pop-move-mail
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2802 'vm-spool-move-mail))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2803 (sleep-for 1)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2804 ;; we don't know if mail was
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2805 ;; put into the crash box or
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2806 ;; not, so return t just to be
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2807 ;; safe.
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2808 t ))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2809 (funcall retrieval-function maildrop crash))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2810 (if (vm-gobble-crash-box crash)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2811 (progn
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2812 (setq got-mail t)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2813 (message "Got mail from %s."
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2814 (or popdrop maildrop)))))))))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2815 (setq triples (cdr triples)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2816 ;; not really correct, but it is what the user expects to see.
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2817 (if got-mail
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2818 (setq vm-spooled-mail-waiting nil))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2819 (intern (buffer-name) vm-buffers-needing-display-update)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2820 (vm-update-summary-and-mode-line)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2821 (if got-mail
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2822 (run-hooks 'vm-retrieved-spooled-mail-hook))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2823 got-mail )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 (defun vm-safe-popdrop-string (drop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 (or (and (string-match "^\\([^:]+\\):[^:]+:[^:]+:\\([^:]+\\):[^:]+" drop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 (concat (substring drop (match-beginning 2) (match-end 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 "@"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 (substring drop (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 "???"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 (defun vm-get-new-mail (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 "Move any new mail that has arrived in any of the spool files for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 current folder into the folder. New mail is appended to the disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 and buffer copies of the folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 Prefix arg means to gather mail from a user specified folder, instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 the usual spool files. The file name will be read from the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 Unlike when getting mail from a spool file, the source file is left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 undisturbed after its messages have been copied.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 When applied to a virtual folder, this command runs itself on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 each of the underlying real folders associated with this virtual folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 A prefix argument has no effect; mail is always gathered from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 spool files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 (vm-error-if-folder-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 (cond ((eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 (vm-virtual-get-new-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 ((null arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 (if (not (eq major-mode 'vm-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 (vm-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 (if (consp (car (vm-spool-files)))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2856 (message "Checking for new mail for %s..."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 (or buffer-file-name (buffer-name)))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2858 (message "Checking for new mail..."))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 (let (totals-blurb)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2860 (if (and (vm-get-spooled-mail t) (vm-assimilate-new-messages t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 ;; say this NOW, before the non-previewers read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 ;; a message, alter the new message count and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 ;; confuse themselves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 (setq totals-blurb (vm-emit-totals-blurb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 (vm-display nil nil '(vm-get-new-mail) '(vm-get-new-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 (if (vm-thoughtfully-select-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 (vm-preview-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 (message totals-blurb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 (if (consp (car (vm-spool-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 (message "No new mail for %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 (or buffer-file-name (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 (message "No new mail."))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2875 (and (interactive-p) (sit-for 4) (message "")))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 (let ((buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 folder mcount totals-blurb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 (setq folder (read-file-name "Gather mail from folder: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 vm-folder-directory t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 (if (and vm-check-folder-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 (not (vm-compatible-folder-p folder)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 (error "Folder %s is not the same format as this folder."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 (goto-char (point-max))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2889 (let ((coding-system-for-read 'binary))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2890 (insert-file-contents folder))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 (setq mcount (length vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 (if (vm-assimilate-new-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 ;; say this NOW, before the non-previewers read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 ;; a message, alter the new message count and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 ;; confuse themselves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 (setq totals-blurb (vm-emit-totals-blurb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 (vm-display nil nil '(vm-get-new-mail) '(vm-get-new-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 (if (vm-thoughtfully-select-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 (vm-preview-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 (message totals-blurb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 ;; The gathered messages are actually still on disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 ;; unless the user deletes the folder himself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 ;; However, users may not understand what happened if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 ;; the messages go away after a "quit, no save".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 (setq vm-messages-not-on-disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 (+ vm-messages-not-on-disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 (- (length vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 mcount))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 (message "No messages gathered."))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 ;; returns non-nil if there were any new messages
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2914 (defun vm-assimilate-new-messages (&optional
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2915 dont-read-attributes
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2916 gobble-order
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2917 labels)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 (let ((tail-cons (vm-last vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 b-list new-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 (vm-build-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 (if (or (null tail-cons) (cdr tail-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 (setq vm-ml-sort-keys nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 (if dont-read-attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 (vm-set-default-attributes (cdr tail-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 (vm-read-attributes (cdr tail-cons)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 ;; Yuck. This has to be done here instead of in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 ;; vm function because this needs to be done before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 ;; any initial thread sort (so that if the thread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 ;; sort matches the saved order the folder won't be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 ;; modified) but after the message list is created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 ;; Since thread sorting is done here this has to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 ;; done here too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 (if gobble-order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 (vm-gobble-message-order))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 (if vm-thread-obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 (vm-build-threads (cdr tail-cons))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 (setq new-messages (if tail-cons (cdr tail-cons) vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 (vm-set-numbering-redo-start-point new-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 (vm-set-summary-redo-start-point new-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 ;; copy the new-messages list because sorting might scramble
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 ;; it. Also something the user does when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 ;; vm-arrived-message-hook is run might affect it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 ;; vm-assimilate-new-messages returns this value so it must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 ;; not be mangled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 (setq new-messages (copy-sequence new-messages))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2950 ;; add the labels
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2951 (if (and labels vm-burst-digest-messages-inherit-labels)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2952 (let ((mp new-messages))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2953 (while mp
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2954 (vm-set-labels-of (car mp) (copy-sequence labels))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2955 (setq mp (cdr mp)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 (if vm-summary-show-threads
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 ;; get numbering and summary of new messages done now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 ;; so that the sort code only has to worry about the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 ;; changes it needs to make.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 (vm-sort-messages "thread")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 (if (and vm-arrived-message-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 new-messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 ;; tail-cons == nil means vm-message-list was empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 ;; Thus new-messages == vm-message-list. In this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 ;; case, run the hooks only if this is not the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 ;; time vm-assimilate-new-messages has been called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 ;; in this folder. gobble-order non-nil is a good
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 ;; indicator that this is the first time because the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 ;; order is gobbled only once per visit and always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 ;; the first time vm-assimilate-new-messages is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 ;; called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 (or tail-cons (null gobble-order)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 (let ((new-messages new-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 ;; seems wise to do this so that if the user runs VM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 ;; command here they start with as much of a clean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 ;; slate as we can provide, given we're currently deep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 ;; in the guts of VM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 (while new-messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 (vm-run-message-hook (car new-messages) 'vm-arrived-message-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 (setq new-messages (cdr new-messages)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 (run-hooks 'vm-arrived-messages-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 (if (and new-messages vm-virtual-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 (setq b-list vm-virtual-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 (while b-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 ;; buffer might be dead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 (if (buffer-name (car b-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 (let (tail-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 (set-buffer (car b-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 (setq tail-cons (vm-last vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 (vm-build-virtual-message-list new-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 (if (or (null tail-cons) (cdr tail-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 (setq vm-ml-sort-keys nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 (if vm-thread-obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 (vm-build-threads (cdr tail-cons)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 (vm-set-summary-redo-start-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 (or (cdr tail-cons) vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 (vm-set-numbering-redo-start-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 (or (cdr tail-cons) vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 (if (null vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 (progn (setq vm-message-pointer vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 vm-need-summary-pointer-update t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 (vm-preview-current-message))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 (if vm-summary-show-threads
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 (vm-sort-messages "thread")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 (setq b-list (cdr b-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 new-messages ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 ;; return a list of all marked messages or the messages indicated by a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 ;; prefix argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 (defun vm-select-marked-or-prefixed-messages (prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 (let (mlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 (if (eq last-command 'vm-next-command-uses-marks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 (setq mlist (vm-marked-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 (let ((direction (if (< prefix 0) 'backward 'forward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 (count (vm-abs prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 (vm-message-pointer vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 (if (not (eq vm-circular-folders t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 (vm-check-count prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 (while (not (zerop count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 (setq mlist (cons (car vm-message-pointer) mlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 (vm-decrement count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 (if (not (zerop count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 (vm-move-message-pointer direction))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 (nreverse mlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 (defun vm-display-startup-message ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036 (if (sit-for 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 (let ((lines vm-startup-message-lines))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3038 (message "VM %s, Copyright (C) 1997 Kyle E. Jones; type ? for help"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 vm-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 (setq vm-startup-message-displayed t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 (while (and (sit-for 4) lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 (message (substitute-command-keys (car lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 (setq lines (cdr lines)))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
3044 (message ""))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 (defun vm-load-init-file (&optional interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 (if (or (not vm-init-file-loaded) interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 (and vm-init-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 (load vm-init-file (not interactive) (not interactive) t))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3052 (and vm-preferences-file (load vm-preferences-file t t t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 (setq vm-init-file-loaded t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 (vm-display nil nil '(vm-load-init-file) '(vm-load-init-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 (defun vm-session-initialization ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 ;; If this is the first time VM has been run in this Emacs session,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 ;; do some necessary preparations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 (if (or (not (boundp 'vm-session-beginning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 vm-session-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 (random t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 (vm-load-init-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 (if (not vm-window-configuration-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 (setq vm-window-configurations vm-default-window-configuration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 (or (vm-load-window-configurations vm-window-configuration-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 (setq vm-window-configurations vm-default-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 (setq vm-buffers-needing-display-update (make-vector 29 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 (setq vm-session-beginning nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 (defun vm-toggle-read-only ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 (setq vm-folder-read-only (not vm-folder-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 (message "Folder is now %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 (if vm-folder-read-only "read-only" "modifiable"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 (vm-display nil nil '(vm-toggle-read-only) '(vm-toggle-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3081 (defvar scroll-in-place)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3082
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 ;; this does the real major mode scutwork.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 (defun vm-mode-internal ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 (make-local-variable 'require-final-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 ;; don't kill local variables, as there is some state we'd like to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 ;; keep. rather than non-portably marking the variables we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 ;; want to keep, just avoid calling kill-local-variables and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 ;; reset everything that needs to be reset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 major-mode 'vm-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 mode-line-format vm-mode-line-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 mode-name "VM"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 ;; must come after the setting of major-mode
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3096 mode-popup-menu (and vm-use-menus vm-popup-menu-on-mouse-3
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 (vm-menu-support-possible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 (vm-menu-mode-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 buffer-read-only t
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3100 ;; If the user quits a vm-mode buffer, the default action is
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3101 ;; to kill the buffer. Make a note that we should offer to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3102 ;; save this buffer even if it has no file associated with it.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3103 ;; We have no idea of the value of the data in the buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3104 ;; before it was put into vm-mode.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3105 buffer-offer-save t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 require-final-newline nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 vm-thread-obarray nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 vm-thread-subject-obarray nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 vm-label-obarray (make-vector 29 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 vm-last-message-pointer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 vm-modification-counter 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 vm-message-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 vm-message-pointer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 vm-message-order-changed nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 vm-message-order-header-present nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 vm-summary-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 vm-system-state nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 vm-undo-record-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 vm-undo-record-pointer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 vm-virtual-buffers (vm-link-to-virtual-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 vm-folder-type (vm-get-folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 (use-local-map vm-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 (and (vm-menu-support-possible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 (vm-menu-install-menus))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3125 (add-hook 'kill-buffer-hook 'vm-garbage-collect-folder)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3126 (add-hook 'kill-buffer-hook 'vm-garbage-collect-message)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3127 ;; avoid the XEmacs file dialog box.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3128 (defvar use-dialog-box)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3129 (make-local-variable 'use-dialog-box)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3130 (setq use-dialog-box nil)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3131 ;; mail folders are precious. protect them by default.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3132 (make-local-variable 'file-precious-flag)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3133 (setq file-precious-flag t)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3134 ;; scroll in place messes with scroll-up and this loses
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3135 (make-local-variable 'scroll-in-place)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3136 (setq scroll-in-place nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 (run-hooks 'vm-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 ;; compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 (run-hooks 'vm-mode-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 (defun vm-link-to-virtual-buffers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 (let ((b-list (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 (vbuffers nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 (folder-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 folders clauses)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 (while b-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 (set-buffer (car b-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 (cond ((eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 (setq clauses (cdr vm-virtual-folder-definition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 (while clauses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 (setq folders (car (car clauses)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 (while folders
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 (if (eq folder-buffer (vm-get-file-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 (car folders)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 vm-folder-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 (setq vbuffers (cons (car b-list) vbuffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 vm-real-buffers (cons folder-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 vm-real-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 folders nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 clauses nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 (setq folders (cdr folders)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 (setq clauses (cdr clauses)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 (setq b-list (cdr b-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 vbuffers )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 (defun vm-change-folder-type (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 "Change folder type to TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 TYPE may be one of the following symbol values:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 From_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 From_-with-Content-Length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 mmdf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 babyl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 Interactively TYPE will be read from the minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 (let ((this-command this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 (last-command last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 (types vm-supported-folder-types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 (vm-error-if-virtual-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 (setq types (vm-delqual (symbol-name vm-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 (copy-sequence types)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 (list (intern (vm-read-string "Change folder to type: " types)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 (vm-error-if-virtual-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 (if (not (memq type '(From_ From_-with-Content-Length mmdf babyl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 (error "Unknown folder type: %s" type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 (if (or (null vm-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 (eq vm-folder-type 'unknown))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 (error "Current folder's type is unknown, can't change it."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196 (let ((mp vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 (old-type vm-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 ;; no interruptions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 (inhibit-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 (n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 ;; Just for laughs, make the update interval vary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 (modulus (+ (% (vm-abs (random)) 11) 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 text-end opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 (setq vm-folder-type type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 (vm-convert-folder-header old-type type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 (goto-char (vm-start-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 (setq opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 (insert (vm-leading-message-separator type (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 (if (> (vm-headers-of (car mp)) (vm-start-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 (delete-region (point) (vm-headers-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 (set-marker (vm-headers-of (car mp)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 ;; if headers-of == start-of then so could vheaders-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 ;; and text-of. clear them to force a recompute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 (vm-set-vheaders-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 (vm-set-text-of (car mp) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 (vm-convert-folder-type-headers old-type type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 (goto-char (vm-text-end-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 (setq text-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 (insert-before-markers (vm-trailing-message-separator type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 (delete-region (vm-text-end-of (car mp)) (vm-end-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 (set-marker (vm-text-end-of (car mp)) text-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 (goto-char (vm-headers-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 (vm-munge-message-separators type (vm-headers-of (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 (vm-text-end-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 (vm-set-byte-count-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 (vm-set-babyl-frob-flag-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 (vm-set-message-type-of (car mp) type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 ;; Technically we should mark each message for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 ;; summary update since the message byte counts might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 ;; have changed. But I don't think anyone cares that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 ;; much and the summary regeneration would make this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238 ;; process slower.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 (setq mp (cdr mp) n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 (if (zerop (% n modulus))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
3241 (message "Converting... %d" n))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 (vm-clear-modification-flag-undos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245 (message "Conversion complete.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 ;; message separator strings may have leaked into view
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 (if (> (point-max) (vm-text-end-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 (narrow-to-region (point-min) (vm-text-end-of (car vm-message-pointer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 (vm-display nil nil '(vm-change-folder-type) '(vm-change-folder-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3251 (defun vm-garbage-collect-folder ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3252 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3253 (while vm-folder-garbage-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3254 (condition-case nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3255 (funcall (cdr (car vm-folder-garbage-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3256 (car (car vm-folder-garbage-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3257 (error nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3258 (setq vm-folder-garbage-alist (cdr vm-folder-garbage-alist)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3259
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3260 (defun vm-garbage-collect-message ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3261 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3262 (while vm-message-garbage-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3263 (condition-case nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3264 (funcall (cdr (car vm-message-garbage-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3265 (car (car vm-message-garbage-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3266 (error nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3267 (setq vm-message-garbage-alist (cdr vm-message-garbage-alist)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3268
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 (if (not (memq 'vm-write-file-hook write-file-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 (setq write-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 (cons 'vm-write-file-hook write-file-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 (if (not (memq 'vm-handle-file-recovery find-file-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 (setq find-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 (nconc find-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 '(vm-handle-file-recovery
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 vm-handle-file-reversion))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 ;; after-revert-hook is new to FSF v19.23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 (defvar after-revert-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 (if (boundp 'after-revert-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 (setq after-revert-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 (cons 'vm-after-revert-buffer-hook after-revert-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 (setq after-revert-hook (list 'vm-after-revert-buffer-hook)))