0
|
1 ;;; Commands for handling messages marks
|
|
2 ;;; Copyright (C) 1990, 1993, 1994 Kyle E. Jones
|
|
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-mark)
|
|
19
|
|
20 (defun vm-clear-all-marks ()
|
|
21 "Removes all message marks in the current folder."
|
|
22 (interactive)
|
|
23 (vm-select-folder-buffer)
|
|
24 (vm-check-for-killed-summary)
|
|
25 (vm-error-if-folder-empty)
|
|
26 (let ((mp vm-message-list))
|
|
27 (while mp
|
|
28 (if (vm-mark-of (car mp))
|
|
29 (progn
|
|
30 (vm-set-mark-of (car mp) nil)
|
|
31 (vm-mark-for-summary-update (car mp) t)))
|
|
32 (setq mp (cdr mp))))
|
|
33 (vm-display nil nil '(vm-clear-all-marks)
|
|
34 '(vm-clear-all-marks marking-message))
|
70
|
35 (vm-update-summary-and-mode-line))
|
0
|
36
|
|
37 (defun vm-mark-all-messages ()
|
|
38 "Mark all messages in the current folder."
|
|
39 (interactive)
|
|
40 (vm-select-folder-buffer)
|
|
41 (vm-check-for-killed-summary)
|
|
42 (vm-error-if-folder-empty)
|
|
43 (let ((mp vm-message-list))
|
|
44 (while mp
|
|
45 (vm-set-mark-of (car mp) t)
|
|
46 (vm-mark-for-summary-update (car mp) t)
|
|
47 (setq mp (cdr mp))))
|
|
48 (vm-display nil nil '(vm-mark-all-messages)
|
|
49 '(vm-mark-all-messages marking-message))
|
70
|
50 (vm-update-summary-and-mode-line))
|
0
|
51
|
|
52 (defun vm-mark-message (count)
|
|
53 "Mark the current message.
|
|
54 Numeric prefix argument N means mark the current message and the next
|
|
55 N-1 messages. A negative N means mark the current message and the
|
|
56 previous N-1 messages."
|
|
57 (interactive "p")
|
|
58 (if (interactive-p)
|
|
59 (vm-follow-summary-cursor))
|
|
60 (vm-select-folder-buffer)
|
|
61 (vm-check-for-killed-summary)
|
|
62 (vm-error-if-folder-empty)
|
|
63 (let ((direction (if (< count 0) 'backward 'forward))
|
|
64 (count (vm-abs count))
|
|
65 (oldmp vm-message-pointer)
|
|
66 (vm-message-pointer vm-message-pointer))
|
|
67 (while (not (zerop count))
|
|
68 (if (not (vm-mark-of (car vm-message-pointer)))
|
|
69 (progn
|
|
70 (vm-set-mark-of (car vm-message-pointer) t)
|
|
71 (vm-mark-for-summary-update (car vm-message-pointer) t)))
|
|
72 (vm-decrement count)
|
|
73 (if (not (zerop count))
|
|
74 (vm-move-message-pointer direction))))
|
|
75 (vm-display nil nil '(vm-mark-message)
|
|
76 '(vm-mark-message marking-message))
|
|
77 (vm-update-summary-and-mode-line))
|
|
78
|
|
79 (defun vm-unmark-message (count)
|
|
80 "Remove the mark from the current message.
|
|
81 Numeric prefix argument N means unmark the current message and the next
|
|
82 N-1 messages. A negative N means unmark the current message and the
|
|
83 previous N-1 messages."
|
|
84 (interactive "p")
|
|
85 (if (interactive-p)
|
|
86 (vm-follow-summary-cursor))
|
|
87 (vm-select-folder-buffer)
|
|
88 (vm-check-for-killed-summary)
|
|
89 (vm-error-if-folder-empty)
|
|
90 (let ((mlist (vm-select-marked-or-prefixed-messages count)))
|
|
91 (while mlist
|
|
92 (if (vm-mark-of (car mlist))
|
|
93 (progn
|
|
94 (vm-set-mark-of (car mlist) nil)
|
|
95 (vm-mark-for-summary-update (car mlist) t)))
|
|
96 (setq mlist (cdr mlist))))
|
|
97 (vm-display nil nil '(vm-unmark-message)
|
|
98 '(vm-unmark-message marking-message))
|
|
99 (vm-update-summary-and-mode-line))
|
|
100
|
98
|
101 (defun vm-mark-summary-region ()
|
|
102 "Mark all messages with summary lines contained in the region."
|
|
103 (interactive)
|
|
104 (vm-select-folder-buffer)
|
|
105 (vm-check-for-killed-summary)
|
|
106 (vm-error-if-folder-empty)
|
|
107 (if (null vm-summary-buffer)
|
|
108 (error "No summary."))
|
|
109 (set-buffer vm-summary-buffer)
|
|
110 (if (not (mark))
|
|
111 (error "The region is not active now"))
|
|
112 (vm-mark-or-unmark-summary-region t)
|
|
113 (vm-display nil nil '(vm-mark-summary-region)
|
|
114 '(vm-mark-summary-region marking-message))
|
|
115 (vm-update-summary-and-mode-line))
|
|
116
|
|
117 (defun vm-unmark-summary-region ()
|
|
118 "Remove marks from messages with summary lines contained in the region."
|
|
119 (interactive)
|
|
120 (vm-select-folder-buffer)
|
|
121 (vm-check-for-killed-summary)
|
|
122 (vm-error-if-folder-empty)
|
|
123 (if (null vm-summary-buffer)
|
|
124 (error "No summary."))
|
|
125 (set-buffer vm-summary-buffer)
|
|
126 (if (not (mark))
|
|
127 (error "The region is not active now"))
|
|
128 (vm-mark-or-unmark-summary-region nil)
|
|
129 (vm-display nil nil '(vm-unmark-summary-region)
|
|
130 '(vm-unmark-summary-region marking-message))
|
|
131 (vm-update-summary-and-mode-line))
|
|
132
|
|
133 (defun vm-mark-or-unmark-summary-region (markit)
|
|
134 ;; The folder buffers copy of vm-message-list has already been
|
|
135 ;; propagated to the summary buffer.
|
|
136 (let ((mp vm-message-list)
|
|
137 (beg (point))
|
|
138 (end (mark))
|
|
139 tmp m)
|
|
140 (if (> beg end)
|
|
141 (setq tmp beg beg end end tmp))
|
|
142 (while mp
|
|
143 (setq m (car mp))
|
|
144 (if (not (eq (not markit) (not (vm-mark-of m))))
|
|
145 (if (or (and (> (vm-su-end-of m) beg)
|
|
146 (< (vm-su-end-of m) end))
|
|
147 (and (>= (vm-su-start-of m) beg)
|
|
148 (< (vm-su-start-of m) end))
|
|
149 (and (>= beg (vm-su-start-of m))
|
|
150 (< beg (vm-su-end-of m))))
|
|
151 (progn
|
|
152 (vm-set-mark-of m markit)
|
|
153 (vm-mark-for-summary-update m t))))
|
|
154 (setq mp (cdr mp)))))
|
|
155
|
0
|
156 (defun vm-mark-or-unmark-messages-with-selector (val selector arg)
|
|
157 (let ((mlist vm-message-list)
|
|
158 (virtual (eq major-mode 'vm-virtual-mode))
|
|
159 (arglist (if arg (list arg) nil))
|
|
160 (count 0))
|
|
161 (setq selector (intern (concat "vm-vs-" (symbol-name selector))))
|
|
162 (while mlist
|
|
163 (if (if virtual
|
|
164 (save-excursion
|
|
165 (set-buffer
|
|
166 (vm-buffer-of
|
|
167 (vm-real-message-of
|
|
168 (car mlist))))
|
|
169 (apply selector (vm-real-message-of (car mlist)) arglist))
|
|
170 (apply selector (car mlist) arglist))
|
|
171 (progn
|
|
172 (vm-set-mark-of (car mlist) val)
|
|
173 (vm-mark-for-summary-update (car mlist) t)
|
|
174 (vm-increment count)))
|
|
175 (setq mlist (cdr mlist)))
|
|
176 (vm-display nil nil
|
|
177 '(vm-mark-matching-messages vm-unmark-matching-messages)
|
|
178 (list this-command 'marking-message))
|
|
179 (vm-update-summary-and-mode-line)
|
|
180 (message "%d message%s %smarked"
|
|
181 count
|
|
182 (if (= 1 count) "" "s")
|
|
183 (if val "" "un"))))
|
|
184
|
|
185 (defun vm-mark-matching-messages (selector &optional arg)
|
|
186 "Mark messages matching some criterion.
|
|
187 You can use any of the virtual folder selectors, except for the
|
|
188 `and', `or' and `not' selectors. See the documentation for the
|
|
189 variable vm-virtual-folder-alist for more information."
|
|
190 (interactive
|
|
191 (let ((last-command last-command)
|
|
192 (this-command this-command))
|
|
193 (vm-select-folder-buffer)
|
|
194 (vm-read-virtual-selector "Mark messages: ")))
|
|
195 (vm-select-folder-buffer)
|
|
196 (vm-check-for-killed-summary)
|
|
197 (vm-error-if-folder-empty)
|
|
198 (vm-mark-or-unmark-messages-with-selector t selector arg))
|
|
199
|
|
200 (defun vm-unmark-matching-messages (selector &optional arg)
|
|
201 "Unmark messages matching some criterion.
|
|
202 You can use any of the virtual folder selectors, except for the
|
|
203 `and', `or' and `not' selectors. See the documentation for the
|
|
204 variable vm-virtual-folder-alist for more information."
|
|
205 (interactive
|
|
206 (let ((last-command last-command)
|
|
207 (this-command this-command))
|
|
208 (vm-select-folder-buffer)
|
|
209 (vm-read-virtual-selector "Unmark messages: ")))
|
|
210 (vm-select-folder-buffer)
|
|
211 (vm-check-for-killed-summary)
|
|
212 (vm-error-if-folder-empty)
|
|
213 (vm-mark-or-unmark-messages-with-selector nil selector arg))
|
|
214
|
|
215 (defun vm-mark-thread-subtree ()
|
|
216 "Mark all messages in the thread tree rooted at the current message."
|
|
217 (interactive)
|
|
218 (vm-follow-summary-cursor)
|
|
219 (vm-select-folder-buffer)
|
|
220 (vm-check-for-killed-summary)
|
|
221 (vm-error-if-folder-empty)
|
|
222 (vm-mark-or-unmark-thread-subtree t))
|
|
223
|
|
224 (defun vm-unmark-thread-subtree ()
|
|
225 "Unmark all messages in the thread tree rooted at the current message."
|
|
226 (interactive)
|
|
227 (vm-follow-summary-cursor)
|
|
228 (vm-select-folder-buffer)
|
|
229 (vm-check-for-killed-summary)
|
|
230 (vm-error-if-folder-empty)
|
|
231 (vm-mark-or-unmark-thread-subtree nil))
|
|
232
|
|
233 (defun vm-mark-or-unmark-thread-subtree (mark)
|
|
234 (vm-build-threads-if-unbuilt)
|
|
235 (let ((list (list (car vm-message-pointer)))
|
|
236 (loop-obarray (make-vector 29 0))
|
|
237 subject-sym id-sym)
|
|
238 (while list
|
|
239 (if (not (eq (vm-mark-of (car list)) mark))
|
|
240 (progn
|
|
241 (vm-set-mark-of (car list) mark)
|
|
242 (vm-mark-for-summary-update (car list))))
|
|
243 (setq id-sym (car (vm-last (vm-th-thread-list (car list)))))
|
|
244 (if (null (intern-soft (symbol-name id-sym) loop-obarray))
|
|
245 (progn
|
|
246 (intern (symbol-name id-sym) loop-obarray)
|
|
247 (nconc list (copy-sequence (get id-sym 'children)))
|
|
248 (setq subject-sym (intern (vm-so-sortable-subject (car list))
|
|
249 vm-thread-subject-obarray))
|
|
250 (if (and (boundp subject-sym)
|
|
251 (eq id-sym (aref (symbol-value subject-sym) 0)))
|
|
252 (nconc list (copy-sequence
|
|
253 (aref (symbol-value subject-sym) 2))))))
|
|
254 (setq list (cdr list))))
|
|
255 (vm-display nil nil
|
|
256 '(vm-mark-thread-subtree vm-unmark-thread-subtree)
|
|
257 (list this-command 'marking-message))
|
|
258 (vm-update-summary-and-mode-line))
|
|
259
|
|
260 (defun vm-mark-messages-same-subject ()
|
|
261 "Mark all messages with the same subject as the current message."
|
|
262 (interactive)
|
|
263 (vm-follow-summary-cursor)
|
|
264 (vm-select-folder-buffer)
|
|
265 (vm-check-for-killed-summary)
|
|
266 (vm-error-if-folder-empty)
|
|
267 (vm-mark-or-unmark-messages-same-subject t))
|
|
268
|
|
269 (defun vm-unmark-messages-same-subject ()
|
|
270 "Unmark all messages with the same subject as the current message."
|
|
271 (interactive)
|
|
272 (vm-follow-summary-cursor)
|
|
273 (vm-select-folder-buffer)
|
|
274 (vm-check-for-killed-summary)
|
|
275 (vm-error-if-folder-empty)
|
|
276 (vm-mark-or-unmark-messages-same-subject nil))
|
|
277
|
|
278 (defun vm-mark-or-unmark-messages-same-subject (mark)
|
|
279 (let ((mp vm-message-list)
|
|
280 (mark-count 0)
|
|
281 (subject (vm-so-sortable-subject (car vm-message-pointer))))
|
|
282 (while mp
|
|
283 (if (and (not (eq (vm-mark-of (car mp)) mark))
|
|
284 (string-equal subject (vm-so-sortable-subject (car mp))))
|
|
285 (progn
|
|
286 (vm-set-mark-of (car mp) mark)
|
|
287 (vm-increment mark-count)
|
|
288 (vm-mark-for-summary-update (car mp) t)))
|
|
289 (setq mp (cdr mp)))
|
|
290 (if (zerop mark-count)
|
|
291 (message "No messages %smarked" (if mark "" "un"))
|
|
292 (message "%d message%s %smarked"
|
|
293 mark-count
|
|
294 (if (= 1 mark-count) "" "s")
|
|
295 (if mark "" "un"))))
|
|
296 (vm-display nil nil
|
|
297 '(vm-mark-messages-same-subject
|
|
298 vm-unmark-messages-same-subject)
|
|
299 (list this-command 'marking-message))
|
|
300 (vm-update-summary-and-mode-line))
|
|
301
|
|
302 (defun vm-mark-messages-same-author ()
|
|
303 "Mark all messages with the same author as the current message."
|
|
304 (interactive)
|
|
305 (vm-follow-summary-cursor)
|
|
306 (vm-select-folder-buffer)
|
|
307 (vm-check-for-killed-summary)
|
|
308 (vm-error-if-folder-empty)
|
|
309 (vm-mark-or-unmark-messages-same-author t))
|
|
310
|
|
311 (defun vm-unmark-messages-same-author ()
|
|
312 "Unmark all messages with the same author as the current message."
|
|
313 (interactive)
|
|
314 (vm-follow-summary-cursor)
|
|
315 (vm-select-folder-buffer)
|
|
316 (vm-check-for-killed-summary)
|
|
317 (vm-error-if-folder-empty)
|
|
318 (vm-mark-or-unmark-messages-same-author nil))
|
|
319
|
|
320 (defun vm-mark-or-unmark-messages-same-author (mark)
|
|
321 (let ((mp vm-message-list)
|
|
322 (mark-count 0)
|
|
323 (author (vm-su-from (car vm-message-pointer))))
|
|
324 (while mp
|
|
325 (if (and (not (eq (vm-mark-of (car mp)) mark))
|
|
326 (string-equal author (vm-su-from (car mp))))
|
|
327 (progn
|
|
328 (vm-set-mark-of (car mp) mark)
|
|
329 (vm-increment mark-count)
|
|
330 (vm-mark-for-summary-update (car mp) t)))
|
|
331 (setq mp (cdr mp)))
|
|
332 (if (zerop mark-count)
|
|
333 (message "No messages %smarked" (if mark "" "un"))
|
|
334 (message "%d message%s %smarked"
|
|
335 mark-count
|
|
336 (if (= 1 mark-count) "" "s")
|
|
337 (if mark "" "un"))))
|
|
338 (vm-display nil nil
|
|
339 '(vm-mark-messages-same-author
|
|
340 vm-unmark-messages-same-author)
|
|
341 (list this-command 'marking-message))
|
|
342 (vm-update-summary-and-mode-line))
|
|
343
|
|
344 (defun vm-next-command-uses-marks ()
|
|
345 "Does nothing except insure that the next VM command will operate only
|
70
|
346 on the marked messages in the current folder."
|
0
|
347 (interactive)
|
|
348 (setq this-command 'vm-next-command-uses-marks)
|
70
|
349 (vm-unsaved-message "Next command uses marks...")
|
0
|
350 (vm-display nil nil '(vm-next-command-uses-marks)
|
|
351 '(vm-next-command-uses-marks)))
|
|
352
|
|
353 (defun vm-marked-messages ()
|
|
354 (let (list (mp vm-message-list))
|
|
355 (while mp
|
|
356 (if (vm-mark-of (car mp))
|
|
357 (setq list (cons (car mp) list)))
|
|
358 (setq mp (cdr mp)))
|
|
359 (nreverse list)))
|
|
360
|
|
361 (defun vm-mark-help ()
|
|
362 (interactive)
|
|
363 (vm-display nil nil '(vm-mark-help) '(vm-mark-help))
|
|
364 (message "MM = mark, MU = unmark, Mm = mark all, Mu = unmark all, MN = use marks, ..."))
|