EasyPG 1.07 Released
[packages] / xemacs-packages / mew / mew / contrib / mew-virtual-thread.el
1 ;; -*- Mode: Emacs-Lisp -*-
2 ;;  $Id: mew-virtual-thread.el,v 1.1 2000-05-23 08:31:16 steveb Exp $
3 ;;
4 ;; mew-virtual-thread.el --- "Virtual Thread mode for Mew, easy and safety :-)"
5 ;;
6 ;;                         "Hideyuki SHIRAI" <shirai@rdmg.mgcs.mei.co.jp>
7 ;;                                            Created: <05/25/1999>
8 ;;                                Revised: Time-stamp: <09/02/1999 11:08 shirai>
9 ;;
10 ;;; Usage
11 ;;; 1. Put a below line on your ~/.emacs.
12 ;; (eval-after-load "mew" '(require 'mew-virtual-thread))
13 ;;
14 ;;; 2. When type the "T" in summary-mode, list the threaded messages.
15 ;;;    Selection of the messages has the four ways as described below.
16 ;;;
17 ;;;  2.1. without "C-u" and no "review mark".
18 ;;;       => 'matched input REGEXP' messages.
19 ;;;  2.2. without "C-u" and some "review mark".
20 ;;;       => marked messages.
21 ;;;  2.3. with "C-u" and the region.
22 ;;;       => messages in the region.
23 ;;;  2.4. with "C-u" and no region.
24 ;;;       => messages after point.
25 ;;;
26 ;;; 3. When type the "T" in virtual-thread-mode with any marks,
27 ;;;    The marks transfer to original folder.
28 ;;;
29
30 (defconst mew-virtual-thread-version "mew-virtual-thread.el 0.16")
31
32 (eval-when-compile (require 'mew))
33
34 (defvar mew-virtual-thread-get-remote t
35   "If non-nil, get remote folder's messages, before make a threaded summary buffer.")
36
37 (add-hook 'mew-summary-mode-hook
38           '(lambda ()
39              (define-key mew-summary-mode-map "T" 'mew-virtual-thread)))
40
41 (defun mew-virtual-thread (&optional arg)
42   "\"Virtual Thread Mode\" execute."
43   (interactive "P")
44   (if (and (eq major-mode 'mew-virtual-mode)
45            mew-virtual-thread-original-folder)
46       (mew-virtual-thread-mark-transfer arg)
47     (mew-summary-only
48      (if (not (mew-summary-exclusive-p))
49          ()
50        (let* ((fld (buffer-name))
51               (src fld)
52               range beg end)
53          (if (not arg)
54              (progn
55                (setq range (mew-summary-mark-collect
56                             mew-mark-review (point-min) (point-max)))
57                (if range
58                    ()
59                  (call-interactively 'mew-virtual-thread-mark-regexp)
60                  (setq range (mew-summary-mark-collect
61                               mew-mark-review (point-min) (point-max)))
62                  (mew-summary-batch-unmark (list mew-mark-review) nil)))
63            (if (or (and (boundp 'mark-active) mark-active)
64                    (and (functionp 'region-exists-p) (region-exists-p)))
65                (setq range (mew-virtual-thread-number
66                             (min (region-beginning) (region-end))
67                             (max (region-beginning) (region-end))))
68              (setq range (mew-virtual-thread-number
69                           (progn (beginning-of-line) (point)) (point-max)))))
70          (or (listp range) (setq range (list range)))
71          (if (and mew-virtual-thread-get-remote (mew-folder-remotep fld))
72              (save-excursion
73                (goto-char (point-min))
74                (re-search-forward (concat "^ *" (car range)))
75                (beginning-of-line)
76                (mapcar (function
77