This file is indexed.

/usr/share/emacs/site-lisp/vm/vm-mark.el is in vm 8.2.0b-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
;;; vm-mark.el ---  Commands for handling messages marks
;;
;; This file is part of VM
;;
;; Copyright (C) 1990, 1993, 1994 Kyle E. Jones
;; Copyright (C) 2003-2006 Robert Widhopf-Fenk
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License along
;; with this program; if not, write to the Free Software Foundation, Inc.,
;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

;;; Code:

(provide 'vm-mark)

(eval-when-compile
  (require 'vm-misc)
  (require 'vm-folder)
  (require 'vm-motion)
  (require 'vm-thread)
  (require 'vm-summary)
  (require 'vm-sort)
  (require 'vm-virtual)
  (require 'vm-window)
  )


;;;###autoload
(defun vm-clear-all-marks ()
  "Removes all message marks in the current folder."
  (interactive)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-inform 5 "Clearing all marks...")
  (let ((mp vm-message-list))
    (while mp
      (if (vm-mark-of (car mp))
	  (progn
	    (vm-set-mark-of (car mp) nil)
	    (vm-mark-for-summary-update (car mp) t)))
      (setq mp (cdr mp))))
  (vm-display nil nil '(vm-clear-all-marks)
	      '(vm-clear-all-marks marking-message))
  (vm-update-summary-and-mode-line)
  (vm-inform 5 "Clearing all marks... done"))

;;;###autoload
(defun vm-toggle-all-marks ()
  "Toggles all message marks in the current folder.
Messages that are unmarked will become marked and messages that are
marked will become unmarked."
  (interactive)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-inform 5 "Toggling all marks...")
  (let ((mp vm-message-list))
    (while mp
      (vm-set-mark-of (car mp) (not (vm-mark-of (car mp))))
      (vm-mark-for-summary-update (car mp) t)
      (setq mp (cdr mp))))
  (vm-display nil nil '(vm-toggle-all-marks)
	      '(vm-toggle-all-marks marking-message))
  (vm-update-summary-and-mode-line)
  (vm-inform 5 "Toggling all marks... done"))

;;;###autoload
(defun vm-mark-all-messages ()
  "Mark all messages in the current folder."
  (interactive)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-inform 5 "Marking all messages...")
  (let ((mp vm-message-list))
    (while mp
      (vm-set-mark-of (car mp) t)
      (vm-mark-for-summary-update (car mp) t)
      (setq mp (cdr mp))))
  (vm-display nil nil '(vm-mark-all-messages)
	      '(vm-mark-all-messages marking-message))
  (vm-update-summary-and-mode-line)
  (vm-inform 5 "Marking all messages... done"))

;;;###autoload
(defun vm-mark-message (count)
  "Mark the current message.
Numeric prefix argument N means mark the current message and the next
N-1 messages.  A negative N means mark the current message and the
previous N-1 messages."
  (interactive "p")
  (if (vm-interactive-p)
      (vm-follow-summary-cursor))
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (let ((direction (if (< count 0) 'backward 'forward))
	(count (vm-abs count))
	(oldmp vm-message-pointer)
	(vm-message-pointer vm-message-pointer))
    (while (not (zerop count))
      (if (not (vm-mark-of (car vm-message-pointer)))
	  (progn
	    (vm-set-mark-of (car vm-message-pointer) t)
	    (vm-mark-for-summary-update (car vm-message-pointer) t)))
      (vm-decrement count)
      (if (not (zerop count))
	  (vm-move-message-pointer direction))))
  (vm-display nil nil '(vm-mark-message)
	      '(vm-mark-message marking-message))
  (vm-update-summary-and-mode-line))

;;;###autoload
(defun vm-unmark-message (count)
  "Remove the mark from the current message.
Numeric prefix argument N means unmark the current message and the next
N-1 messages.  A negative N means unmark the current message and the
previous N-1 messages."
  (interactive "p")
  (if (vm-interactive-p)
      (vm-follow-summary-cursor))
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (let ((mlist (vm-select-operable-messages
		count (vm-interactive-p) "Unmark")))
    (while mlist
      (if (vm-mark-of (car mlist))
	  (progn
	    (vm-set-mark-of (car mlist) nil)
	    (vm-mark-for-summary-update (car mlist) t)))
      (setq mlist (cdr mlist))))
  (vm-display nil nil '(vm-unmark-message)
	      '(vm-unmark-message marking-message))
  (vm-update-summary-and-mode-line))

;;;###autoload
(defun vm-mark-summary-region ()
  "Mark all messages with summary lines contained in the region."
  (interactive)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (if (null vm-summary-buffer)
      (error "No summary."))
  (set-buffer vm-summary-buffer)
  (if (not (mark))
      (error "The region is not active now"))
  (vm-mark-or-unmark-summary-region t)
  (vm-display nil nil '(vm-mark-summary-region)
	      '(vm-mark-summary-region marking-message))
  (vm-update-summary-and-mode-line))

;;;###autoload
(defun vm-unmark-summary-region ()
  "Remove marks from messages with summary lines contained in the region."
  (interactive)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (if (null vm-summary-buffer)
      (error "No summary."))
  (set-buffer vm-summary-buffer)
  (if (not (mark))
      (error "The region is not active now"))
  (vm-mark-or-unmark-summary-region nil)
  (vm-display nil nil '(vm-unmark-summary-region)
	      '(vm-unmark-summary-region marking-message))
  (vm-update-summary-and-mode-line))

(defun vm-mark-or-unmark-summary-region (markit)
  ;; The folder buffers copy of vm-message-list has already been
  ;; propagated to the summary buffer.
  (let ((mp vm-message-list)
	(beg (point))
	(end (mark))
	tmp m)
    (if (> beg end)
	(setq tmp beg 
	      beg end 
	      end tmp))
    (while mp
      (setq m (car mp))
      (if (not (eq (not markit) (not (vm-mark-of m))))
	  (if (or (and (>  (vm-su-end-of m) beg)
		       (<  (vm-su-end-of m) end))
		  (and (>= (vm-su-start-of m) beg)
		       (<  (vm-su-start-of m) end))
		  (and (>= beg (vm-su-start-of m))
		       (<  beg (vm-su-end-of m))))
	      (progn
		(vm-set-mark-of m markit)
		(vm-mark-for-summary-update m t))))
      (setq mp (cdr mp)))))

(defun vm-mark-or-unmark-messages-with-selector (val selector arg)
  (let ((mlist vm-message-list)
	(virtual (eq major-mode 'vm-virtual-mode))
	(arglist (if arg (list arg) nil))
	(count 0))
    (setq selector (intern (concat "vm-vs-" (symbol-name selector))))
    (while mlist
      (if (if virtual
	      (save-excursion
		(set-buffer
		 (vm-buffer-of
		  (vm-real-message-of
		   (car mlist))))
		(apply selector (vm-real-message-of (car mlist)) arglist))
	    (apply selector (car mlist) arglist))
	  (progn
	    (vm-set-mark-of (car mlist) val)
	    (vm-mark-for-summary-update (car mlist) t)
	    (vm-increment count)))
      (setq mlist (cdr mlist)))
    (vm-display nil nil
		'(vm-mark-matching-messages vm-unmark-matching-messages)
		(list this-command 'marking-message))
    (vm-update-summary-and-mode-line)
    (vm-inform 5 "%s message%s %smarked"
	     (if (> count 0) count "No")
	     (if (= 1 count) "" "s")
	     (if val "" "un"))))

;;;###autoload
(defun vm-mark-matching-messages (selector &optional arg)
  "Mark messages matching some criterion.
You can use any of the virtual folder selectors, except for the
`and', `or' and `not' selectors.  See the documentation for the
variable vm-virtual-folder-alist for more information."
  (interactive
   (let ((last-command last-command)
	 (this-command this-command))
     (save-current-buffer
       (vm-select-folder-buffer)
       (vm-read-virtual-selector "Mark messages: "))))
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-mark-or-unmark-messages-with-selector t selector arg))

;;;###autoload
(defun vm-unmark-matching-messages (selector &optional arg)
  "Unmark messages matching some criterion.
You can use any of the virtual folder selectors, except for the
`and', `or' and `not' selectors.  See the documentation for the
variable vm-virtual-folder-alist for more information."
  (interactive
   (let ((last-command last-command)
	 (this-command this-command))
     (save-current-buffer
       (vm-select-folder-buffer)
       (vm-read-virtual-selector "Unmark messages: "))))
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-mark-or-unmark-messages-with-selector nil selector arg))

;;;###autoload
(defun vm-mark-thread-subtree ()
  "Mark all messages in the thread tree rooted at the current message."
  (interactive)
  (vm-follow-summary-cursor)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-mark-or-unmark-thread-subtree t))

;;;###autoload
(defun vm-unmark-thread-subtree ()
  "Unmark all messages in the thread tree rooted at the current message."
  (interactive)
  (vm-follow-summary-cursor)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-mark-or-unmark-thread-subtree nil))

(defun vm-mark-or-unmark-thread-subtree (mark)
  (vm-build-threads-if-unbuilt)
  (let ((list (vm-thread-subtree 
	       (vm-thread-symbol (car vm-message-pointer)))))
    (while list
      (unless (eq (vm-mark-of (car list)) mark)
	(vm-set-mark-of (car list) mark)
	(vm-mark-for-summary-update (car list)))
      (setq list (cdr list))))
;;   (let ((list (list (car vm-message-pointer)))
;; 	(loop-obarray (make-vector 29 0))
;; 	subject-sym id-sym)
;;     (while list
;;       (if (not (eq (vm-mark-of (car list)) mark))
;; 	  (progn
;; 	    (vm-set-mark-of (car list) mark)
;; 	    (vm-mark-for-summary-update (car list))))
;;       (setq id-sym (vm-last-elem (vm-thread-list (car list))))
;;       (if (null (intern-soft (symbol-name id-sym) loop-obarray))
;; 	  (progn
;; 	    (intern (symbol-name id-sym) loop-obarray)
;; 	    (nconc list (copy-sequence (vm-th-child-messages-of id-sym)))
;; 	    (setq subject-sym (intern (vm-so-sortable-subject (car list))
;; 				      vm-thread-subject-obarray))
;; 	    (if (and (boundp subject-sym) 
;; 		     (eq id-sym (aref (symbol-value subject-sym) 0)))
;; 		(nconc list (copy-sequence
;; 			     (aref (symbol-value subject-sym) 2))))))
;;       (setq list (cdr list))))
  (vm-display nil nil
	      '(vm-mark-thread-subtree vm-unmark-thread-subtree)
	      (list this-command 'marking-message))
  (vm-update-summary-and-mode-line))

;;;###autoload
(defun vm-mark-messages-same-subject ()
  "Mark all messages with the same subject as the current message."
  (interactive)
  (vm-follow-summary-cursor)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-mark-or-unmark-messages-same-subject t))

;;;###autoload
(defun vm-unmark-messages-same-subject ()
  "Unmark all messages with the same subject as the current message."
  (interactive)
  (vm-follow-summary-cursor)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-mark-or-unmark-messages-same-subject nil))

(defun vm-mark-or-unmark-messages-same-subject (mark)
  (let ((mp vm-message-list)
	(mark-count 0)
	(subject (vm-so-sortable-subject (car vm-message-pointer))))
    (while mp
      (if (and (not (eq (vm-mark-of (car mp)) mark))
	       (string-equal subject (vm-so-sortable-subject (car mp))))
	  (progn
	    (vm-set-mark-of (car mp) mark)
	    (vm-increment mark-count)
	    (vm-mark-for-summary-update (car mp) t)))
      (setq mp (cdr mp)))
    (vm-display nil nil
		'(vm-mark-messages-same-subject
		  vm-unmark-messages-same-subject)
		(list this-command 'marking-message))
    (vm-update-summary-and-mode-line)
    (if (zerop mark-count)
	(vm-inform 5 "No messages %smarked" (if mark "" "un"))
      (vm-inform 5 "%d message%s %smarked"
	       mark-count
	       (if (= 1 mark-count) "" "s")
	       (if mark "" "un")))))

;;;###autoload
(defun vm-mark-messages-same-author ()
  "Mark all messages with the same author as the current message."
  (interactive)
  (vm-follow-summary-cursor)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-mark-or-unmark-messages-same-author t))

;;;###autoload
(defun vm-unmark-messages-same-author ()
  "Unmark all messages with the same author as the current message."
  (interactive)
  (vm-follow-summary-cursor)
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-mark-or-unmark-messages-same-author nil))

(defun vm-mark-or-unmark-messages-same-author (mark)
  (let ((mp vm-message-list)
	(mark-count 0)
	(author (vm-su-from (car vm-message-pointer))))
    (while mp
      (if (and (not (eq (vm-mark-of (car mp)) mark))
	       (vm-string-equal-ignore-case author (vm-su-from (car mp))))
	  (progn
	    (vm-set-mark-of (car mp) mark)
	    (vm-increment mark-count)
	    (vm-mark-for-summary-update (car mp) t)))
      (setq mp (cdr mp)))
    (vm-display nil nil
		'(vm-mark-messages-same-author
		  vm-unmark-messages-same-author)
		(list this-command 'marking-message))
    (vm-update-summary-and-mode-line)
    (if (zerop mark-count)
	(vm-inform 5 "No messages %smarked" (if mark "" "un"))
      (vm-inform 5 "%d message%s %smarked"
	       mark-count
	       (if (= 1 mark-count) "" "s")
	       (if mark "" "un")))))

(defun vm-mark-or-unmark-messages-with-virtual-folder (val name)
  (let* ((vfolder (assoc name vm-virtual-folder-alist))
	 vm-virtual-folder-definition m mlist clauses
	 (count 0))
    (or vfolder (error "No such virtual folder, %s" name))
    (setq vfolder (vm-copy vfolder))
    (setq clauses (cdr vfolder))
    (while clauses
      (setcar (car clauses) (list (list 'get-buffer (buffer-name))))
      (setq clauses (cdr clauses)))
    (setq vm-virtual-folder-definition vfolder)
    (setq mlist (vm-build-virtual-message-list vm-message-list t))
    (if (null vm-real-buffers)
	(while mlist
	  (setq m (vm-real-message-of (car mlist)))
	  (vm-set-mark-of m val)
	  (vm-mark-for-summary-update m t)
	  (vm-increment count)
	  (setq mlist (cdr mlist)))
      (let ((curbuf (current-buffer)) vmlist)
	(while mlist
	  (setq m (vm-real-message-of (car mlist))
		vmlist (vm-virtual-messages-of m))
	  (while vmlist
	    (cond ((eq curbuf (vm-buffer-of (car vmlist)))
		   (vm-set-mark-of (car vmlist) val)
		   (vm-mark-for-summary-update (car vmlist) t)
		   (vm-increment count)
		   (setq vmlist nil))
		  (t (setq vmlist (cdr vmlist)))))
	  (setq mlist (cdr mlist)))))
    (vm-display nil nil
		'(vm-mark-matching-messages-with-virtual-folder
		  vm-unmark-matching-messages-with-virtual-folder)
		(list this-command 'marking-message))
    (vm-update-summary-and-mode-line)
    (vm-inform 5 "%s message%s %smarked"
	     (if (> count 0) count "No")
	     (if (= 1 count) "" "s")
	     (if val "" "un"))))

;;;###autoload
(defun vm-mark-matching-messages-with-virtual-folder (name)
  "Mark messages that are matched by the selectors of virtual folder NAME."
  (interactive
   (let ((last-command last-command)
	 (this-command this-command))
     (list
      (completing-read
       "Mark messages matching this virtual folder's selectors: "
       vm-virtual-folder-alist nil t))))
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-mark-or-unmark-messages-with-virtual-folder t name))

;;;###autoload
(defun vm-unmark-matching-messages-with-virtual-folder (name)
  "Unmark messages that are matched by the selectors of virtual folder NAME."
  (interactive
   (let ((last-command last-command)
	 (this-command this-command))
     (list
      (completing-read
       "Unmark message matching this virtual folder's selectors: "
       vm-virtual-folder-alist nil t))))
  (vm-select-folder-buffer-and-validate 1 (vm-interactive-p))
  (vm-mark-or-unmark-messages-with-virtual-folder nil name))

;;;###autoload
(defun vm-next-command-uses-marks ()
  "Does nothing except insure that the next VM command will operate only
on the marked messages in the current folder.  This only works for
commands bound to key, menu or button press events.  M-x vm-command will
not work."
  (interactive)
  (setq this-command 'vm-next-command-uses-marks)
  (vm-inform 5 "Next command uses marks...")
  (vm-display nil nil '(vm-next-command-uses-marks)
	      '(vm-next-command-uses-marks)))

;;;###autoload
(defun vm-marked-messages ()
  (let (list (mp vm-message-list))
    (while mp
      (if (vm-mark-of (car mp))
	  (setq list (cons (car mp) list)))
      (setq mp (cdr mp)))
    (nreverse list)))

;;;###autoload
(defun vm-mark-help ()
  (interactive)
  (vm-display nil nil '(vm-mark-help) '(vm-mark-help))
  (vm-inform 0 "MM = mark, MU = unmark, Mm = mark all, Mu = unmark all, MN = use marks, ..."))

;;; vm-mark.el ends here