-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vm
2446 lines (2332 loc) · 93.4 KB
/
.vm
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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;;;
;;;; .vm.el - startup initialisation for ViewMail
;;;;
;;;#ident "@(#)HOME:.vm 37.1 21/03/23 11:43:04 (woods)"
;;;
;;; per-user start-up functions for GNU-emacs VM package (View-Mail)
;;;
(require 'sendmail) ; get this over with right away
(require 'message) ; and this too....
(require 'vm-menu) ; and this too....
(setq vm-version-number (string-to-number vm-version))
;;; Netscape (and Mozilla) use X Window properties to implement the "remote"
;;; control protocol. So long as you have only one browser per user-id running
;;; on any given display then all you need to do is set the display and all
;;; should work just fine....
;;;
(defvar my-vm-netscape-display "xtremely:0"
"Display name to pass to netscape in vm-netscape-program-switches.")
(defvar my-vm-galeon-program "galeon"
"Name of program to use to run Galeon.")
(defvar my-vm-galeon-program-switches (list "--disable-sound")
"List of command line switches to pass to Galeon (not including -n).")
(defun my-vm-mouse-send-url-to-galeon (url)
(message "Sending URL to Galeon (opening new tab)...")
(apply 'vm-run-background-command my-vm-galeon-program
(append my-vm-galeon-program-switches (list "-n" url)))
(message "Sending URL to Galeon... done (opened new tab)"))
;;;
;;; dired stuff...
;;;
;;Message-ID: <[email protected]>
;;References: <[email protected]>
;;Date: 06 Apr 1999 18:06:25 -0400
;;From: David Bakhash <[email protected]>
;;Organization: Boston University
;;Subject: Re: Selecting a special mail
;;To: [email protected]
;;
;; I don't think that's feasible given the command interface that VM
;; has. With some programming, you can probably figure out something,
;; but the best way to do it, of course, is to just use vm-visit-folder
;; instead of find-file. If you visit with dired, then use the `r'
;; binding (XEmacs), and you will visit it with vm-visit-folder instead
;; of find-file. If you're using GNU Emacs, then try this code out in
;; your ~/.emacs file:
;;
(defun dired-vm (&optional read-only)
"Run VM on this file.
With prefix arg, visit folder read-only (this requires at least VM 5).
See also variable `dired-vm-read-only-folders'."
(interactive "P")
(let ((dir (dired-current-directory))
(fil (dired-get-filename)))
;; take care to supply 2nd arg only if requested - may still run VM 4!
(require 'vm) ; vm-visit-folder may not be an autoload
(setq this-command 'vm-visit-folder) ; for vm window config
(if read-only
(vm-visit-folder fil t)
(vm-visit-folder fil))
;; so that pressing `v' inside VM does prompt within current directory:
(set (make-local-variable 'vm-folder-directory) dir)))
(add-hook 'dired-mode-hook
'(lambda ()
(require 'dired-x)
(define-key dired-mode-map "r" 'dired-vm)))
;;;
;;; VM related things
;;;
(define-key vm-mode-map "/" 'vm-isearch-forward)
(define-key vm-mode-map "\em" 'vm-mark-message)
(define-key vm-mode-map "\eu" 'vm-unmark-message)
;; Hack using virtual folders to kill only unread messages matching the same
;; subject....
;;
;; V S ; vm-create-virtual-folder-same-subject
;; M C unread RET ; vm-mark-messages-matching ...
;; M N ; vm-next-command-uses-marks
;; d ; vm-delete-message
;; q ; vm-quit
;;(define-key vm-mode-map "k" 'vm-kill-unread-subject)
;;(define-key vm-mode-map "K" 'vm-kill-subject)
;; Kyle suggests this as the q&d way to be able to see all the parts of a
;; multipart/alternative message....
;;
(defun my-vm-unbind-vm-mime-display-internal-multipart/alternative ()
"Get rid of vm-mime-display-internal-multipart/alternative so that buttons
for all parts will be displayed."
(require 'vm-mime)
(fmakunbound 'vm-mime-display-internal-multipart/alternative))
(add-hook 'vm-mode-hook 'my-vm-unbind-vm-mime-display-internal-multipart/alternative)
;; this is too "easy" -- need a confirmation, or just use the pull-down menu!
;(define-key vm-mode-map "+" 'vm-print-message)
(defvar my-vm-virtual-leftovers-folder "General Delivery"
"The name of the virtual folder containing all the messages which are not
members of other virtual folders. (It's created after all the others are
created by my-vm-visit-all-virtual-folders.)
NOTE: Changes to this variable only take effect when your emacs session is
restarted.")
(defvar my-vm-virtual-spam-folder "zzzz Spam-I-Am zzzz"
"The name of the spam virtual folder.
NOTE: Changes to this variable only take effect when your .vm is reloaded.")
(defun my-vm-quit-all-virtual-folders ()
"Quit from all of the virtual folders in vm-virtual-folder-alist."
(interactive)
(let ((vfolder vm-virtual-folder-alist))
(while vfolder
(save-excursion
(condition-case error-data
(let ((vm-confirm-quit nil))
(set-buffer (concat "(" (car (car vfolder)) ")"))
(vm-quit))
(error nil))
(setq vfolder (cdr vfolder))))))
(defun my-vm-visit-all-virtual-folders ()
"Visit all of the virtual folders in vm-virtual-folder-alist."
(interactive)
(save-excursion
(condition-case error-data
(let ((vm-confirm-quit nil))
(set-buffer (concat "(" my-vm-virtual-leftovers-folder ")"))
(vm-quit))
(error nil)))
(let ((vfolder vm-virtual-folder-alist))
(while vfolder
(let ((vfname (car (car vfolder))))
(if (not (string-equal vfname my-vm-virtual-leftovers-folder))
(vm-visit-virtual-folder vfname))
(setq vfolder (cdr vfolder)))))
(vm-visit-virtual-folder my-vm-virtual-leftovers-folder))
(define-key vm-mode-map "Va" 'my-vm-visit-all-virtual-folders)
(defun my-vm-resync-all-virtual-folders ()
"Revisit all virtual folders to update them. This doesn't seem to be
necessary any more with newer versions of VM, eg. 6.62."
(interactive)
(save-excursion
;; this is no longer necessary with newer versions of VM, eg. 6.62
;;(my-vm-quit-all-virtual-folders)
;; make sure all new messages are in their target folders so that the magic
;; for the General Delivery folder works....
(my-vm-visit-all-virtual-folders)))
(defun my-vm-get-new-mail ()
"Local version of vm-get-new-mail that updates all virtual folders in
vm-virtual-folder-alist."
(interactive)
(save-excursion
;; this is no longer necessar with newer versions of VM, eg. 6.62
;;(my-vm-quit-all-virtual-folders)
;; instead we only need to quit the "General Delivery" folder:
(save-excursion
(condition-case error-data
(let ((vm-confirm-quit nil))
(set-buffer (concat "(" my-vm-virtual-leftovers-folder ")"))
(vm-quit))
(error nil)))
(set-buffer (vm-get-file-buffer vm-primary-inbox))
(vm-get-new-mail)
;; make sure all new messages are in their target folders so that the magic
;; for the General Delivery folder works....
(my-vm-visit-all-virtual-folders)))
;; This overrides the normal binding of 'G' to vm-sort-messages....
(define-key vm-mode-map "G" 'my-vm-get-new-mail)
(defun my-vm-quit ()
"Local version of vm-quit that quits all virtual buffers if quitting
vm-primary-inbox."
(interactive)
(vm-select-folder-buffer)
(if (eq major-mode 'vm-virtual-mode)
(vm-quit)
(if (string-equal (buffer-file-name)
(expand-file-name vm-primary-inbox))
(my-vm-quit-all-virtual-folders))
(vm-quit)))
(define-key vm-mode-map "q" 'my-vm-quit)
(defun my-vm-quit-all ()
"Quit from all buffers in VM-mode."
(interactive)
(save-excursion
(mapcar '(lambda (buffer)
(and (buffer-live-p buffer) (set-buffer buffer)
(eq major-mode 'vm-mode) (vm-quit)))
(buffer-list))))
;; Does no harm if VM already exited.
(add-hook 'my-before-kill-emacs-hook 'my-vm-quit-all)
(defun my-vm-count-function ()
"Return the number of buffers in vm-mode."
(interactive)
(let ((count 0))
(save-excursion
(mapcar '(lambda (buffer) (set-buffer buffer)
(and (eq major-mode 'vm-mode) (setq count (1+ count))))
(buffer-list)))
(if (interactive-p)
(message "%s buffer%s in VM mode" count (if (> count 1) "s" ""))
count)))
(defun my-vm-quit-last ()
"Quit from VM. If this is the last buffer in VM mode, prompt."
(interactive)
(let ((quit t))
(and (= (my-vm-count-function) 1)
(or (when (yes-or-no-p "Really exit VM? ")
(my-vm-save-all-folders-deactivate)
t)
(setq quit nil)))
(message "%s" (current-buffer))
(when quit
(vm-quit))))
(require 'ispell)
(add-hook 'vm-mail-mode-hook
(function (lambda () (local-set-key "\C-ci" 'ispell-message))))
(setq ispell-message-text-end
(mapconcat (function identity)
(list ispell-message-text-end
"^-- $" ; XXX this is in orig, but it's not!
"^-----BEGIN PGP " ; PGP
"&This is a[-A-Z0-9 ]+digest" ; digest
)
"\\|"))
(require 'advice)
(defadvice vm-summarize (after my-vm-summarize activate)
"Also call vm-emit-totals-blurb after vm-summarize."
(vm-emit-totals-blurb))
;;From: Kevin Rodgers <[email protected]>
;;Newsgroups: gnu.emacs.vm.info
;;Subject: Re: Behavior of vm-delete-message
;;Date: Wed, 27 Oct 2004 16:45:17 -0600
;;Message-ID: <[email protected]>
;;
;;(defadvice vm-delete-message (before vm-follow-summary-cursor activate)
;; "When called interactively, select the message at point in the summary
;;buffer."
;; (when (interactive-p)
;; (let ((vm-follow-summary-cursor t))
;; (vm-follow-summary-cursor))))
(defun my-vm-auto-archive-messages ()
"Local version of vm-auto-archive-messages that obtains user confirmation."
(interactive)
(if (y-or-n-p "Are you really sure you want to archive all messages???")
(vm-auto-archive-messages)))
(define-key vm-mode-map "A" 'my-vm-auto-archive-messages)
;; this is done this way so that it remains compatible with pre-6.x VM
(defun my-vm-forward-message-using-rfc934 ()
"Local version of vm-forward-message that uses rfc934 encapsulation and
avoids any MIME transfer encoding. Pine 3.96 cannot show headers in MIME
message/rfc822 attachments."
(interactive)
(let ((vm-forwarding-digest-type "rfc934"))
(vm-forward-message)
(set (make-local-variable 'vm-send-using-mime) nil)))
(define-key vm-mode-map "Z" 'vm-forward-message) ; use default (mime)
(define-key vm-mode-map "z" 'my-vm-forward-message-using-rfc934)
;;;
;;; vm-bogofilter support
;;;
(require 'vm-bogofilter)
(defun my-vm-quit-virtual-spam-folder ()
"Quit from the virtual spam folder `my-vm-virtual-spam-folder' if not
currently visiting it."
(let ((virtual-spam-folder-name (concat "(" my-vm-virtual-spam-folder ")")))
(if (not (equal (buffer-name)
virtual-spam-folder-name))
(save-excursion
(condition-case error-data
(let ((vm-confirm-quit nil))
(set-buffer virtual-spam-folder-name)
(vm-quit))
(error nil))))))
(defadvice vm-bogofilter-is-spam (after my-vm-bogofilter-is-spam activate)
"Also call `my-vm-quit-virtual-spam-folder' in case spam status changed."
(my-vm-quit-virtual-spam-folder))
(defadvice vm-bogofilter-is-clean (after my-vm-bogofilter-is-clean activate)
"Also call `my-vm-quit-virtual-spam-folder' in case spam status changed."
(my-vm-quit-virtual-spam-folder))
(defadvice vm-bogofilter-just-retag (after my-vm-bogofilter-just-retag activate)
"Also call `my-vm-quit-virtual-spam-folder' in case spam status changed."
(my-vm-quit-virtual-spam-folder))
(defadvice vm-bogofilter-new-spam (after my-vm-bogofilter-new-spam activate)
"Also call `my-vm-quit-virtual-spam-folder' in case spam status changed."
(my-vm-quit-virtual-spam-folder))
(defadvice vm-bogofilter-new-clean (after my-vm-bogofilter-new-clean activate)
"Also call `my-vm-quit-virtual-spam-folder' in case spam status changed."
(my-vm-quit-virtual-spam-folder))
(defadvice vm-bogofilter-update-and-tag (after my-vm-bogofilter-update-and-tag activate)
"Also call `my-vm-quit-virtual-spam-folder' in case spam status changed."
(my-vm-quit-virtual-spam-folder))
(define-key vm-mode-map "\C-cs" 'vm-bogofilter-new-spam)
(define-key vm-mode-map "\C-cS" 'vm-bogofilter-is-spam)
(define-key vm-mode-map "\C-cn" 'vm-bogofilter-new-clean)
(define-key vm-mode-map "\C-cN" 'vm-bogofilter-is-clean)
(define-key vm-mode-map "\C-ct" 'vm-bogofilter-test-if-spam)
(define-key vm-mode-map "\C-cT" 'vm-bogofilter-just-retag)
(define-key vm-mode-map "\C-cu" 'vm-bogofilter-update-and-tag)
;;;
;;; some more assistance for spam-handling
;;;
(defun my-vm-run-lookup-prog (progname args pop-buffer &optional bufname)
"Run PROGNAME with ARGS into BUFNAME, visiting buffer if POP-BUFFER is
non-nil. If BUFNAME is nil or not given then create it using PROGNAME."
(if (not bufname)
(setq bufname (concat "*VM-lookup-" progname "*")))
(save-window-excursion ; bury-buffer buggers windows...
(save-excursion
(set-buffer (get-buffer-create bufname))
(setq buffer-read-only nil)
(erase-buffer)
(if pop-buffer
;; watch it in progress...
(apply 'start-process progname bufname progname args)
;; wait for the output...
(apply 'call-process progname nil '(t t) nil args))
(if pop-buffer
(setq buffer-read-only t))
(goto-char (point-min))
(if pop-buffer
(let ((pop-up-windows t))
(pop-to-buffer (current-buffer)))
(bury-buffer)))))
(defun my-vm-rblookup (ip-addr-or-name)
"Run rblookup on the address or name given as IP-ADDR-OR-NAME, leaving output
in *VM-lookup-rblookup*."
(interactive "sAddress or hostname for rblookup: ")
(my-vm-run-lookup-prog "rblookup" (list ; "-v" is too verbose
ip-addr-or-name) (interactive-p)))
(defun my-vm-host-check (ip-addr)
"Run `host -A' on the address given as IP-ADDR, leaving output in
*VM-lookup-host-A*."
(interactive "sAddress or hostname for host -v -A: ")
(if (not (interactive-p))
(my-vm-run-lookup-prog "host" (list "-v" "-A" ip-addr) nil "*VM-lookup-host-A*"))
(my-vm-run-lookup-prog "host" (list "-v" "-A" ip-addr) (interactive-p) "*VM-lookup-host-A*"))
(defun my-vm-jwhois (token)
"Run jwhois on the address or name given as TOKEN, leaving output in
*VM-lookup-jwhois*."
(interactive "sAddress or hostname for jwhois: ")
(my-vm-run-lookup-prog "jwhois" (list token) (interactive-p)))
(defun my-vm-forward-spam ()
"Local version of vm-forward-message that treats the message being forwarded
as spam and prepares information about its sources."
(interactive)
(vm-follow-summary-cursor)
(vm-select-folder-buffer)
(vm-check-for-killed-summary)
(vm-error-if-folder-empty)
;; note the magic use of `%UR', which calls `vm-summary-function-R'
(let* ((vm-forwarding-subject-format
"forwarded spam/UCE from \"%UR\"\nSummary: original message sent %y/%M/%d-%h (%z)\n with ID %i")
(mp (car (vm-select-marked-or-prefixed-messages 1)))
;; we call `vm-summary-function-R' again to get the from-host string
(from-host (vm-summary-function-R mp)))
;; force simple encapsulation so the recipient doesn't need a MIME-capable
;; mailer to read this message...
(my-vm-forward-message-using-rfc934)
(string-match "[[)]\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)[])]" from-host)
(let ((from-host-addr (match-string 1 from-host)))
(mail-to)
(insert "[email protected]")
(replace-regexp "(locally authorised broken client using invalid hostname!) [^(]*" "INVALID-HOSTNAME")
(undo-boundary)
(if (<= (string-to-number from-host-addr) 0) ; XXX not a real test, but what the heck
(message (concat
"Apparently there is no IP address in `" from-host "'!"))
(message (concat
"Getting info for `" from-host "' as `" from-host-addr "'..."))
(my-vm-host-check from-host-addr)
(my-vm-jwhois from-host-addr)
;;; (my-vm-rblookup from-host-addr)
(message (concat
"Getting info for `" from-host "' as `" from-host-addr "'... Done."))
;; XXX this next bit should probably be a separate function....
(let ((abuse-emails nil)
(look-for-more nil))
(save-window-excursion ; XXX is this necessary?
(save-excursion
(set-buffer (get-buffer "*VM-lookup-jwhois*"))
(setq case-fold-search t)
(goto-char (point-min))
(replace-string "" "") ; XXX use the DOS EOL converter?
;; XXX this next bit should also be a separate function as it is reused....
(goto-char (point-min))
;; the obvious ARIN "{Org}AbuseEmail:" entries, plus other oddballs...
(while (re-search-forward "abuse.*mail[ \t]*:" nil t)
(skip-chars-forward ": \t<" (point-at-eol))
(let ((astart (point)))
(skip-chars-forward "^:, \"\t>" (point-at-eol))
(let ((addr (buffer-substring astart
(point))))
(message "Found abuse*mail address: <%s>" addr)
(if (not (member addr abuse-emails))
(setq abuse-emails (append abuse-emails
(list addr))))))
(goto-char (point-at-eol)))
(if (or (not abuse-emails)
look-for-more)
(progn
(goto-char (point-min))
;; the ARIN TechEmail: entries
(while (re-search-forward "tech.*mail[ \t]*:" nil t)
(skip-chars-forward ": \t<" (point-at-eol))
(let ((astart (point)))
(skip-chars-forward "^:, \"\t>" (point-at-eol))
(let ((addr (buffer-substring astart
(point))))
(message "Found tech*mail address: <%s>" addr)
(setq look-for-more t) ; go on for admins too!
(if (not (member addr abuse-emails))
(setq abuse-emails (append abuse-emails
(list addr))))))
(goto-char (point-at-eol))))
(message "[Not looking for more tech*mail entries..."))
(if (or (not abuse-emails)
look-for-more)
(progn
(goto-char (point-min))
;; the ARIN AdminEmail: entries
(while (re-search-forward "admin.*mail[ \t]*:" nil t)
(skip-chars-forward ": \t<" (point-at-eol))
(let ((astart (point)))
(skip-chars-forward "^:, \"\t>" (point-at-eol))
(let ((addr (buffer-substring astart
(point))))
(message "Found admin*mail address: <%s>" addr)
(setq look-for-more nil)
(if (not (member addr abuse-emails))
(setq abuse-emails (append abuse-emails
(list addr))))))
(goto-char (point-at-eol))))
(message "[Not looking for more admin*mail entries..."))
;; anything else that might look obvious
(progn
(goto-char (point-min))
(while (search-forward "abuse@" nil t)
(goto-char (match-beginning 0))
(skip-chars-backward "^:, \t<" (point-at-bol))
(let ((astart (point)))
(skip-chars-forward "^:, \"\t>" (point-at-eol))
(let ((addr (buffer-substring astart
(point))))
(message "Found abuse@ address: <%s>" addr)
(if (string-equal addr "[email protected]")
(setq look-for-more t))
(if (not (member addr abuse-emails))
(setq abuse-emails (append abuse-emails
(list addr))))))
(goto-char (point-at-eol))))
(if (or (not abuse-emails)
look-for-more)
(progn
(goto-char (point-min))
;; other *mail: entries
(while (re-search-forward "mail[ \t]*:" nil t)
(skip-chars-forward ": \t<" (point-at-eol))
(let ((astart (point)))
(skip-chars-forward "^:, \"\t>" (point-at-eol))
(let ((addr (buffer-substring astart
(point))))
(message "Found mail: address: <%s>" addr)
(setq look-for-more nil)
(if (not (member addr abuse-emails))
(setq abuse-emails (append abuse-emails
(list addr))))))
(goto-char (point-at-eol))))
(message "[Not looking for more mail: entries..."))
(if (or (not abuse-emails)
look-for-more)
(progn
(goto-char (point-min))
;; the whois.nic.ad.jp entries
(while (search-forward "[Reply Mail]" nil t)
(skip-chars-forward ": \t<" (point-at-eol))
(let ((astart (point)))
(skip-chars-forward "^, \"\t>" (point-at-eol))
(let ((addr (buffer-substring astart
(point))))
(message "Found reply-mail address: <%s>" addr)
(setq look-for-more nil)
(if (not (member addr abuse-emails))
(setq abuse-emails (append abuse-emails
(list addr))))))
(goto-char (point-at-eol))))
(message "[Not looking for more reply-mail entries..."))
(if (or (not abuse-emails)
look-for-more)
(progn
(goto-char (point-min))
;; whois servers that use the old un-tagged format
(while (search-forward "@" nil t)
(skip-chars-backward "^:, \t<" (point-at-bol))
(let ((astart (point)))
(skip-chars-forward "^:, \"\t>" (point-at-eol))
(let ((addr (buffer-substring astart
(point))))
(message "Found un-tagged address: <%s>" addr)
(if (not (member addr abuse-emails))
(setq abuse-emails (append abuse-emails
(list addr))))))
(goto-char (point-at-eol))))
(message "[Not looking for more reply-mail entries..."))
;; deal with those most stupid idiots using the *.rima-tde.net reverse-DNS
(progn
(goto-char (point-min))
(while (search-forward "nemesys@" nil t)
(if (not (member "You MUST have an ABUSE Mailbox <[email protected]>" abuse-emails))
(setq abuse-emails (append abuse-emails
(list
"You MUST have an ABUSE Mailbox <[email protected]>"))))
(goto-char (match-beginning 0))
(skip-chars-backward "^:, \t<" (point-at-bol))
(let ((astart (point)))
(skip-chars-forward "^, \"\t>" (point-at-eol))
(let ((addr (buffer-substring astart
(point))))
(message "Found nemesys@ address: <%s>" addr)
(if (not (member addr abuse-emails))
(setq abuse-emails (append abuse-emails
(list addr))))))
(goto-char (point-at-eol))))))
(if abuse-emails
(progn
(message "Found addresses: ")
(princ abuse-emails t)
;; XXX should do something to remove "mailto:" prefixes from
;; the likes of proxad.net's addresses.
(mail-to)
(insert (concat ", "
(mapconcat 'append abuse-emails ", "))))))
(mail-text)
(insert (concat "\n$ host -v -A " from-host-addr "\n"))
(insert-buffer-substring "*VM-lookup-host-A*")
(insert "\n")
;;; (undo-boundary)
;;; (insert (concat "\n$ jwhois " from-host-addr "\n"))
;;; (insert-buffer-substring "*VM-lookup-jwhois*")
;;; (insert "\n")
;;; (undo-boundary)
;;; (insert (concat "\n$ rblookup " from-host-addr "\n"))
;;; (insert-buffer-substring "*VM-lookup-rblookup*")
;;; (insert "\n")
(undo-boundary)
(mail-to)))))
(define-key vm-mode-map "\eZ" 'my-vm-forward-spam) ; use default (mime)
(defun my-vm-forward-fraud ()
"Local version of vm-forward-message that treats the message being forwarded
as fraud and prepares information about its sources."
(interactive)
(vm-follow-summary-cursor)
(vm-select-folder-buffer)
(vm-check-for-killed-summary)
(vm-error-if-folder-empty)
;; note the magic use of `%UR', which calls `vm-summary-function-R'
(let* ((vm-forwarding-subject-format
"forwarded FRAUD from \"%UR\"\nSummary: original message sent %y/%M/%d-%h (%z)\n with ID %i")
(mp (car (vm-select-marked-or-prefixed-messages 1)))
;; we call `vm-summary-function-R' again to get the from-host string
(from-host (vm-summary-function-R mp)))
;; force simple encapsulation so the recipient doesn't need a MIME-capable
;; mailer to read this message...
(my-vm-forward-message-using-rfc934)
(string-match "[[)]\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)[])]" from-host)
(let ((from-host-addr (match-string 1 from-host)))
(mail-to)
(insert "[email protected]")
(undo-boundary)
(if (<= (string-to-number from-host-addr) 0) ; XXX not a real test, but what the heck
(message (concat
"Apparently there is no IP address in `" from-host "'!"))
(message (concat
"Getting info for `" from-host "' as `" from-host-addr "'..."))
(my-vm-host-check from-host-addr)
(my-vm-jwhois from-host-addr)
(message (concat
"Getting info for `" from-host "' as `" from-host-addr "'... Done."))
(mail-text)
(insert (concat "\n$ host -v -A " from-host-addr "\n"))
(insert-buffer-substring "*VM-lookup-host-A*")
(insert "\n")
(undo-boundary)
(insert (concat "\n$ jwhois " from-host-addr "\n"))
(insert-buffer-substring "*VM-lookup-jwhois*")
(insert "\n")
(undo-boundary)))))
(define-key vm-mode-map "\eF" 'my-vm-forward-fraud) ; use default (mime)
(defun vm-summary-function-R (mp)
"Local function to extract first interesting next-hop host from the received
headers of message MP. Called by `vm-forward-message' when
`vm-forwarding-subject-format' contains the magic format string `%UR'."
(let ((from-host nil)
;; gather the content of all the received headers into a string and
;; split this string into a list of words.
(split-rcvd (split-string (vm-get-header-contents mp "Received:" " Received: "))))
;; search for the first word following an occurance of the keyword "from"
;; that is not followed by a host/addr string matching one that commonly
;; forwards messages to us.
;;
;;(message (concat "STARTING new parse of: " (mapconcat 'concat split-rcvd " ") "\n"))
(while (and (>= (length split-rcvd) 2)
(not from-host))
(catch 'next-token
(let ((key (car split-rcvd))
(value (car (cdr split-rcvd))))
;;(message (concat "KEY is: '" key "', VALUE is: '" value "'"))
(if (string-equal key "from")
(progn
(setq split-rcvd (cdr split-rcvd)) ; be sure to skip key ...
;; This shouldn't happen, but sometimes mailers forget to
;; properly quote hostnames that need quoting to appear in
;; RFC-822 headers. Also sometimes the optional comment
;; containing the TCP info is in the next token. Try
;; concatenating another word if the value doesn't contain a
;; commented IP address literal.
(while (and (car (cdr split-rcvd))
(not (string-match "[[(][0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+[])]" value)))
;; we also need to deal with incomplete timestamp lines --
;; e.g. those that don't contain a TCP info comment
(setq split-rcvd (cdr split-rcvd))
(let ((next-token (car split-rcvd)))
(if (or (string-equal next-token "Received:")
(string-equal next-token "by"))
;; seeing "Received:" or "by" means we need to restart
;; collecting `value' again so throw away what have
;; collected so far and continue the outer loop
(progn
;;(message (concat "FOUND '" next-token "', jumping to outer loop"))
(setq value "")
(throw 'next-token t))
;; else we have a good token to append to `value'
;;(message (concat "CURRENT value is: '" value "', APPENDING: '" next-token "'"))
(setq value (concat value
(if (and (not (string-equal "" value))
(not (string-match "(" next-token 0)))
" ")
next-token)))))
(if (string-match "(client is using the wrong hostname!) *" value 0)
(setq value (replace-match "" t t value)))
;; append any missing closing paren...
(if (and (string-match ".*(" value 0)
(not (string-match ".*)" value 0)))
(setq value (concat value ")")))
;; skip all the mailers were I have local aliases forwarded to me
;;(message (concat "FINAL value is: '" value "'"))
(if (and (not (string-match ".*\\.weird\\.com *\\(( *\\[204\\.92\\.254.[0-9]+\\][^\)]*)\\)?" value 0))
(not (string-match "whome.planix.com *\\(([204.29.161.33])\\)?" value 0))
(not (string-match "druid.net *\\(([216.126.72.98])\\)?" value 0))
(not (string-match "gateway.tectrol.com *\\(([207.219.105.6])\\)?" value 0))
(not (string-match "gateway.tectrol.com *\\((gateway.tectrol.ca[207.219.105.6])\\)?" value 0))
(not (string-match "server.proxy.net *\\(([198.96.186.33])\\)?" value 0))
(not (string-match "fw.protagon.com *\\(([216.191.74.18])\\)?" value 0))
(not (string-match "mail.netbsd.org *\\(([155.53.1.253])\\)?" value 0)) ; this doesn't work well -- qmail SUCKS!
(not (string-match "camomile.cloud9.net *\\(([168.100.1.3])\\)?" value 0))
(not (string-match "russian-caravan.cloud9.net *\\(([168.100.1.4])\\)?" value 0))
(not (string-match "localhost *\\((localhost [127.0.0.1])\\)?" value 0)) ; also for cloud9.net
(not (string-match "localhost.cloud9.net *\\((localhost.cloud9.net [127.0.0.1])\\)?" value 0))
(not (string-match "camomile.cloud9.net *\\((localhost.cloud9.net [127.0.0.1])\\)?" value 0))
(not (string-match "russian-caravan.cloud9.net *\\((localhost [127.0.0.1])\\)?" value 0))
(not (string-match "corporate.aci.on.ca *\\(([205.207.148.249])\\)?" value 0))
(not (string-match "corporate.aci.on.ca *\\(([205.207.148.12])\\)?" value 0))
(not (string-match "corporate.aci.on.ca *\\((dns.aci.on.ca[205.207.148.12])\\)?" value 0))
(not (string-match "aci.on.ca *\\((ipass.aci.on.ca[205.207.148.15])\\)?" value 0))
(not (string-match "admin.aci.on.ca *\\(([205.207.148.250])\\)?" value 0))
(not (string-match "public.aci.on.ca *\\(([205.207.148.251])\\)?" value 0))
(not (string-match "aci.on.ca *\\(([205.207.148.251])\\)?" value 0)))
(setq from-host value))))
(setq split-rcvd (cdr split-rcvd)))))
(if (not from-host)
(setq from-host "(unknown)"))
;; return the string containing the most interesting next-hop host
from-host))
;;;
;;; from Jukka Partanen <[email protected]>.
;;;
(if (>= vm-version-number 6.0)
(progn
(defun vm-mime-delete-mime-body-part (&optional layout)
"Delete the mime body part at the point"
(interactive)
(if (not layout)
(setq layout
(if (and vm-fsfemacs-p (= emacs-major-version 19))
(let (o-list (overlays-at (point)))
(while (and o-list
(not (overlay-get (car o-list) 'vm-mime-layout)))
(setq o-list (cdr o-list)))
(car o-list))
(extent-at (point) nil 'vm-mime-layout))))
(let ((mp vm-message-pointer)
start end buf)
(if (not layout)
(error "No MIME body at point!"))
(if (not (vectorp layout))
(setq layout (vm-extent-property layout 'vm-mime-layout)))
(setq start (vm-mm-layout-header-start layout)
end (vm-mm-layout-body-end layout)
buf (marker-buffer start))
(save-excursion
(set-buffer buf)
(vm-save-restriction
(widen)
(narrow-to-region (vm-headers-of (vm-real-message-of (car mp)))
(vm-text-end-of (vm-real-message-of (car mp))))
(let ((buffer-read-only nil)
(type (vm-get-header-contents (car mp) "Content-Type:"))
boundary)
(setq type (vm-mime-parse-content-header type ?\;))
(while type
(if (string-match "^boundary=" (car type))
(setq boundary (car (vm-parse (car type) "=\\(.+\\)"))
type nil)
(setq type (cdr type))))
(if (not boundary)
(error "Cannot find MIME boundary!"))
(goto-char start)
(if (not (re-search-backward (concat "\n--"
(regexp-quote boundary))
(point-min) t))
(error "Cannot find MIME boundary!"))
(delete-region (point) end)
(if (and (looking-at (concat "\n*--" (regexp-quote boundary) "--"))
(not (re-search-backward (concat "^--"
(regexp-quote boundary))
(point-min) t)))
(insert (concat "\n--" boundary "\n\n")))))
(vm-discard-cached-data)
(vm-set-edited-flag-of (car mp) t)
(vm-show-current-message))))
(define-key vm-mode-map "X" 'vm-mime-delete-mime-body-part)))
;;;
;;; some more enhancements
;;;
;;; borrowed from gnuspost.el and then greatly re-mangled....
;;;
;; a real nasty hack to force a reload to re-eval all the variable settings
;; that use mail-local-domain-name...
;;
;; ARGH! This doesn't seem to be working!
;;
(defadvice set-new-mail-local-domain-name (after my-vm-set-new-mail-local-domain-name activate)
"Also call vm-load-init-file after set-new-local-domain-name."
(vm-load-init-file t))
(if (not (fboundp 'vm-generate-message-id))
(defun vm-generate-message-id ()
"Generate unique Message-Id value for user."
(concat "<" (vm-unique-id) "@" (system-name) ">")))
(if (not (fboundp 'vm-unique-id))
(defun vm-unique-id ()
"Generate unique ID from user name and current time."
(let ((date (current-time-string))
(name (user-login-name)))
(if (string-match "^[^ ]+ \\([^ ]+\\)[ ]+\\([0-9]+\\) \\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\) [0-9][0-9]\\([0-9][0-9]\\)"
date)
(concat (upcase name) "."
(substring date (match-beginning 6) (match-end 6)) ;Year
(substring date (match-beginning 1) (match-end 1)) ;Month
(substring date (match-beginning 2) (match-end 2)) ;Day
(substring date (match-beginning 3) (match-end 3)) ;Hour
(substring date (match-beginning 4) (match-end 4)) ;Minute
(substring date (match-beginning 5) (match-end 5)) ;Second
)
(error "Cannot understand current-time-string: %s." date)))))
;;;
;;; this borrowed from gnus-art.el....
;;;
(defun vm-url-unhex (x)
"Convert X from a hex representation to the actual value."
(if (> x ?9)
(if (>= x ?a)
(+ 10 (- x ?a))
(+ 10 (- x ?A)))
(- x ?0)))
;;;
;;; this also borrowed from gnus-art.el....
;;;
(defun vm-url-unhex-string (str &optional allow-newlines)
"Return a string with the %XX embedded codes removed from the url giving in STR.
If optional second argument ALLOW-NEWLINES is non-nil, then allow the
decoding of carriage returns and line feeds in the string, which is normally
forbidden in URL encoding."
(setq str (or str ""))
(let ((tmp "")
(case-fold-search t))
(while (string-match "%[0-9a-f][0-9a-f]" str)
(let* ((start (match-beginning 0))
(ch1 (vm-url-unhex (elt str (+ start 1))))
(code (+ (* 16 ch1)
(vm-url-unhex (elt str (+ start 2))))))
(setq tmp (concat
tmp (substring str 0 start)
(cond
(allow-newlines
(char-to-string code))
((or (= code ?\n) (= code ?\r))
" ")
(t (char-to-string code))))
str (substring str (match-end 0)))))
(setq tmp (concat tmp str))
tmp))
;;; Turn this horror of a URL:
;;;
;;; http://angelfire.com%40%77%77%77%2E%63%79ber%67%61%74%65w%61%79%2E%6E%65%74/t%68e%72%65%6D%6F%76e%31/r%65%6Do%76%65%2E%68%74%6D#@f%72%65%65%79%65%6C%6C%6Fw.%63%6F%6D/%6D%65%6D%62%65%72%73/b%69%67%6Der%63%68a%6E%74%73%74%75%66%66/i%6Edex%2E%68%74%6D%6C
;;;
;;; into this at least semi-readable URL:
;;;
;;; http://[email protected]/theremove1/remove.htm#@freeyellow.com/members/bigmerchantstuff/index.html
;;;
(defun vm-url-unhex-region (beg end)
"Remove %XX embedded codes in a URL marked as the current region."
(interactive "r")
(if (integerp end) ; dunno -- was in morse.el (allow point + extent?)
(setq end (copy-marker end)))
(save-excursion
(let ((str (buffer-substring beg end)))
(goto-char beg)
(delete-region beg end)
(insert (vm-url-unhex-string str)))))
;;; Message-ID: <[email protected]>
;;; From: [email protected] (Edwin Huffstutler)
;;; Date: 24 Aug 1996 15:14:02 -0700
;;; Subject: Remove "extra" text from replies
;;; Summary: functions to remove .sigs, double citations
;;;
;;; Create a function to nuke a .sig from replied-to mail (if it exists).
;;; Find the end of the buffer, back up over my .sig, then delete up to
;;; the beginning of the quoted .sig.
;;
(defun citation-kill-sig ()
"Nuke a .sig from cited mail"
(interactive)
(save-excursion
(goto-char (point-max))
(search-backward-regexp "^-- $" 1 t)
(let ((top-of-my-sig (point)))
(search-backward-regexp
(concat "^" vm-included-text-prefix "-- $") 1 t)
(delete-region (point) top-of-my-sig)
)))
(add-hook 'vm-reply-hook
'citation-kill-sig)
;;; more from: [email protected] (Edwin Huffstutler)
;;;
;;; This next one I bind to C-c C-d in a reply buffer, and it deletes anything
;;; that has been quoted twice, and removes included-text-prefixes on blank
;;; lines. (I just think it looks cleaner that way, as I usually reply to
;;; each paragraph of the mail separately)
;;;
;;; define a function to remove doubly-cited stuff
;;
(defun citation-kill-double ()
"Remove doubly-cited text and extra lines in a mail message"
(interactive)
(save-excursion
;;; nuke the quoted quoted text
;;(beginning-of-buffer)
;;(replace-regexp
;; (concat "^" vm-included-text-prefix "\\sw*[>|}].*\n") "")
;;; get rid of citation prefix on blank lines
(beginning-of-buffer)
(replace-regexp
(concat "^" vm-included-text-prefix "$") "")
;;; replace more than two newlines with just two
(beginning-of-buffer)
(replace-regexp "\n\n+" "\n\n")
;;; get rid of double attribution text
;;(beginning-of-buffer)
;;(replace-regexp
;; (concat "^" vm-included-text-prefix "\\[ .*wrote.*\\]\n\\|"
;; "^" vm-included-text-prefix ".*wrote:\n") "")
))
(defun citation-set-kill-double-binding ()
"Set the binding for citation-kill-double"
(local-set-key "\C-c\C-d" 'citation-kill-double))
(add-hook 'vm-reply-hook
'citation-set-kill-double-binding)
;;; From: [email protected]
;;; Newsgroups: gnu.emacs.vm.info
;;; Subject: Re: Why do only some links get tagged and highlighted as html links?
;;; Date: 24 Jun 2003 08:34:42 +0200
;;; Message-ID: <[email protected]>
;;;
;;; Without actually testing this, something like the following
;;; should highlight all URLs ...
;;
(defun my-vm-energize-urls-in-message ()
(interactive)
(save-excursion
(vm-select-folder-buffer)
(if vm-presentation-buffer (set-buffer vm-presentation-buffer))
(vm-energize-urls-in-message-region (point-min) (point-max))))
(define-key vm-mode-map "E" 'my-vm-energize-urls-in-message)
;;;
;;; some additional stuff for sendmail.el et al that's not in ~/.emacs...
;;;
;;; From: [email protected] (Bruce W. Hoylman)
;;; SENDER: [email protected]
;;; Subject: Re: Newbie wants VM to auto-archive mail like (shudder) pine
;;; Date: 30 May 1995 10:57:11 -0600
;;
;; Mail archive filename defun
;;
(defun set-mail-archive-file-name ()
"Set `mail-archive-file-name' based on the current date."
(let ((date (current-time-string)))
(string-match
"^\\([A-Z][a-z][a-z]\\) \\([A-Z][a-z][a-z]\\) \\([0-9 ][0-9]\\) \\([0-9][0-9]:[0-9][0-9]\\)\\(:[0-9][0-9]\\) [0-9][0-9]\\([0-9][0-9]\\)"
date)
(setq mail-archive-file-name
(concat vm-folder-directory
".outgoing/"
(substring date (match-beginning 6)
(match-end 6))
"-"
(substring date (match-beginning 2)
(match-end 2))))))
(set-mail-archive-file-name)
(add-hook 'vm-mail-mode-hook 'set-mail-archive-file-name)
(defvar mail-default-organization "~/.organization"
"The default name of your organization (or a filename containing a string
defining the organization name), if not set in the environment variable
ORGANIZATION. If not nil, takes precedence over the file
{$LOCAL,/usr}/lib/news/organization.")
(setq mail-default-headers
(concat
(if (< vm-version-number 6.0)
(concat "X-Mailer: ViewMail (vm) Version "
vm-version