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

Added tag r20-2p1 for changeset 2af401a6ecca
author cvs
date Mon, 13 Aug 2007 09:34:48 +0200
parents 585fb297b004
children 43dd3413c7c7
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
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
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)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1169 oldpoint 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 ()
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1185 (progn
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1186 (setq oldpoint (point)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1187 data (read (current-buffer)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1188 (if (and (or (not (listp data)) (not (= 3 (length data))))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1189 (not (vectorp data)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1190 (progn
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1191 (error "Bad x-vm-v5-data at %d in buffer %s"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1192 oldpoint (buffer-name))))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1193 data )
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1194 (error
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1195 (message "Bad x-vm-v5-data header at %d in buffer %s, ignoring"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1196 oldpoint (buffer-name))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1197 (setq data
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1198 (list
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1199 (make-vector vm-attributes-vector-length nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1200 (make-vector vm-cache-vector-length nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1201 nil))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1202 ;; In lieu of a valid attributes header
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1203 ;; assume the message is new. avoid
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1204 ;; vm-set-new-flag because it asks for a
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1205 ;; summary update.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1206 (vm-set-new-flag-in-vector (car data) t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 ;; support version 4 format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (cond ((vectorp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (setq data (vm-convert-v4-attributes data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 ;; tink the message modflag so that if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 ;; user saves we get rid of the old v4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 ;; attributes header. otherwise we could be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 ;; dealing with these things for all eternity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (vm-set-modflag-of (car mp) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;; extend vectors if necessary to accomodate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 ;; more caching and attributes without alienating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 ;; other version 5 folders.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (cond ((< (length (car data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 vm-attributes-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 data (vm-extend-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (car data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 vm-attributes-vector-length))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (cond ((< (length (car (cdr data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 vm-cache-vector-length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 ;; tink the message modflag so that if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ;; the user saves we get rid of the old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 ;; short vector. otherwise we could be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 ;; dealing with these things for all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 ;; eternity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (vm-set-modflag-of (car mp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (setcar (cdr data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (vm-extend-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (car (cdr data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 vm-cache-vector-length))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (vm-set-labels-of (car mp) (nth 2 data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (vm-set-cache-of (car mp) (car (cdr data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (vm-set-attributes-of (car mp) (car data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 ((and vm-berkeley-mail-compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (re-search-forward vm-berkeley-mail-status-header-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (vm-text-of (car mp)) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (vm-set-cache-of (car mp) (make-vector vm-cache-vector-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (vm-set-attributes-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (car mp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (make-vector vm-attributes-vector-length nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (vm-set-unread-flag (car mp) (not (looking-at ".*R.*")) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (vm-set-cache-of (car mp) (make-vector vm-cache-vector-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (vm-set-attributes-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (car mp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (make-vector vm-attributes-vector-length nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 ;; In lieu of a valid attributes header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 ;; assume the message is new. avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 ;; vm-set-new-flag because it asks for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;; summary update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (vm-set-new-flag-of (car mp) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 ;; let babyl attributes override the normal VM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 ;; attributes header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (cond ((eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (vm-read-babyl-attributes (car mp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (cond ((vm-deleted-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (vm-increment vm-deleted-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 ((vm-new-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (vm-increment vm-new-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 ((vm-unread-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (vm-increment vm-unread-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (if (zerop (% vm-total-count modulus))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
1277 (message "Reading attributes... %d" vm-total-count))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (setq mp (cdr mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (if (>= vm-total-count modulus)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
1280 (message "Reading attributes... done"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (if (null message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (setq vm-totals (list vm-modification-counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 vm-total-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 vm-new-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 vm-unread-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 vm-deleted-count))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (defun vm-read-babyl-attributes (message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (labels nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (vect (make-vector vm-attributes-vector-length nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (vm-set-attributes-of message vect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (goto-char (vm-start-of message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 ;; skip past ^L\n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (vm-set-babyl-frob-flag-of message (if (= (following-char) ?1) t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 ;; skip past 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 ;; loop, noting attributes as we go.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (while (and (not (eobp)) (not (looking-at ",")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (cond ((looking-at " unseen,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (vm-set-unread-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 ((looking-at " recent,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (vm-set-new-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 ((looking-at " deleted,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (vm-set-deleted-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 ((looking-at " answered,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (vm-set-replied-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 ((looking-at " forwarded,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (vm-set-forwarded-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 ((looking-at " filed,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (vm-set-filed-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 ((looking-at " redistributed,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (vm-set-redistributed-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 ;; only VM knows about these, as far as I know.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 ((looking-at " edited,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (vm-set-forwarded-flag-of message t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 ((looking-at " written,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (vm-set-forwarded-flag-of message t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (skip-chars-forward "^,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (and (not (eobp)) (forward-char 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (and (not (eobp)) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (while (looking-at " \\([^\000-\040,\177-\377]+\\),")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (setq labels (cons (vm-buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 labels))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (goto-char (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (vm-set-labels-of message labels))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (defun vm-set-default-attributes (message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (let ((mp (or message-list vm-message-list)) attr cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (setq attr (make-vector vm-attributes-vector-length nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 cache (make-vector vm-cache-vector-length nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (vm-set-cache-of (car mp) cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (vm-set-attributes-of (car mp) attr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 ;; make message be new by default, but avoid vm-set-new-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 ;; because it asks for a summary update for the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (vm-set-new-flag-of (car mp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 ;; since this function is usually called in lieu of reading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 ;; attributes from the buffer, the attributes may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 ;; untrustworthy. tink the message modflag to force the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 ;; new attributes out if the user saves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (vm-set-modflag-of (car mp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (setq mp (cdr mp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (defun vm-emit-totals-blurb ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (if (not (equal (nth 0 vm-totals) vm-modification-counter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (let ((mp vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (vm-new-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (vm-unread-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (vm-deleted-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (vm-total-count 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (vm-increment vm-total-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (cond ((vm-deleted-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (vm-increment vm-deleted-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 ((vm-new-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (vm-increment vm-new-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 ((vm-unread-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (vm-increment vm-unread-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (setq mp (cdr mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (setq vm-totals (list vm-modification-counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 vm-total-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 vm-new-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 vm-unread-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 vm-deleted-count))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (if (equal (nth 1 vm-totals) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (message "No messages.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (message "%d message%s, %d new, %d unread, %d deleted"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (nth 1 vm-totals) (if (= (nth 1 vm-totals) 1) "" "s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (nth 2 vm-totals)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (nth 3 vm-totals)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (nth 4 vm-totals)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (defun vm-convert-v4-attributes (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (list (apply 'vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (nconc (vm-vector-to-list data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (make-list (- vm-attributes-vector-length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (length data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (make-vector vm-cache-vector-length nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (defun vm-gobble-labels ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (if (eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (if (re-search-forward "^Labels:" lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (let (string list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (setq string (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (progn (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 list (vm-parse string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 "[\000-\040,\177-\377]*\\([^\000-\040,\177-\377]+\\)[\000-\040,\177-\377]*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (intern (downcase s) vm-label-obarray)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (if (re-search-forward vm-labels-header-regexp lim t)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1420 (let ((oldpoint (point))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1421 list)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1422 (condition-case ()
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1423 (progn
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1424 (setq list (read (current-buffer)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1425 (if (not (listp list))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1426 (error "Bad global label list at %d in buffer %s"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1427 oldpoint (buffer-name)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1428 list )
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1429 (error
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1430 (message "Bad global label list at %d in buffer %s, ignoring"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1431 oldpoint (buffer-name))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1432 (setq list nil) ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (intern s vm-label-obarray)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 t ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 ;; Go to the message specified in a bookmark and eat the bookmark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 ;; Returns non-nil if successful, nil otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (defun vm-gobble-bookmark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (let ((case-fold-search t)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1443 (n nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1444 lim oldpoint)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (if (re-search-forward vm-bookmark-header-regexp lim t)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1457 (condition-case ()
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1458 (progn
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1459 (setq oldpoint (point)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1460 n (read (current-buffer)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1461 (if (not (natnump n))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1462 (error "Bad bookmark at %d in buffer %s"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1463 oldpoint (buffer-name)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1464 n )
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1465 (error
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1466 (message "Bad bookmark at %d in buffer %s, ignoring"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1467 oldpoint (buffer-name))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1468 (setq n 1))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (if n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (vm-record-and-change-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (nthcdr (1- n) vm-message-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 t ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (defun vm-gobble-visible-header-variables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (if (re-search-forward vm-vheader-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (let (vis invis (got nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (setq vis (read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 invis (read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 got t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 ;; if the variables don't match the values stored when this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 ;; folder was saved, then we have to discard any cached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;; vheader info so the user will see the right headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (and got (or (not (equal vis vm-visible-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (not (equal invis vm-invisible-header-regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (let ((mp vm-message-list))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
1502 (message "Discarding visible header info...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (vm-set-vheaders-regexp-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (vm-set-vheaders-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (setq mp (cdr mp)))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 ;; Read and delete the header that gives the folder's desired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;; message order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (defun vm-gobble-message-order ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 lim v order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (mp vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 list-length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (setq lim (point))
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 (if (re-search-forward vm-message-order-header-regexp lim t)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1527 (let ((oldpoint (point)))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
1528 (message "Reordering messages...")
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1529 (condition-case nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1530 (progn
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1531 (setq order (read (current-buffer)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1532 (if (not (listp order))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1533 (error "Bad order header at %d in buffer %s"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1534 oldpoint (buffer-name)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1535 order )
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1536 (error
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1537 (message "Bad order header at %d in buffer %s, ignoring"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1538 oldpoint (buffer-name))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1539 (setq order nil)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1540 (setq list-length (length vm-message-list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 v (make-vector (max list-length (length order)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (while (and order mp)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1543 (condition-case nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1544 (aset v (1- (car order)) (car mp))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1545 (args-out-of-range nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (setq order (cdr order) mp (cdr mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 ;; lock out interrupts while the message list is in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 ;; an inconsistent state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (setq vm-message-list (delq nil (append v mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 vm-message-order-changed nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 vm-message-order-header-present t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 vm-message-pointer (memq (car vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (vm-set-numbering-redo-start-point t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (vm-reverse-link-messages))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
1557 (message "Reordering messages... done")))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 ;; Read the header that gives the folder's cached summary format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 ;; If the current summary format is different, then the cached
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 ;; summary lines are discarded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (defun vm-gobble-summary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 summary lim
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (mp vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (if (re-search-forward vm-summary-header-regexp lim t)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1578 (let ((oldpoint (point)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1579 (condition-case ()
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1580 (setq summary (read (current-buffer)))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1581 (error
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1582 (message "Bad summary header at %d in buffer %s, ignoring"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1583 oldpoint (buffer-name))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1584 (setq summary "")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (if (not (equal summary vm-summary-format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (vm-set-summary-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 ;; force restuffing of cache to clear old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 ;; summary entry cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (vm-set-modflag-of (car mp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (setq mp (cdr mp))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 ;; Stuff the message attributes back into the message as headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (defun vm-stuff-attributes (m &optional for-other-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 attributes cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 opoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (delflag (vm-deleted-flag m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 ;; don't put this folder's summary entry into another folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (if for-other-folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (vm-set-summary-of m nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (if (vm-su-start-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 ;; fill the summary cache if it's not done already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (vm-su-summary m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (setq attributes (vm-attributes-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 cache (vm-cache-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (and delflag for-other-folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (vm-set-deleted-flag-in-vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (setq attributes (copy-sequence attributes)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (if (eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (vm-stuff-babyl-attributes m for-other-folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (goto-char (vm-headers-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (while (re-search-forward vm-attributes-header-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (vm-text-of m) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (delete-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (goto-char (vm-headers-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (setq opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (insert-before-markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 vm-attributes-header " ("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 (let ((print-escape-newlines t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 (prin1-to-string attributes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 "\n\t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (let ((print-escape-newlines t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (prin1-to-string cache))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 "\n\t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (let ((print-escape-newlines t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (prin1-to-string (vm-labels-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 ")\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (set-marker (vm-headers-of m) opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (cond ((and (eq vm-folder-type 'From_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 vm-berkeley-mail-compatibility)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (goto-char (vm-headers-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 vm-berkeley-mail-status-header-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (vm-text-of m) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (delete-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (goto-char (vm-headers-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (cond ((not (vm-new-flag m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (insert-before-markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 vm-berkeley-mail-status-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (if (vm-unread-flag m) "" "R")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 "O\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (set-marker (vm-headers-of m) opoint)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (vm-set-modflag-of m nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1660 (defun vm-stuff-folder-attributes (&optional abort-if-input-pending)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1661 (let ((newlist nil) mp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1662 ;; stuff the attributes of messages that need it.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1663 ;; build a list of messages that need their attributes stuffed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1664 (setq mp vm-message-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1665 (while mp
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1666 (if (vm-modflag-of (car mp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1667 (setq newlist (cons (car mp) newlist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1668 (setq mp (cdr mp)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1669 ;; now sort the list by physical order so that we
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1670 ;; reduce the amount of gap motion induced by modifying
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1671 ;; the buffer. what we want to avoid is updating
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1672 ;; message 3, then 234, then 10, then 500, thus causing
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1673 ;; large chunks of memory to be copied repeatedly as
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1674 ;; the gap moves to accomodate the insertions.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1675 (let ((vm-key-functions '(vm-sort-compare-physical-order-r)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1676 (setq mp (sort newlist 'vm-sort-compare-xxxxxx)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1677 (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
1678 (vm-stuff-attributes (car mp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1679 (setq mp (cdr mp)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1680 (if mp nil t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
1681
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 ;; 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
1683 ;; from within vm-stuff-attributes. we don't worry about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 ;; restoring the modified flag, setting buffer-read-only, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 ;; about not moving point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (defun vm-stuff-babyl-attributes (m for-other-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (goto-char (vm-start-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (if (vm-babyl-frob-flag-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (insert "1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (insert "0"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (if (looking-at "\\( [^\000-\040,\177-\377]+,\\)+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (delete-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (if (vm-new-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (insert " recent, unseen,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (if (vm-unread-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (insert " unseen,")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (if (and (not for-other-folder) (vm-deleted-flag m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (insert " deleted,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (if (vm-replied-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (insert " answered,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (if (vm-forwarded-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (insert " forwarded,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (if (vm-redistributed-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (insert " redistributed,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (if (vm-filed-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (insert " filed,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (if (vm-edited-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (insert " edited,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (if (vm-written-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (insert " written,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (if (looking-at "\\( [^\000-\040,\177-\377]+,\\)+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (delete-region (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (mapcar (function (lambda (label) (insert " " label ",")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (vm-labels-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 (defun vm-babyl-attributes-string (m for-other-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (if (vm-new-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 " recent, unseen,"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (if (vm-unread-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 " unseen,"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (if (and (not for-other-folder) (vm-deleted-flag m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 " deleted,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (if (vm-replied-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 " answered,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (if (vm-forwarded-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 " forwarded,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 (if (vm-redistributed-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 " redistributed,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (if (vm-filed-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 " filed,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (if (vm-edited-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 " edited,")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (if (vm-written-flag m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 " written,")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (defun vm-babyl-labels-string (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (let ((list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (labels (vm-labels-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (while labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (setq list (cons "," (cons (car labels) (cons " " list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 labels (cdr labels)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (apply 'concat (nreverse list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (defun vm-stuff-virtual-attributes (message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (let ((virtual (vm-virtual-message-p message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (if (or (not virtual) (and virtual (vm-virtual-messages-of message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (vm-buffer-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (vm-real-message-of message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (vm-stuff-attributes (vm-real-message-of message))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (defun vm-stuff-labels ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (if (eq vm-folder-type 'babyl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (delete-region (point) (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (insert-before-markers (vm-folder-header vm-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 vm-label-obarray))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (while (re-search-forward vm-labels-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (if (vm-match-header vm-labels-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 ;; To insert or to insert-before-markers, that is the question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 ;; If we insert-before-markers we push a header behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 ;; vm-headers-of, which is clearly undesirable. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ;; just insert. This will cause the summary header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 ;; to be visible if there are no non-visible headers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 ;; oh well, no way around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (insert vm-labels-header " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 (let ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (mapatoms (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (lambda (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (setq list (cons (symbol-name sym) list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 vm-label-obarray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (prin1-to-string list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 ;; Insert a bookmark into the first message in the folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (defun vm-stuff-bookmark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 (if (re-search-forward vm-bookmark-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (if (vm-match-header vm-bookmark-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 ;; To insert or to insert-before-markers, that is the question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 ;; If we insert-before-markers we push a header behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 ;; vm-headers-of, which is clearly undesirable. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 ;; just insert. This will cause the bookmark header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 ;; to be visible if there are no non-visible headers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 ;; oh well, no way around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (insert vm-bookmark-header " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (vm-number-of (car vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 ;; Insert the summary format variable header into the first message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (defun vm-stuff-summary ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 lim)
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 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (while (re-search-forward vm-summary-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (if (vm-match-header vm-summary-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 ;; To insert or to insert-before-markers, that is the question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 ;; If we insert-before-markers we push a header behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 ;; vm-headers-of, which is clearly undesirable. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 ;; just insert. This will cause the summary header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 ;; to be visible if there are no non-visible headers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 ;; oh well, no way around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (insert vm-summary-header " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (let ((print-escape-newlines t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (prin1-to-string vm-summary-format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 ;; stuff the current values of the header variables for future messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (defun vm-stuff-header-variables ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 lim
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (buffer-file-name nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (while (re-search-forward vm-vheader-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (if (vm-match-header vm-vheader-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 ;; To insert or to insert-before-markers, that is the question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 ;; If we insert-before-markers we push a header behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 ;; vm-headers-of, which is clearly undesirable. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 ;; just insert. This header will be visible if there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 ;; are no non-visible headers, oh well, no way around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (insert vm-vheader-header " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (prin1-to-string vm-visible-headers) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (prin1-to-string vm-invisible-header-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 ;; Insert a header into the first message of the folder that lists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 ;; the folder's message order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 (defun vm-stuff-message-order ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 (if (cdr vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 lim n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (mp (copy-sequence vm-message-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (setq mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (sort mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 (lambda (p q)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (< (vm-start-of p) (vm-start-of q))))))
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-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (vm-find-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (while (re-search-forward vm-message-order-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (if (vm-match-header vm-message-order-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 ;; To insert or to insert-before-markers, that is the question.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 ;; If we insert-before-markers we push a header behind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 ;; vm-headers-of, which is clearly undesirable. So we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 ;; just insert. This header will be visible if there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 ;; are no non-visible headers, oh well, no way around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (insert vm-message-order-header "\n\t(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (setq n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (insert (vm-number-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 (setq n (1+ n) mp (cdr mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 (and mp (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (if (zerop (% n 15))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 "\n\t "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 " "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (insert ")\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (setq vm-message-order-changed nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 vm-message-order-header-present t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 ;; Remove the message order header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (defun vm-remove-message-order ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (if (cdr vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (let ((old-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 lim
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 ;; This prevents file locking from occuring. Disabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 ;; locking can speed things noticeably if the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 ;; directory is on a slow device. We don't need locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 ;; here because the user shouldn't care about VM stuffing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 ;; its own status headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (setq lim (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (vm-skip-past-folder-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 (vm-skip-past-leading-message-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 (while (re-search-forward vm-message-order-header-regexp lim t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 (progn (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 (if (vm-match-header vm-message-order-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (delete-region (vm-matched-header-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 (vm-matched-header-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 (setq vm-message-order-header-present nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 (set-buffer-modified-p old-buffer-modified-p))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 (defun vm-change-all-new-to-unread ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (let ((mp vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 (if (vm-new-flag (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (vm-set-new-flag (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 (vm-set-unread-flag (car mp) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 (setq mp (cdr mp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (defun vm-unread-message (&optional count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 "Set the `unread' attribute for the current message. If the message is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 already new or unread, then it is left unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 Numeric prefix argument N means to unread the current message plus the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 next N-1 messages. A negative N means unread the current message and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 the previous N-1 messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 When invoked on marked messages (via vm-next-command-uses-marks),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 all marked messages are affected, other messages are ignored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (or count (setq count 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (vm-follow-summary-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 (let ((mlist (vm-select-marked-or-prefixed-messages count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 (while mlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 (if (and (not (vm-unread-flag (car mlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 (not (vm-new-flag (car mlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (vm-set-unread-flag (car mlist) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 (setq mlist (cdr mlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 (vm-display nil nil '(vm-unread-message) '(vm-unread-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 (defun vm-quit-just-bury ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 "Bury the current VM folder and summary buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 The folder is not altered and Emacs is still visiting it. You
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 can switch back to it with switch-to-buffer or by using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 Buffer Menu."
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-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (if (not (memq major-mode '(vm-mode vm-virtual-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (error "%s must be invoked from a VM buffer." this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 (vm-check-for-killed-summary)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2078 (vm-check-for-killed-presentation)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2080 (save-excursion (run-hooks 'vm-quit-hook))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2081
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2082 (vm-garbage-collect-message)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (vm-display nil nil '(vm-quit-just-bury)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 '(vm-quit-just-bury quitting))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 (if vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (vm-display vm-summary-buffer nil nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 (if vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (vm-bury-buffer vm-summary-buffer))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2090 (if vm-presentation-buffer-handle
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2091 (vm-display vm-presentation-buffer-handle nil nil nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2092 (if vm-presentation-buffer-handle
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2093 (vm-bury-buffer vm-presentation-buffer-handle))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 (vm-display (current-buffer) nil nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 (vm-bury-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (defun vm-quit-just-iconify ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 "Iconify the frame and bury the current VM folder and summary buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 The folder is not altered and Emacs is still visiting it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (if (not (memq major-mode '(vm-mode vm-virtual-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 (error "%s must be invoked from a VM buffer." this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (vm-check-for-killed-summary)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2105 (vm-check-for-killed-presentation)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2107 (save-excursion (run-hooks 'vm-quit-hook))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2108
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2109 (vm-garbage-collect-message)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (vm-display nil nil '(vm-quit-just-iconify)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 '(vm-quit-just-iconify quitting))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2113 (let ((summary-buffer vm-summary-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2114 (pres-buffer vm-presentation-buffer-handle))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2115 (vm-bury-buffer (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2116 (if summary-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2117 (vm-bury-buffer summary-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2118 (if pres-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2119 (vm-bury-buffer pres-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2120 (vm-iconify-frame)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (defun vm-quit-no-change ()
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
2123 "Quit visiting the current folder without saving changes made to the folder."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 (vm-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 (defun vm-quit (&optional no-change)
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
2128 "Quit visiting the current folder, saving changes. Deleted messages are not expunged."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 (if (not (memq major-mode '(vm-mode vm-virtual-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 (error "%s must be invoked from a VM buffer." this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (vm-check-for-killed-summary)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2134 (vm-check-for-killed-presentation)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 (vm-display nil nil '(vm-quit vm-quit-no-change)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 (list this-command 'quitting))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (let ((virtual (eq major-mode 'vm-virtual-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 ((and (not virtual) no-change (buffer-modified-p)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2140 (or buffer-file-name buffer-offer-save)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 (not (zerop vm-messages-not-on-disk))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 ;; 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
2143 ;; been changed after that; in that case vm-messages-not-on-disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 ;; would not have been zeroed. However, all modification flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 ;; undos are cleared if VM actually modifies the folder buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 ;; (as opposed to the folder's attributes), so this can be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 ;; to verify that there are indeed unsaved messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (null (assq 'vm-set-buffer-modified-p vm-undo-record-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 "%d message%s have not been saved to disk, quit anyway? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 vm-messages-not-on-disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 (if (= 1 vm-messages-not-on-disk) "" "s")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (error "Aborted"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 ((and (not virtual)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2157 no-change
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2158 (or buffer-file-name buffer-offer-save)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2159 (buffer-modified-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2160 vm-confirm-quit
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (not (y-or-n-p "There are unsaved changes, quit anyway? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (error "Aborted"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 ((and (eq vm-confirm-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (not (y-or-n-p "Do you really want to quit? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (error "Aborted")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2167 (save-excursion (run-hooks 'vm-quit-hook))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2168
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2169 (vm-garbage-collect-message)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2170 (vm-garbage-collect-folder)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (vm-virtual-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 (if (and (not no-change) (not virtual))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 ;; this could take a while, so give the user some feedback
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2176 (message "Quitting...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 (or vm-folder-read-only (eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 (vm-change-all-new-to-unread))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2179 (if (and (buffer-modified-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2180 (or buffer-file-name buffer-offer-save)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2181 (not no-change)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2182 (not virtual))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (vm-save-folder))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2184 (message "")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (let ((summary-buffer vm-summary-buffer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2186 (pres-buffer vm-presentation-buffer-handle)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 (mail-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (if summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (progn
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2190 (vm-display summary-buffer nil nil nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (kill-buffer summary-buffer)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2192 (if pres-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2193 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2194 (vm-display pres-buffer nil nil nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2195 (kill-buffer pres-buffer)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (set-buffer mail-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (vm-display mail-buffer nil nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 ;; vm-display is not supposed to change the current buffer.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2199 ;; still it's better to be safe here.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 (set-buffer mail-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (vm-update-summary-and-mode-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (defun vm-start-itimers-if-needed ()
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2206 (cond ((and (not (natnump vm-flush-interval))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2207 (not (natnump vm-auto-get-new-mail))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2208 (not (natnump vm-mail-check-interval))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2209 ((condition-case data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2210 (progn (require 'itimer) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2211 (error nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2212 (and (natnump vm-flush-interval) (not (get-itimer "vm-flush"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2213 (start-itimer "vm-flush" 'vm-flush-itimer-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2214 vm-flush-interval nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2215 (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
2216 (start-itimer "vm-get-mail" 'vm-get-mail-itimer-function
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2217 vm-auto-get-new-mail nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2218 (and (natnump vm-mail-check-interval)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2219 (not (get-itimer "vm-check-mail"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2220 (start-itimer "vm-check-mail" 'vm-check-mail-itimer-function
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2221 vm-mail-check-interval nil)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2222 ((condition-case data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2223 (progn (require 'timer) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2224 (error nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2225 (let (timer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2226 (and (natnump vm-flush-interval)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2227 (not (vm-timer-using 'vm-flush-itimer-function))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2228 (setq timer (run-at-time vm-flush-interval vm-flush-interval
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2229 'vm-flush-itimer-function nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2230 (timer-set-function timer 'vm-flush-itimer-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2231 (list timer)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2232 (and (natnump vm-mail-check-interval)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2233 (not (vm-timer-using 'vm-check-mail-itimer-function))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2234 (setq timer (run-at-time vm-mail-check-interval
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2235 vm-mail-check-interval
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2236 'vm-check-mail-itimer-function nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2237 (timer-set-function timer 'vm-check-mail-itimer-function
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2238 (list timer)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2239 (and (natnump vm-auto-get-new-mail)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2240 (not (vm-timer-using 'vm-get-mail-itimer-function))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2241 (setq timer (run-at-time vm-auto-get-new-mail
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2242 vm-auto-get-new-mail
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2243 'vm-get-mail-itimer-function nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2244 (timer-set-function timer 'vm-get-mail-itimer-function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2245 (list timer)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2246 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2247 (setq vm-flush-interval t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2248 vm-auto-get-new-mail t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2250 (defun vm-timer-using (fun)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2251 (let ((p timer-list)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2252 (done nil))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2253 (while (and p (not done))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2254 (if (eq (aref (car p) 5) fun)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2255 (setq done t)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2256 (setq p (cdr p))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2257 p ))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2258
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2259 ;; support for vm-mail-check-interval
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2260 ;; if timer argument is present, this means we're using the Emacs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2261 ;; 'timer package rather than the 'itimer package.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2262 (defun vm-check-mail-itimer-function (&optional timer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2263 ;; FSF Emacs sets this non-nil, which means the user can't
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2264 ;; interrupt the check. Bogus.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2265 (setq inhibit-quit nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2266 (if (integerp vm-mail-check-interval)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2267 (if timer
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2268 (timer-set-time timer (current-time) vm-mail-check-interval)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2269 (set-itimer-restart current-itimer vm-mail-check-interval))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2270 ;; user has changed the variable value to something that
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2271 ;; isn't a number, make the timer go away.
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2272 (if timer
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2273 (cancel-timer timer)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2274 (set-itimer-restart current-itimer nil)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2275 (let ((b-list (buffer-list))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2276 (found-one nil)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2277 oldval)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2278 (while (and (not (input-pending-p)) b-list)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2279 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2280 (set-buffer (car b-list))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2281 (if (and (eq major-mode 'vm-mode)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2282 (setq found-one t)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2283 ;; to avoid reentrance into the pop code
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2284 (not vm-block-new-mail)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2285 ;; Don't bother checking if we already know from
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2286 ;; a previous check that there's mail waiting
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2287 ;; and the user hasn't retrieved it yet. Not
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2288 ;; completely accurate, but saves network
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2289 ;; connection build and tear down which is slow
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2290 ;; for some users.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2291 (not vm-spooled-mail-waiting))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2292 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2293 (setq oldval vm-spooled-mail-waiting)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2294 (vm-check-for-spooled-mail nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2295 (if (not (eq oldval vm-spooled-mail-waiting))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2296 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2297 (intern (buffer-name) vm-buffers-needing-display-update)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2298 (vm-update-summary-and-mode-line))))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2299 (setq b-list (cdr b-list)))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2300 ;; 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
2301 (if (and (not found-one) (null b-list))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2302 (if timer
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2303 (cancel-timer timer)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2304 (set-itimer-restart current-itimer nil)))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2305
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
2306 ;; support for numeric vm-auto-get-new-mail
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2307 ;; if timer argument is present, this means we're using the Emacs
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2308 ;; 'timer package rather than the 'itimer package.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2309 (defun vm-get-mail-itimer-function (&optional timer)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2310 ;; FSF Emacs sets this non-nil, which means the user can't
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2311 ;; interrupt mail retrieval. Bogus.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2312 (setq inhibit-quit nil)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
2313 (if (integerp vm-auto-get-new-mail)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2314 (if timer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2315 (timer-set-time timer (current-time) vm-auto-get-new-mail)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2316 (set-itimer-restart current-itimer vm-auto-get-new-mail))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2317 ;; user has changed the variable value to something that
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2318 ;; isn't a number, make the timer go away.
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2319 (if timer
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2320 (cancel-timer timer)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2321 (set-itimer-restart current-itimer nil)))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2322 (let ((b-list (buffer-list))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2323 (found-one nil))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2324 (while (and (not (input-pending-p)) b-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2325 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2326 (set-buffer (car b-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2327 (if (and (eq major-mode 'vm-mode)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2328 (setq found-one t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 (not (and (not (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 (file-newer-than-file-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (make-auto-save-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 (not vm-block-new-mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 (not vm-folder-read-only)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2336 (vm-get-spooled-mail nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (vm-assimilate-new-messages t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 ;; don't move the message pointer unless the folder
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 ;; was empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 (if (and (null vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 (vm-thoughtfully-select-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 (vm-preview-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 (vm-update-summary-and-mode-line)))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2345 (setq b-list (cdr b-list)))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2346 ;; 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
2347 (if (and (not found-one) (null b-list))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2348 (if timer
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2349 (cancel-timer timer)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2350 (set-itimer-restart current-itimer nil)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 ;; support for numeric vm-flush-interval
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2353 ;; if timer argument is present, this means we're using the Emacs
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2354 ;; 'timer package rather than the 'itimer package.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2355 (defun vm-flush-itimer-function (&optional timer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 (if (integerp vm-flush-interval)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2357 (if timer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2358 (timer-set-time timer (current-time) vm-flush-interval)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2359 (set-itimer-restart current-itimer vm-flush-interval)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 ;; 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
2361 ;; flush itimer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 (if (not (vm-flush-cached-data))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2363 (if timer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2364 (cancel-timer timer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2365 (set-itimer-restart current-itimer nil))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 ;; flush cached data in all vm-mode buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 ;; returns non-nil if any vm-mode buffers were found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 (defun vm-flush-cached-data ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 (let ((buf-list (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 (found-one nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 (while (and buf-list (not (input-pending-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 (set-buffer (car buf-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 (cond ((and (eq major-mode 'vm-mode) vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 (setq found-one t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 (if (not (eq vm-modification-counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 vm-flushed-modification-counter))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2379 (progn
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 (vm-stuff-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 (vm-stuff-labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 (and vm-message-order-changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (vm-stuff-message-order))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2384 (and (vm-stuff-folder-attributes t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 (setq vm-flushed-modification-counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 vm-modification-counter))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 (setq buf-list (cdr buf-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 ;; if we haven't checked them all return non-nil so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 ;; the flusher won't give up trying.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 (or buf-list found-one) )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 ;; 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
2393 ;; Note that deleted messages are not expunged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 (defun vm-write-file-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 (if (and (eq major-mode 'vm-mode) (not vm-inhibit-write-file-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 ;; The vm-save-restriction isn't really necessary here, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 ;; the stuff routines clean up after themselves, but should remain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 ;; as a safeguard against the time when other stuff is added here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 (vm-save-restriction
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2400 (let ((buffer-read-only))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2401 (vm-stuff-folder-attributes nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2402 (if vm-message-list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2403 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2404 ;; get summary cache up-to-date
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2405 (vm-update-summary-and-mode-line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2406 (vm-stuff-bookmark)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2407 (vm-stuff-header-variables)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2408 (vm-stuff-labels)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2409 (vm-stuff-summary)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2410 (and vm-message-order-changed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2411 (vm-stuff-message-order))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2412 nil ))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 (defun vm-save-buffer (prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 (vm-error-if-virtual-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 (save-buffer prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 (setq vm-block-new-mail nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 (vm-display nil nil '(vm-save-buffer) '(vm-save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 (vm-update-summary-and-mode-line))
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-write-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 (vm-error-if-virtual-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 (call-interactively 'write-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 (setq vm-block-new-mail nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 (vm-display nil nil '(vm-write-file) '(vm-write-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 (defun vm-save-folder (&optional prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 "Save current folder to disk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 Deleted messages are not expunged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 Prefix arg is handled the same as for the command save-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 When applied to a virtual folder, this command runs itself on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 each of the underlying real folders associated with the virtual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 folder."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 (interactive (list current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 (vm-display nil nil '(vm-save-folder) '(vm-save-folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 (if (eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 (vm-virtual-save-folder prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 (if (buffer-modified-p)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2449 (let (mp (newlist nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 ;; stuff the attributes of messages that need it.
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2451 (message "Stuffing attributes...")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2452 (vm-stuff-folder-attributes nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 ;; stuff bookmark and header variable values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 (if vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 ;; get summary cache up-to-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 (vm-stuff-bookmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 (vm-stuff-header-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 (vm-stuff-labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (vm-stuff-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (and vm-message-order-changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 (vm-stuff-message-order))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2464 (message "Saving...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 (let ((vm-inhibit-write-file-hook t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 (save-buffer prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 (vm-set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 (vm-clear-modification-flag-undos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (setq vm-messages-not-on-disk 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 (setq vm-block-new-mail nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (and (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 vm-delete-empty-folders
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (or (eq vm-delete-empty-folders t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (y-or-n-p (format "%s is empty, remove it? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 (or buffer-file-name (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 (delete-file buffer-file-name)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2480 (clear-visited-file-modtime)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (message "%s removed" buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 ;; no can do, oh well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (message "No changes need to be saved"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 (defun vm-save-and-expunge-folder (&optional prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 "Expunge folder, then save it to disk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 Prefix arg is handled the same as for the command save-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 Expunge won't be done if folder is read-only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 When applied to a virtual folder, this command works as if you had
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 run vm-expunge-folder followed by vm-save-folder."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 (interactive (list current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 (vm-display nil nil '(vm-save-and-expunge-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 '(vm-save-and-expunge-folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 (if (not vm-folder-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 (progn
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2501 (message "Expunging...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 (vm-expunge-folder t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (vm-save-folder prefix))
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-handle-file-recovery-or-reversion (recovery)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (if (and vm-summary-buffer (buffer-name vm-summary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (kill-buffer vm-summary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 (vm-virtual-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 ;; reset major mode, this will cause vm to start from scratch.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 (setq major-mode 'fundamental-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 ;; 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
2512 ;; mail until a real save is performed. Until then the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 ;; and the disk don't match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 (if recovery
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 (setq vm-block-new-mail t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 (vm buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 ;; detect if a recover-file is being performed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 ;; and handle things properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 (defun vm-handle-file-recovery ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 (eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 (= (vm-end-of (car vm-message-list)) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 (vm-handle-file-recovery-or-reversion t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 ;; detect if a revert-buffer is being performed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 ;; and handle things properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (defun vm-handle-file-reversion ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 (if (and (not (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 (eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 (= (vm-end-of (car vm-message-list)) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 (vm-handle-file-recovery-or-reversion nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 ;; FSF v19.23 revert-buffer doesn't mash all the markers together
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 ;; like v18 and prior v19 versions, so the check in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 ;; vm-handle-file-reversion doesn't work. However v19.23 has a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 ;; hook we can use, after-revert-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (defun vm-after-revert-buffer-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 (if (eq major-mode 'vm-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (vm-handle-file-recovery-or-reversion nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 (defun vm-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 "Display help for various VM activities."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 (if (eq major-mode 'vm-summary-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 (vm-select-folder-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 (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
2550 (pop-up-frames vm-mutable-frames))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 ((eq last-command 'vm-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 (describe-function major-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 ((eq vm-system-state 'previewing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 (message "Type SPC to read message, n previews next message (? gives more help)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 ((memq vm-system-state '(showing reading))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 (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
2558 ((eq vm-system-state 'editing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 "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
2562 ((eq major-mode 'mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 (substitute-command-keys
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 54
diff changeset
2565 "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
2566 (t (describe-mode)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 (defun vm-spool-move-mail (source destination)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (let ((handler (and (fboundp 'find-file-name-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 (find-file-name-handler source 'vm-spool-move-mail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 (wrong-number-of-arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 (find-file-name-handler source)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 status error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 (if handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 (funcall handler 'vm-spool-move-mail source destination)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 (setq error-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 (format "*output of %s %s %s*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 vm-movemail-program source destination)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 (set-buffer error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 (setq status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 (call-process vm-movemail-program nil error-buffer t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 source destination))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 (set-buffer error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 (if (and (numberp status) (not (= 0 status)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 (insert (format "\n%s exited with code %s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 vm-movemail-program status)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 (if (> (buffer-size) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (vm-display-buffer error-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (if (and (numberp status) (not (= 0 status)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (error "Failed getting new mail from %s" source)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 (message "Warning: unexpected output from %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 vm-movemail-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (sleep-for 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 ;; nag, nag, nag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 (kill-buffer error-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 t ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 (defun vm-gobble-crash-box (crash-box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (vm-save-restriction
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 (let ((opoint-max (point-max)) crash-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (inbox-buffer-file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 (inbox-folder-type vm-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 (inbox-empty (zerop (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 got-mail crash-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 (old-buffer-modified-p (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (setq crash-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 ;; crash box could contain a letter bomb...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 ;; force user notification of file variables for v18 Emacses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 ;; enable-local-variables == nil disables them for newer Emacses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 (let ((inhibit-local-variables t)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2620 (enable-local-variables nil)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2621 (coding-system-for-read 'no-conversion))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 (find-file-noselect crash-box)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 (set-buffer crash-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (setq crash-folder-type (vm-get-folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 (if (and crash-folder-type vm-check-folder-types)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (cond ((eq crash-folder-type 'unknown)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 (error "crash box %s's type is unrecognized" crash-box))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 ((eq inbox-folder-type 'unknown)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 (error "inbox %s's type is unrecognized"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 inbox-buffer-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 ((null inbox-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 (if vm-default-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 (if (not (eq vm-default-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 crash-folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 (if vm-convert-folder-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 (vm-convert-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 crash-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 vm-default-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 ;; so that kill-buffer won't ask a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 ;; question later...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 (error "crash box %s mismatches vm-default-folder-type: %s, %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 crash-box crash-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 vm-default-folder-type)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 ((not (eq inbox-folder-type crash-folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 (if vm-convert-folder-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 (vm-convert-folder-type crash-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 inbox-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 ;; so that kill-buffer won't ask a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 ;; question later...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 (error "crash box %s mismatches %s's folder type: %s, %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 crash-box inbox-buffer-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 crash-folder-type inbox-folder-type)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 ;; toss the folder header if the inbox is not empty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 (if (not inbox-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 (vm-convert-folder-header (or inbox-folder-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 vm-default-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 (set-buffer-modified-p nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 (insert-buffer-substring crash-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 1 (1+ (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 (set-buffer crash-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 (buffer-size))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 (setq got-mail (/= opoint-max (point-max)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2673 (if (not got-mail)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2674 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2675 (write-region opoint-max (point-max) buffer-file-name t t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2676 (vm-increment vm-modification-counter)
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2677 (set-buffer-modified-p old-buffer-modified-p))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2678 (kill-buffer crash-buf)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2679 (if (not (stringp vm-keep-crash-boxes))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2680 (vm-error-free-call 'delete-file crash-box)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2681 (let ((time (decode-time (current-time)))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2682 name)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2683 (setq name
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2684 (expand-file-name (format "Z-%02d-%02d-%05d"
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2685 (nth 4 time)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2686 (nth 3 time)
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2687 (% (vm-abs (random)) 100000))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2688 vm-keep-crash-boxes))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2689 (while (file-exists-p name)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2690 (setq name
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2691 (expand-file-name (format "Z-%02d-%02d-%05d"
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2692 (nth 4 time)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2693 (nth 3 time)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 102
diff changeset
2694 (% (vm-abs (random)) 100000))
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2695 vm-keep-crash-boxes)))
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
2696 (rename-file crash-box name)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 got-mail ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2699 (defun vm-compute-spool-files ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2700 (let ((fallback-triples nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2701 triples)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2702 (cond ((and buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2703 (consp vm-spool-file-suffixes)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2704 (stringp vm-crash-box-suffix))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2705 (setq fallback-triples
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2706 (mapcar (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2707 (lambda (suffix)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2708 (list buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2709 (concat buffer-file-name suffix)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2710 (concat buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2711 vm-crash-box-suffix))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2712 vm-spool-file-suffixes))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2713 (cond ((and buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2714 vm-make-spool-file-name vm-make-crash-box-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2715 (setq fallback-triples
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2716 (nconc fallback-triples
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2717 (list (list buffer-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2718 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2719 (funcall vm-make-spool-file-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2720 buffer-file-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2721 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2722 (funcall vm-make-crash-box-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2723 buffer-file-name))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 (cond ((null (vm-spool-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 (setq triples (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 (list vm-primary-inbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 (concat vm-spool-directory (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 vm-crash-box))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 ((stringp (car (vm-spool-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 (setq triples
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 (lambda (s) (list vm-primary-inbox s vm-crash-box)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 (vm-spool-files))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 ((consp (car (vm-spool-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 (setq triples (vm-spool-files))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2736 (setq triples (append triples fallback-triples))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2737 triples ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2738
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2739 (defun vm-spool-check-mail (source)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2740 (let ((handler (and (fboundp 'find-file-name-handler)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2741 (condition-case ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2742 (find-file-name-handler source 'vm-spool-check-mail)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2743 (wrong-number-of-arguments
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2744 (find-file-name-handler source))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2745 (if handler
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2746 (funcall handler 'vm-spool-check-mail source)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2747 (and (not (equal 0 (nth 7 (file-attributes source))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2748 (file-readable-p source)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2749
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2750 (defun vm-check-for-spooled-mail (&optional interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2751 (if vm-block-new-mail
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2752 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2753 (let ((triples (vm-compute-spool-files))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2754 ;; since we could accept-process-output here (POP code),
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2755 ;; a timer process might try to start retrieving mail
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2756 ;; before we finish. block these attempts.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2757 (vm-block-new-mail t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2758 (vm-pop-ok-to-ask interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2759 (done nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2760 crash in maildrop popdrop
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2761 (mail-waiting nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2762 (while (and triples (not done))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2763 (setq in (expand-file-name (nth 0 (car triples)) vm-folder-directory)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2764 maildrop (nth 1 (car triples))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2765 crash (nth 2 (car triples)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2766 (if (eq (current-buffer) (vm-get-file-buffer in))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2767 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2768 (if (file-exists-p crash)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2769 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2770 (setq mail-waiting t
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2771 done t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2772 (setq popdrop (and vm-recognize-pop-maildrops
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2773 (string-match vm-recognize-pop-maildrops
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2774 maildrop)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2775 (if (not interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2776 ;; allow no error to be signaled
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2777 (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2778 (setq mail-waiting
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2779 (or mail-waiting
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2780 (if popdrop
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2781 (vm-pop-check-mail maildrop)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2782 (vm-spool-check-mail maildrop))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2783 (error nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2784 (setq mail-waiting (or mail-waiting
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2785 (if popdrop
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2786 (vm-pop-check-mail maildrop)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2787 (vm-spool-check-mail maildrop)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2788 (if mail-waiting
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2789 (setq done t)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2790 (setq triples (cdr triples)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2791 (setq vm-spooled-mail-waiting mail-waiting)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2792 mail-waiting )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2793
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2794 (defun vm-get-spooled-mail (&optional interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2795 (if vm-block-new-mail
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2796 (error "Can't get new mail until you save this folder."))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2797 (let ((triples (vm-compute-spool-files))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2798 ;; since we could accept-process-output here (POP code),
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2799 ;; a timer process might try to start retrieving mail
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2800 ;; before we finish. block these attempts.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2801 (vm-block-new-mail t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2802 (vm-pop-ok-to-ask interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2803 crash in maildrop popdrop
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2804 (got-mail nil))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2805 (if (and (not (verify-visited-file-modtime (current-buffer)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2806 (or (null interactive)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2807 (not (yes-or-no-p
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2808 (format
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2809 "Folder %s changed on disk, discard those changes? "
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2810 (buffer-name (current-buffer)))))))
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 (message "Folder %s changed on disk, consider M-x revert-buffer"
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2813 (buffer-name (current-buffer)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2814 (sleep-for 1)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2815 nil )
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2816 (while triples
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2817 (setq in (expand-file-name (nth 0 (car triples)) vm-folder-directory)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2818 maildrop (nth 1 (car triples))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2819 crash (nth 2 (car triples)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2820 (if (eq (current-buffer) (vm-get-file-buffer in))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2821 (let (retrieval-function)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2822 (if (file-exists-p crash)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2823 (progn
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2824 (message "Recovering messages from %s..." crash)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2825 (setq got-mail (or (vm-gobble-crash-box crash) got-mail))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2826 (message "Recovering messages from %s... done" crash)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2827 (setq popdrop (and vm-recognize-pop-maildrops
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2828 (string-match vm-recognize-pop-maildrops
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2829 maildrop)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2830 ;; maildrop with password clipped
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2831 (vm-safe-popdrop-string maildrop)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2832 (if (or popdrop
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2833 (and (not (equal 0 (nth 7 (file-attributes maildrop))))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2834 (file-readable-p maildrop)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2835 (progn
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2836 (setq crash (expand-file-name crash vm-folder-directory))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2837 (if (not popdrop)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2838 (setq maildrop (expand-file-name maildrop)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2839 retrieval-function 'vm-spool-move-mail)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2840 (setq retrieval-function 'vm-pop-move-mail))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2841 (if (if got-mail
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2842 ;; don't allow errors to be signaled unless no
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2843 ;; mail has been appended to the incore
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2844 ;; copy of the folder. otherwise the
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2845 ;; user will wonder where the mail is,
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2846 ;; since it is not in the crash box or
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2847 ;; the spool file and doesn't _appear_ to
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2848 ;; be in the folder either.
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2849 (condition-case error-data
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2850 (funcall retrieval-function maildrop crash)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2851 (error (message "%s signaled: %s"
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2852 (if popdrop
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2853 'vm-pop-move-mail
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2854 'vm-spool-move-mail)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2855 error-data)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2856 (sleep-for 2)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2857 ;; we don't know if mail was
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2858 ;; put into the crash box or
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2859 ;; not, so return t just to be
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2860 ;; safe.
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2861 t )
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2862 (quit (message "quitting from %s..."
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2863 (if popdrop
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2864 'vm-pop-move-mail
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2865 'vm-spool-move-mail))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2866 (sleep-for 1)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2867 ;; we don't know if mail was
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2868 ;; put into the crash box or
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2869 ;; not, so return t just to be
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2870 ;; safe.
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2871 t ))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2872 (funcall retrieval-function maildrop crash))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2873 (if (vm-gobble-crash-box crash)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2874 (progn
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2875 (setq got-mail t)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2876 (message "Got mail from %s."
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2877 (or popdrop maildrop)))))))))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2878 (setq triples (cdr triples)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2879 ;; not really correct, but it is what the user expects to see.
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2880 (if got-mail
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2881 (setq vm-spooled-mail-waiting nil))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2882 (intern (buffer-name) vm-buffers-needing-display-update)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2883 (vm-update-summary-and-mode-line)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2884 (if got-mail
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2885 (run-hooks 'vm-retrieved-spooled-mail-hook))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 108
diff changeset
2886 got-mail )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 (defun vm-safe-popdrop-string (drop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 (or (and (string-match "^\\([^:]+\\):[^:]+:[^:]+:\\([^:]+\\):[^:]+" drop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 (concat (substring drop (match-beginning 2) (match-end 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 "@"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 (substring drop (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 "???"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 (defun vm-get-new-mail (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 "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
2897 current folder into the folder. New mail is appended to the disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 and buffer copies of the folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 Prefix arg means to gather mail from a user specified folder, instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 the usual spool files. The file name will be read from the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 Unlike when getting mail from a spool file, the source file is left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 undisturbed after its messages have been copied.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 When applied to a virtual folder, this command runs itself on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 each of the underlying real folders associated with this virtual folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 A prefix argument has no effect; mail is always gathered from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 spool files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 (vm-error-if-folder-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 (cond ((eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 (vm-virtual-get-new-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 ((null arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 (if (not (eq major-mode 'vm-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 (vm-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 (if (consp (car (vm-spool-files)))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2919 (message "Checking for new mail for %s..."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 (or buffer-file-name (buffer-name)))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2921 (message "Checking for new mail..."))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 (let (totals-blurb)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2923 (if (and (vm-get-spooled-mail t) (vm-assimilate-new-messages t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 ;; say this NOW, before the non-previewers read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 ;; a message, alter the new message count and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 ;; confuse themselves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 (setq totals-blurb (vm-emit-totals-blurb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 (vm-display nil nil '(vm-get-new-mail) '(vm-get-new-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 (if (vm-thoughtfully-select-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 (vm-preview-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 (message totals-blurb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 (if (consp (car (vm-spool-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 (message "No new mail for %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 (or buffer-file-name (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 (message "No new mail."))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
2938 (and (interactive-p) (sit-for 4) (message "")))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 (let ((buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 folder mcount totals-blurb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 (setq folder (read-file-name "Gather mail from folder: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 vm-folder-directory t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 (if (and vm-check-folder-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 (not (vm-compatible-folder-p folder)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 (error "Folder %s is not the same format as this folder."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 folder))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 (goto-char (point-max))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2952 (let ((coding-system-for-read 'binary))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
2953 (insert-file-contents folder))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 (setq mcount (length vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 (if (vm-assimilate-new-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 ;; say this NOW, before the non-previewers read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 ;; a message, alter the new message count and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 ;; confuse themselves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 (setq totals-blurb (vm-emit-totals-blurb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 (vm-display nil nil '(vm-get-new-mail) '(vm-get-new-mail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 (if (vm-thoughtfully-select-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 (vm-preview-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 (message totals-blurb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 ;; The gathered messages are actually still on disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 ;; unless the user deletes the folder himself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 ;; However, users may not understand what happened if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 ;; the messages go away after a "quit, no save".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 (setq vm-messages-not-on-disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 (+ vm-messages-not-on-disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 (- (length vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 mcount))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 (message "No messages gathered."))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 ;; returns non-nil if there were any new messages
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2977 (defun vm-assimilate-new-messages (&optional
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2978 dont-read-attributes
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2979 gobble-order
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
2980 labels)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 (let ((tail-cons (vm-last vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 b-list new-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 (vm-build-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 (if (or (null tail-cons) (cdr tail-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 (setq vm-ml-sort-keys nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 (if dont-read-attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 (vm-set-default-attributes (cdr tail-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 (vm-read-attributes (cdr tail-cons)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 ;; Yuck. This has to be done here instead of in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 ;; vm function because this needs to be done before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 ;; any initial thread sort (so that if the thread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 ;; sort matches the saved order the folder won't be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 ;; modified) but after the message list is created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 ;; Since thread sorting is done here this has to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 ;; done here too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 (if gobble-order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 (vm-gobble-message-order))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 (if vm-thread-obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 (vm-build-threads (cdr tail-cons))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 (setq new-messages (if tail-cons (cdr tail-cons) vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 (vm-set-numbering-redo-start-point new-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 (vm-set-summary-redo-start-point new-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 ;; copy the new-messages list because sorting might scramble
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 ;; it. Also something the user does when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 ;; vm-arrived-message-hook is run might affect it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 ;; vm-assimilate-new-messages returns this value so it must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 ;; not be mangled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 (setq new-messages (copy-sequence new-messages))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3013 ;; add the labels
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3014 (if (and labels vm-burst-digest-messages-inherit-labels)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3015 (let ((mp new-messages))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3016 (while mp
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3017 (vm-set-labels-of (car mp) (copy-sequence labels))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3018 (setq mp (cdr mp)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 (if vm-summary-show-threads
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 ;; get numbering and summary of new messages done now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 ;; so that the sort code only has to worry about the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 ;; changes it needs to make.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 (vm-sort-messages "thread")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 (if (and vm-arrived-message-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 new-messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 ;; tail-cons == nil means vm-message-list was empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 ;; Thus new-messages == vm-message-list. In this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 ;; case, run the hooks only if this is not the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 ;; time vm-assimilate-new-messages has been called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 ;; in this folder. gobble-order non-nil is a good
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 ;; indicator that this is the first time because the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 ;; order is gobbled only once per visit and always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 ;; the first time vm-assimilate-new-messages is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036 ;; called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 (or tail-cons (null gobble-order)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 (let ((new-messages new-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 ;; seems wise to do this so that if the user runs VM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 ;; command here they start with as much of a clean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 ;; slate as we can provide, given we're currently deep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 ;; in the guts of VM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 (while new-messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 (vm-run-message-hook (car new-messages) 'vm-arrived-message-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 (setq new-messages (cdr new-messages)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 (run-hooks 'vm-arrived-messages-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 (if (and new-messages vm-virtual-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 (setq b-list vm-virtual-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 (while b-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 ;; buffer might be dead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 (if (buffer-name (car b-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 (let (tail-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 (set-buffer (car b-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 (setq tail-cons (vm-last vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 (vm-build-virtual-message-list new-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 (if (or (null tail-cons) (cdr tail-cons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 (setq vm-ml-sort-keys nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 (if vm-thread-obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 (vm-build-threads (cdr tail-cons)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 (vm-set-summary-redo-start-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 (or (cdr tail-cons) vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 (vm-set-numbering-redo-start-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 (or (cdr tail-cons) vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 (if (null vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 (progn (setq vm-message-pointer vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 vm-need-summary-pointer-update t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 (vm-preview-current-message))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 (if vm-summary-show-threads
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 (vm-sort-messages "thread")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 (setq b-list (cdr b-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 new-messages ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 ;; return a list of all marked messages or the messages indicated by a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 ;; prefix argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 (defun vm-select-marked-or-prefixed-messages (prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 (let (mlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 (if (eq last-command 'vm-next-command-uses-marks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 (setq mlist (vm-marked-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 (let ((direction (if (< prefix 0) 'backward 'forward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 (count (vm-abs prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 (vm-message-pointer vm-message-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 (if (not (eq vm-circular-folders t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 (vm-check-count prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 (while (not (zerop count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 (setq mlist (cons (car vm-message-pointer) mlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 (vm-decrement count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 (if (not (zerop count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 (vm-move-message-pointer direction))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 (nreverse mlist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 (defun vm-display-startup-message ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 (if (sit-for 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 (let ((lines vm-startup-message-lines))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3101 (message "VM %s, Copyright (C) 1997 Kyle E. Jones; type ? for help"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 vm-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 (setq vm-startup-message-displayed t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 (while (and (sit-for 4) lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 (message (substitute-command-keys (car lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 (setq lines (cdr lines)))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
3107 (message ""))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 (defun vm-load-init-file (&optional interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 (if (or (not vm-init-file-loaded) interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 (and vm-init-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 (load vm-init-file (not interactive) (not interactive) t))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3115 (and vm-preferences-file (load vm-preferences-file t t t))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 (setq vm-init-file-loaded t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 (vm-display nil nil '(vm-load-init-file) '(vm-load-init-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 (defun vm-session-initialization ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 ;; 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
3121 ;; do some necessary preparations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 (if (or (not (boundp 'vm-session-beginning))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 vm-session-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 (random t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 (vm-load-init-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 (if (not vm-window-configuration-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 (setq vm-window-configurations vm-default-window-configuration)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 (or (vm-load-window-configurations vm-window-configuration-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 (setq vm-window-configurations vm-default-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 (setq vm-buffers-needing-display-update (make-vector 29 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 (setq vm-session-beginning nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 (defun vm-toggle-read-only ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 (setq vm-folder-read-only (not vm-folder-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 (message "Folder is now %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 (if vm-folder-read-only "read-only" "modifiable"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 (vm-display nil nil '(vm-toggle-read-only) '(vm-toggle-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 (vm-update-summary-and-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3144 (defvar scroll-in-place)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3145
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 ;; this does the real major mode scutwork.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 (defun vm-mode-internal ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 (make-local-variable 'require-final-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 ;; 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
3151 ;; keep. rather than non-portably marking the variables we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 ;; want to keep, just avoid calling kill-local-variables and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 ;; reset everything that needs to be reset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 major-mode 'vm-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 mode-line-format vm-mode-line-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 mode-name "VM"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 ;; must come after the setting of major-mode
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3159 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
3160 (vm-menu-support-possible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 (vm-menu-mode-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 buffer-read-only t
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3163 ;; If the user quits a vm-mode buffer, the default action is
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3164 ;; to kill the buffer. Make a note that we should offer to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3165 ;; save this buffer even if it has no file associated with it.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3166 ;; 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
3167 ;; before it was put into vm-mode.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3168 buffer-offer-save t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 require-final-newline nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 vm-thread-obarray nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 vm-thread-subject-obarray nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 vm-label-obarray (make-vector 29 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 vm-last-message-pointer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 vm-modification-counter 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 vm-message-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 vm-message-pointer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 vm-message-order-changed nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 vm-message-order-header-present nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 vm-summary-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 vm-system-state nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 vm-undo-record-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 vm-undo-record-pointer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 vm-virtual-buffers (vm-link-to-virtual-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 vm-folder-type (vm-get-folder-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 (use-local-map vm-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 (and (vm-menu-support-possible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 (vm-menu-install-menus))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3188 (add-hook 'kill-buffer-hook 'vm-garbage-collect-folder)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3189 (add-hook 'kill-buffer-hook 'vm-garbage-collect-message)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3190 ;; avoid the XEmacs file dialog box.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3191 (defvar use-dialog-box)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3192 (make-local-variable 'use-dialog-box)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3193 (setq use-dialog-box nil)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3194 ;; mail folders are precious. protect them by default.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3195 (make-local-variable 'file-precious-flag)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3196 (setq file-precious-flag t)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3197 ;; scroll in place messes with scroll-up and this loses
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3198 (make-local-variable 'scroll-in-place)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
3199 (setq scroll-in-place nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 (run-hooks 'vm-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 ;; compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 (run-hooks 'vm-mode-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 (defun vm-link-to-virtual-buffers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 (let ((b-list (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 (vbuffers nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 (folder-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 folders clauses)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 (while b-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 (set-buffer (car b-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 (cond ((eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 (setq clauses (cdr vm-virtual-folder-definition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 (while clauses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 (setq folders (car (car clauses)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 (while folders
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 (if (eq folder-buffer (vm-get-file-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 (car folders)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 vm-folder-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 (setq vbuffers (cons (car b-list) vbuffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 vm-real-buffers (cons folder-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 vm-real-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 folders nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 clauses nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 (setq folders (cdr folders)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 (setq clauses (cdr clauses)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 (setq b-list (cdr b-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 vbuffers )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 (defun vm-change-folder-type (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 "Change folder type to TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 TYPE may be one of the following symbol values:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3235 From_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3236 From_-with-Content-Length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237 mmdf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3238 babyl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 Interactively TYPE will be read from the minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 (let ((this-command this-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 (last-command last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 (types vm-supported-folder-types))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 (vm-error-if-virtual-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 (setq types (vm-delqual (symbol-name vm-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 (copy-sequence types)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249 (list (intern (vm-read-string "Change folder to type: " types)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 (vm-error-if-virtual-folder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 (if (not (memq type '(From_ From_-with-Content-Length mmdf babyl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 (error "Unknown folder type: %s" type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 (if (or (null vm-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 (eq vm-folder-type 'unknown))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 (error "Current folder's type is unknown, can't change it."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 (let ((mp vm-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 (old-type vm-folder-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 ;; no interruptions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 (inhibit-quit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 (n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 ;; Just for laughs, make the update interval vary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 (modulus (+ (% (vm-abs (random)) 11) 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 text-end opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 (setq vm-folder-type type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 (vm-convert-folder-header old-type type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 (while mp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 (goto-char (vm-start-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 (setq opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 (insert (vm-leading-message-separator type (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 (if (> (vm-headers-of (car mp)) (vm-start-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 (delete-region (point) (vm-headers-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 (set-marker (vm-headers-of (car mp)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 ;; if headers-of == start-of then so could vheaders-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 ;; and text-of. clear them to force a recompute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 (vm-set-vheaders-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 (vm-set-text-of (car mp) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 (vm-convert-folder-type-headers old-type type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 (goto-char (vm-text-end-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 (setq text-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 (insert-before-markers (vm-trailing-message-separator type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 (delete-region (vm-text-end-of (car mp)) (vm-end-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 (set-marker (vm-text-end-of (car mp)) text-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 (goto-char (vm-headers-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 (vm-munge-message-separators type (vm-headers-of (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 (vm-text-end-of (car mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 (vm-set-byte-count-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 (vm-set-babyl-frob-flag-of (car mp) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 (vm-set-message-type-of (car mp) type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 ;; Technically we should mark each message for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 ;; summary update since the message byte counts might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299 ;; have changed. But I don't think anyone cares that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300 ;; much and the summary regeneration would make this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301 ;; process slower.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 (setq mp (cdr mp) n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 (if (zerop (% n modulus))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 100
diff changeset
3304 (message "Converting... %d" n))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305 (vm-clear-modification-flag-undos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307 (vm-update-summary-and-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 (message "Conversion complete.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 ;; message separator strings may have leaked into view
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 (if (> (point-max) (vm-text-end-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311 (narrow-to-region (point-min) (vm-text-end-of (car vm-message-pointer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312 (vm-display nil nil '(vm-change-folder-type) '(vm-change-folder-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3314 (defun vm-garbage-collect-folder ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3315 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3316 (while vm-folder-garbage-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3317 (condition-case nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3318 (funcall (cdr (car vm-folder-garbage-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3319 (car (car vm-folder-garbage-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3320 (error nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3321 (setq vm-folder-garbage-alist (cdr vm-folder-garbage-alist)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3322
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3323 (defun vm-garbage-collect-message ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3324 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3325 (while vm-message-garbage-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3326 (condition-case nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3327 (funcall (cdr (car vm-message-garbage-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3328 (car (car vm-message-garbage-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3329 (error nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3330 (setq vm-message-garbage-alist (cdr vm-message-garbage-alist)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 76
diff changeset
3331
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332 (if (not (memq 'vm-write-file-hook write-file-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333 (setq write-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334 (cons 'vm-write-file-hook write-file-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 (if (not (memq 'vm-handle-file-recovery find-file-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 (setq find-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338 (nconc find-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339 '(vm-handle-file-recovery
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340 vm-handle-file-reversion))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 ;; after-revert-hook is new to FSF v19.23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 (defvar after-revert-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 (if (boundp 'after-revert-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 (setq after-revert-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346 (cons 'vm-after-revert-buffer-hook after-revert-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 (setq after-revert-hook (list 'vm-after-revert-buffer-hook)))