annotate lisp/vm/vm-folder.el @ 70:131b0175ea99 r20-0b30

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