0
|
1 ;;; Macros and functions dealing with accessing VM message struct fields
|
20
|
2 ;;; Copyright (C) 1989-1997 Kyle E. Jones
|
0
|
3 ;;;
|
|
4 ;;; This program is free software; you can redistribute it and/or modify
|
|
5 ;;; it under the terms of the GNU General Public License as published by
|
|
6 ;;; the Free Software Foundation; either version 1, or (at your option)
|
|
7 ;;; any later version.
|
|
8 ;;;
|
|
9 ;;; This program is distributed in the hope that it will be useful,
|
|
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 ;;; GNU General Public License for more details.
|
|
13 ;;;
|
|
14 ;;; You should have received a copy of the GNU General Public License
|
|
15 ;;; along with this program; if not, write to the Free Software
|
|
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17
|
|
18 (provide 'vm-message)
|
|
19
|
|
20 ;; data that is always shared with virtual folders
|
|
21 (defmacro vm-location-data-of (message) (list 'aref message 0))
|
|
22 ;; where message begins starting at the message separator in the folder
|
|
23 (defmacro vm-start-of (message) (list 'aref (list 'aref message 0) 0))
|
|
24 ;; where headers start (From_ line)
|
|
25 (defmacro vm-headers-of (message) (list 'aref (list 'aref message 0) 1))
|
|
26 ;; where visible headers start
|
|
27 (defun vm-vheaders-of (message)
|
|
28 (or (aref (aref message 0) 2)
|
|
29 (progn (vm-reorder-message-headers message nil nil)
|
|
30 (aref (aref message 0) 2))))
|
|
31 ;; where text section starts
|
|
32 (defun vm-text-of (message)
|
|
33 (or (aref (aref message 0) 3) (progn (vm-find-and-set-text-of message)
|
|
34 (aref (aref message 0) 3))))
|
|
35 ;; where text portion of message ends
|
|
36 (defmacro vm-text-end-of (message) (list 'aref (list 'aref message 0) 4))
|
|
37 ;; where message ends
|
|
38 (defmacro vm-end-of (message) (list 'aref (list 'aref message 0) 5))
|
|
39 ;; soft data vector
|
|
40 (defmacro vm-softdata-of (message) (list 'aref message 1))
|
|
41 (defmacro vm-number-of (message) (list 'aref (list 'aref message 1) 0))
|
|
42 (defmacro vm-padded-number-of (message) (list 'aref (list 'aref message 1) 1))
|
|
43 (defmacro vm-mark-of (message) (list 'aref (list 'aref message 1) 2))
|
|
44 ;; start of summary line
|
|
45 (defmacro vm-su-start-of (message) (list 'aref (list 'aref message 1) 3))
|
|
46 ;; end of summary line
|
|
47 (defmacro vm-su-end-of (message) (list 'aref (list 'aref message 1) 4))
|
|
48 ;; symbol whose value is the real message.
|
|
49 (defmacro vm-real-message-sym-of (message)
|
|
50 (list 'aref (list 'aref message 1) 5))
|
|
51 ;; real message
|
|
52 (defmacro vm-real-message-of (message)
|
|
53 (list 'symbol-value (list 'aref (list 'aref message 1) 5)))
|
|
54 ;; link to previous message in the message list
|
|
55 (defmacro vm-reverse-link-of (message)
|
|
56 (list 'symbol-value (list 'aref (list 'aref message 1) 6)))
|
|
57 ;; message type
|
|
58 (defmacro vm-message-type-of (message) (list 'aref (list 'aref message 1) 7))
|
|
59 ;; number that uniquely identifies each message
|
|
60 ;; this is for the set handling stuff
|
|
61 (defmacro vm-message-id-number-of (message)
|
|
62 (list 'aref (list 'aref message 1) 8))
|
|
63 ;; folder buffer of this message
|
|
64 (defmacro vm-buffer-of (message)
|
|
65 (list 'aref (list 'aref message 1) 9))
|
|
66 ;; cache thread indentation value
|
|
67 (defmacro vm-thread-indentation-of (message)
|
|
68 (list 'aref (list 'aref message 1) 10))
|
|
69 ;; list of symbols from vm-thread-obarray that give this message's lineage
|
|
70 (defmacro vm-thread-list-of (message)
|
|
71 (list 'aref (list 'aref message 1) 11))
|
|
72 ;; babyl header frob flag (0 or 1 at beginning of message)
|
|
73 (defmacro vm-babyl-frob-flag-of (message)
|
|
74 (list 'aref (list 'aref message 1) 12))
|
|
75 ;; saved attributes, if message was switched from unmirrored to mirrored
|
|
76 (defmacro vm-saved-virtual-attributes-of (message)
|
|
77 (list 'aref (list 'aref message 1) 13))
|
|
78 ;; saved mirror data, if message was switched from unmirrored to mirrored
|
|
79 (defmacro vm-saved-virtual-mirror-data-of (message)
|
|
80 (list 'aref (list 'aref message 1) 14))
|
|
81 ;; summary for unmirrored virtual message
|
|
82 (defmacro vm-virtual-summary-of (message)
|
|
83 (list 'aref (list 'aref message 1) 15))
|
20
|
84 ;; MIME layout information; types, ids, positions, etc. of all MIME entities
|
|
85 (defmacro vm-mime-layout-of (message)
|
|
86 (list 'aref (list 'aref message 1) 16))
|
|
87 (defmacro vm-mime-encoded-header-flag-of (message)
|
|
88 (list 'aref (list 'aref message 1) 17))
|
0
|
89 ;; message attribute vector
|
|
90 (defmacro vm-attributes-of (message) (list 'aref message 2))
|
|
91 (defmacro vm-new-flag (message) (list 'aref (list 'aref message 2) 0))
|
|
92 (defmacro vm-unread-flag (message) (list 'aref (list 'aref message 2) 1))
|
|
93 (defmacro vm-deleted-flag (message) (list 'aref (list 'aref message 2) 2))
|
|
94 (defmacro vm-filed-flag (message) (list 'aref (list 'aref message 2) 3))
|
|
95 (defmacro vm-replied-flag (message) (list 'aref (list 'aref message 2) 4))
|
|
96 (defmacro vm-written-flag (message) (list 'aref (list 'aref message 2) 5))
|
|
97 (defmacro vm-forwarded-flag (message) (list 'aref (list 'aref message 2) 6))
|
|
98 (defmacro vm-edited-flag (message) (list 'aref (list 'aref message 2) 7))
|
|
99 (defmacro vm-redistributed-flag (message) (list 'aref (list 'aref message 2) 8))
|
|
100 ;; message cached data
|
|
101 (defmacro vm-cache-of (message) (list 'aref message 3))
|
|
102 ;; message size in bytes (as a string)
|
|
103 (defmacro vm-byte-count-of (message) (list 'aref (list 'aref message 3) 0))
|
|
104 ;; weekday sent
|
|
105 (defmacro vm-weekday-of (message) (list 'aref (list 'aref message 3) 1))
|
|
106 ;; month day
|
|
107 (defmacro vm-monthday-of (message) (list 'aref (list 'aref message 3) 2))
|
|
108 ;; month sent
|
|
109 (defmacro vm-month-of (message) (list 'aref (list 'aref message 3) 3))
|
|
110 ;; year sent
|
|
111 (defmacro vm-year-of (message) (list 'aref (list 'aref message 3) 4))
|
|
112 ;; hour sent
|
|
113 (defmacro vm-hour-of (message) (list 'aref (list 'aref message 3) 5))
|
|
114 ;; timezone
|
|
115 (defmacro vm-zone-of (message) (list 'aref (list 'aref message 3) 6))
|
|
116 ;; message author's full name (Full-Name: or gouged from From:)
|
|
117 (defmacro vm-full-name-of (message) (list 'aref (list 'aref message 3) 7))
|
|
118 ;; message author address (gouged from From:)
|
|
119 (defmacro vm-from-of (message) (list 'aref (list 'aref message 3) 8))
|
|
120 ;; message ID (Message-Id:)
|
|
121 (defmacro vm-message-id-of (message) (list 'aref (list 'aref message 3) 9))
|
|
122 ;; number of lines in message (as a string)
|
|
123 (defmacro vm-line-count-of (message) (list 'aref (list 'aref message 3) 10))
|
|
124 ;; message subject (Subject:)
|
|
125 (defmacro vm-subject-of (message) (list 'aref (list 'aref message 3) 11))
|
|
126 ;; Regexp that can be used to find the start of the already ordered headers.
|
|
127 (defmacro vm-vheaders-regexp-of (message)
|
|
128 (list 'aref (list 'aref message 3) 12))
|
|
129 ;; Addresses of recipients in a comma separated list
|
|
130 (defmacro vm-to-of (message) (list 'aref (list 'aref message 3) 13))
|
|
131 ;; Full names of recipients in a comma separated list. Addresses if
|
|
132 ;; full names not available.
|
|
133 (defmacro vm-to-names-of (message) (list 'aref (list 'aref message 3) 14))
|
|
134 ;; numeric month sent
|
|
135 (defmacro vm-month-number-of (message) (list 'aref (list 'aref message 3) 15))
|
|
136 ;; sortable date string (used for easy sorting, naturally)
|
|
137 (defmacro vm-sortable-datestring-of (message)
|
|
138 (list 'aref (list 'aref message 3) 16))
|
|
139 ;; sortable subject, re: garbage removed
|
|
140 (defmacro vm-sortable-subject-of (message)
|
|
141 (list 'aref (list 'aref message 3) 17))
|
36
|
142 ;; tokenized summary entry
|
0
|
143 (defmacro vm-summary-of (message)
|
|
144 (list 'aref (list 'aref message 3) 18))
|
36
|
145 ;; parent of this message, as determined by threading
|
0
|
146 (defmacro vm-parent-of (message)
|
|
147 (list 'aref (list 'aref message 3) 19))
|
36
|
148 ;; message IDs parsed from References header
|
|
149 (defmacro vm-references-of (message)
|
|
150 (list 'aref (list 'aref message 3) 20))
|
0
|
151 ;; extra data shared by virtual messages if vm-virtual-mirror is non-nil
|
|
152 (defmacro vm-mirror-data-of (message) (list 'aref message 4))
|
|
153 ;; if message is being edited, this is the buffer being used.
|
|
154 (defmacro vm-edit-buffer-of (message) (list 'aref (list 'aref message 4) 0))
|
|
155 ;; list of virtual messages mirroring the underlying real message
|
|
156 (defmacro vm-virtual-messages-of (message)
|
|
157 (list 'symbol-value (list 'aref (list 'aref message 4) 1)))
|
|
158 ;; modification flag for this message
|
|
159 ;; nil if all attribute changes have been stuffed into the folder buffer
|
|
160 (defmacro vm-modflag-of (message) (list 'aref (list 'aref message 4) 2))
|
|
161 ;; list of labels attached to this message
|
|
162 (defmacro vm-labels-of (message) (list 'aref (list 'aref message 4) 3))
|
|
163 ;; comma list of labels
|
|
164 (defmacro vm-label-string-of (message) (list 'aref (list 'aref message 4) 4))
|
|
165
|
|
166 (defmacro vm-set-location-data-of (message vdata) (list 'aset message 0 vdata))
|
|
167 (defmacro vm-set-start-of (message start)
|
|
168 (list 'aset (list 'aref message 0) 0 start))
|
|
169 (defmacro vm-set-headers-of (message h)
|
|
170 (list 'aset (list 'aref message 0) 1 h))
|
|
171 (defmacro vm-set-vheaders-of (message vh)
|
|
172 (list 'aset (list 'aref message 0) 2 vh))
|
|
173 (defmacro vm-set-text-of (message text)
|
|
174 (list 'aset (list 'aref message 0) 3 text))
|
|
175 (defmacro vm-set-text-end-of (message text)
|
|
176 (list 'aset (list 'aref message 0) 4 text))
|
|
177 (defmacro vm-set-end-of (message end)
|
|
178 (list 'aset (list 'aref message 0) 5 end))
|
|
179 (defmacro vm-set-softdata-of (message data)
|
|
180 (list 'aset message 1 data))
|
|
181 (defmacro vm-set-number-of (message n)
|
|
182 (list 'aset (list 'aref message 1) 0 n))
|
|
183 (defmacro vm-set-padded-number-of (message n)
|
|
184 (list 'aset (list 'aref message 1) 1 n))
|
|
185 (defmacro vm-set-mark-of (message val)
|
|
186 (list 'aset (list 'aref message 1) 2 val))
|
|
187 (defmacro vm-set-su-start-of (message pos)
|
|
188 (list 'aset (list 'aref message 1) 3 pos))
|
|
189 (defmacro vm-set-su-end-of (message pos)
|
|
190 (list 'aset (list 'aref message 1) 4 pos))
|
|
191 (defmacro vm-set-real-message-sym-of (message sym)
|
|
192 (list 'aset (list 'aref message 1) 5 sym))
|
|
193 (defmacro vm-set-reverse-link-of (message link)
|
|
194 (list 'set (list 'aref (list 'aref message 1) 6) link))
|
|
195 (defmacro vm-set-reverse-link-sym-of (message sym)
|
|
196 (list 'aset (list 'aref message 1) 6 sym))
|
|
197 (defmacro vm-set-message-type-of (message type)
|
|
198 (list 'aset (list 'aref message 1) 7 type))
|
|
199 (defmacro vm-set-message-id-number-of (message number)
|
|
200 (list 'aset (list 'aref message 1) 8 number))
|
|
201 (defmacro vm-set-buffer-of (message buffer)
|
|
202 (list 'aset (list 'aref message 1) 9 buffer))
|
|
203 (defmacro vm-set-thread-indentation-of (message val)
|
|
204 (list 'aset (list 'aref message 1) 10 val))
|
|
205 (defmacro vm-set-thread-list-of (message list)
|
|
206 (list 'aset (list 'aref message 1) 11 list))
|
|
207 (defmacro vm-set-babyl-frob-flag-of (message flag)
|
|
208 (list 'aset (list 'aref message 1) 12 flag))
|
|
209 (defmacro vm-set-saved-virtual-attributes-of (message attrs)
|
|
210 (list 'aset (list 'aref message 1) 13 attrs))
|
|
211 (defmacro vm-set-saved-virtual-mirror-data-of (message data)
|
|
212 (list 'aset (list 'aref message 1) 14 data))
|
|
213 (defmacro vm-set-virtual-summary-of (message summ)
|
|
214 (list 'aset (list 'aref message 1) 15 summ))
|
20
|
215 (defmacro vm-set-mime-layout-of (message layout)
|
|
216 (list 'aset (list 'aref message 1) 16 layout))
|
|
217 (defmacro vm-set-mime-encoded-header-flag-of (message flag)
|
|
218 (list 'aset (list 'aref message 1) 17 flag))
|
0
|
219 (defmacro vm-set-attributes-of (message attrs) (list 'aset message 2 attrs))
|
|
220 ;; The other routines in attributes group are part of the undo system.
|
|
221 (defun vm-set-edited-flag-of (message flag)
|
|
222 (aset (aref message 2) 7 flag)
|
|
223 (vm-mark-for-summary-update message)
|
|
224 (if (eq vm-flush-interval t)
|
|
225 (vm-stuff-virtual-attributes message)
|
|
226 (vm-set-modflag-of message t))
|
|
227 (and (not (buffer-modified-p)) (vm-set-buffer-modified-p t))
|
|
228 (vm-clear-modification-flag-undos))
|
|
229 (defmacro vm-set-cache-of (message cache) (list 'aset message 3 cache))
|
|
230 (defmacro vm-set-byte-count-of (message count)
|
|
231 (list 'aset (list 'aref message 3) 0 count))
|
|
232 (defmacro vm-set-weekday-of (message val)
|
|
233 (list 'aset (list 'aref message 3) 1 val))
|
|
234 (defmacro vm-set-monthday-of (message val)
|
|
235 (list 'aset (list 'aref message 3) 2 val))
|
|
236 (defmacro vm-set-month-of (message val)
|
|
237 (list 'aset (list 'aref message 3) 3 val))
|
|
238 (defmacro vm-set-year-of (message val)
|
|
239 (list 'aset (list 'aref message 3) 4 val))
|
|
240 (defmacro vm-set-hour-of (message val)
|
|
241 (list 'aset (list 'aref message 3) 5 val))
|
|
242 (defmacro vm-set-zone-of (message val)
|
|
243 (list 'aset (list 'aref message 3) 6 val))
|
|
244 (defmacro vm-set-full-name-of (message author)
|
|
245 (list 'aset (list 'aref message 3) 7 author))
|
|
246 (defmacro vm-set-from-of (message author)
|
|
247 (list 'aset (list 'aref message 3) 8 author))
|
|
248 (defmacro vm-set-message-id-of (message id)
|
|
249 (list 'aset (list 'aref message 3) 9 id))
|
|
250 (defmacro vm-set-line-count-of (message count)
|
|
251 (list 'aset (list 'aref message 3) 10 count))
|
|
252 (defmacro vm-set-subject-of (message subject)
|
|
253 (list 'aset (list 'aref message 3) 11 subject))
|
|
254 (defmacro vm-set-vheaders-regexp-of (message regexp)
|
|
255 (list 'aset (list 'aref message 3) 12 regexp))
|
|
256 (defmacro vm-set-to-of (message recips)
|
|
257 (list 'aset (list 'aref message 3) 13 recips))
|
|
258 (defmacro vm-set-to-names-of (message recips)
|
|
259 (list 'aset (list 'aref message 3) 14 recips))
|
|
260 (defmacro vm-set-month-number-of (message val)
|
|
261 (list 'aset (list 'aref message 3) 15 val))
|
|
262 (defmacro vm-set-sortable-datestring-of (message val)
|
|
263 (list 'aset (list 'aref message 3) 16 val))
|
|
264 (defmacro vm-set-sortable-subject-of (message val)
|
|
265 (list 'aset (list 'aref message 3) 17 val))
|
|
266 (defmacro vm-set-summary-of (message val)
|
|
267 (list 'aset (list 'aref message 3) 18 val))
|
|
268 (defmacro vm-set-parent-of (message val)
|
|
269 (list 'aset (list 'aref message 3) 19 val))
|
36
|
270 (defmacro vm-set-references-of (message val)
|
|
271 (list 'aset (list 'aref message 3) 20 val))
|
0
|
272 (defmacro vm-set-mirror-data-of (message data)
|
|
273 (list 'aset message 4 data))
|
|
274 (defmacro vm-set-edit-buffer-of (message buf)
|
|
275 (list 'aset (list 'aref message 4) 0 buf))
|
|
276 (defmacro vm-set-virtual-messages-of (message list)
|
|
277 (list 'set (list 'aref (list 'aref message 4) 1) list))
|
|
278 (defmacro vm-set-virtual-messages-sym-of (message sym)
|
|
279 (list 'aset (list 'aref message 4) 1 sym))
|
|
280 (defmacro vm-set-modflag-of (message val)
|
|
281 (list 'aset (list 'aref message 4) 2 val))
|
|
282 (defmacro vm-set-labels-of (message labels)
|
|
283 (list 'aset (list 'aref message 4) 3 labels))
|
|
284 (defmacro vm-set-label-string-of (message string)
|
|
285 (list 'aset (list 'aref message 4) 4 string))
|
|
286
|
|
287 (defun vm-make-message ()
|
|
288 (let ((v (make-vector 5 nil)) sym)
|
|
289 (vm-set-softdata-of v (make-vector vm-softdata-vector-length nil))
|
|
290 (vm-set-location-data-of
|
|
291 v (make-vector vm-location-data-vector-length nil))
|
|
292 (vm-set-mirror-data-of v (make-vector vm-mirror-data-vector-length nil))
|
|
293 (vm-set-message-id-number-of v (int-to-string vm-message-id-number))
|
|
294 (vm-increment vm-message-id-number)
|
|
295 (vm-set-buffer-of v (current-buffer))
|
|
296 ;; We use an uninterned symbol here as a level of indirection
|
|
297 ;; from a purely self-referential structure. This is
|
|
298 ;; necessary so that Emacs debugger can be used on this
|
|
299 ;; program.
|
|
300 (setq sym (make-symbol "<<>>"))
|
|
301 (set sym v)
|
|
302 (vm-set-real-message-sym-of v sym)
|
|
303 ;; Another uninterned symbol for the virtual messages list.
|
|
304 (setq sym (make-symbol "<v>"))
|
|
305 (set sym nil)
|
|
306 (vm-set-virtual-messages-sym-of v sym)
|
|
307 ;; Another uninterned symbol for the reverse link
|
|
308 ;; into the message list.
|
|
309 (setq sym (make-symbol "<--"))
|
|
310 (vm-set-reverse-link-sym-of v sym)
|
|
311 v ))
|
|
312
|
|
313 (defun vm-find-and-set-text-of (m)
|
|
314 (save-excursion
|
|
315 (set-buffer (vm-buffer-of m))
|
|
316 (save-restriction
|
|
317 (widen)
|
|
318 (goto-char (vm-headers-of m))
|
|
319 (search-forward "\n\n" (vm-text-end-of m) 0)
|
|
320 (vm-set-text-of m (point-marker)))))
|
|
321
|
|
322 (defun vm-virtual-message-p (m)
|
|
323 (not (eq m (vm-real-message-of m))))
|