annotate lisp/vm/vm-thread.el @ 169:15872534500d r20-3b11

Import from CVS: tag r20-3b11
author cvs
date Mon, 13 Aug 2007 09:46:53 +0200
parents 585fb297b004
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; Thread support for VM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Copyright (C) 1994 Kyle E. Jones
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 (provide 'vm-thread)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (defun vm-toggle-threads-display ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 "Toggle the threads display on and off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 When the threads display is on, the folder will be sorted by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 thread and thread indentation (via the %I summary format specifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 will be visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (vm-set-summary-redo-start-point t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (setq vm-summary-show-threads (not vm-summary-show-threads))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (if vm-summary-show-threads
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (vm-sort-messages "thread")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (vm-sort-messages "physical-order")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (defun vm-build-threads (message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (if (null vm-thread-obarray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (setq vm-thread-obarray (make-vector 641 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 vm-thread-subject-obarray (make-vector 641 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (let ((mp (or message-list vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; Just for laughs, make the update interval vary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (modulus (+ (% (vm-abs (random)) 11) 40))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; no need to schedule reindents of reparented messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; unless there were already messages present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (schedule-reindents message-list)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
45 m parent parent-sym id id-sym date refs old-parent-sym)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (while mp
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
47 (setq m (car mp)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
48 parent (vm-th-parent m)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
49 id (vm-su-message-id m)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 id-sym (intern id vm-thread-obarray)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
51 date (vm-so-sortable-datestring m))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
52 (put id-sym 'messages (cons m (get id-sym 'messages)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (if (and (null (cdr (get id-sym 'messages)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 schedule-reindents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (vm-thread-mark-for-summary-update (get id-sym 'children)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (if parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (setq parent-sym (intern parent vm-thread-obarray))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
59 (cond ((or (not (boundp id-sym))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
60 (null (symbol-value id-sym))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
61 (eq (symbol-value id-sym) parent-sym))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
62 (set id-sym parent-sym))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
63 (t
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
64 (setq old-parent-sym (symbol-value id-sym))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
65 (put old-parent-sym 'children
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
66 (let ((kids (get old-parent-sym 'children))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
67 (msgs (get id-sym 'messages)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
68 (while msgs
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
69 (setq kids (delq m kids)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
70 msgs (cdr msgs)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
71 kids ))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
72 (set id-sym parent-sym)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
73 (if schedule-reindents
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
74 (vm-thread-mark-for-summary-update
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
75 (get id-sym 'messages)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (put parent-sym 'children
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
77 (cons m (get parent-sym 'children))))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
78 (if (not (boundp id-sym))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
79 (set id-sym nil)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
80 ;; use the references header to set parenting information
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
81 ;; for ancestors of this message. This does not override
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
82 ;; a parent pointer for a message if it already exists.
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
83 (if (cdr (setq refs (vm-th-references m)))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
84 (let (parent-sym id-sym msgs)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
85 (setq parent-sym (intern (car refs) vm-thread-obarray)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
86 refs (cdr refs))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
87 (while refs
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
88 (setq id-sym (intern (car refs) vm-thread-obarray))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
89 (if (and (boundp id-sym) (symbol-value id-sym))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
90 nil
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
91 (set id-sym parent-sym)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
92 (if (setq msgs (get id-sym 'messages))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
93 (put parent-sym 'children
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
94 (append msgs (get parent-sym 'children))))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
95 (if schedule-reindents
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
96 (vm-thread-mark-for-summary-update msgs)))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
97 (setq parent-sym id-sym
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
98 refs (cdr refs)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (if vm-thread-using-subject
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
100 ;; inhibit-quit because we need to make sure the asets
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
101 ;; below are an atomic group.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (let* ((inhibit-quit t)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
103 (subject (vm-so-sortable-subject m))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (subject-sym (intern subject vm-thread-subject-obarray)))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
105 ;; if this subject never seen before create the
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
106 ;; information vector.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if (not (boundp subject-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (set subject-sym
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
109 (vector id-sym (vm-so-sortable-datestring m)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
110 nil (list m)))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
111 ;; this subject seen before
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (aset (symbol-value subject-sym) 3
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
113 (cons m (aref (symbol-value subject-sym) 3)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (if (string< date (aref (symbol-value subject-sym) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (let* ((vect (symbol-value subject-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (i-sym (aref vect 0)))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
117 ;; optimization: if we know that this message
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
118 ;; already has a parent, then don't bother
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
119 ;; adding it to the list of child messages
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
120 ;; since we know that it will be threaded and
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
121 ;; unthreaded using the parent information.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (if (or (not (boundp i-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (null (symbol-value i-sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (aset vect 2 (append (get i-sym 'messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (aref vect 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (aset vect 0 id-sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (aset vect 1 date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; this loops _and_ recurses and I'm worried
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; about it going into a spin someday. So I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; unblock interrupts here. It's not critical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; that it finish... the summary will just be out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; of sync.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (if schedule-reindents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (let ((inhibit-quit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (vm-thread-mark-for-summary-update (aref vect 2)))))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
136 ;; optimization: if we know that this message
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
137 ;; already has a parent, then don't bother adding
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
138 ;; it to the list of child messages, since we
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
139 ;; know that it will be threaded and unthreaded
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
140 ;; using the parent information.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (if (null parent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (aset (symbol-value subject-sym) 2
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
143 (cons m (aref (symbol-value subject-sym) 2))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (setq mp (cdr mp) n (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (if (zerop (% n modulus))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
146 (message "Building threads... %d" n)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (if (> n modulus)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
148 (message "Building threads... done"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (defun vm-thread-mark-for-summary-update (message-list)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
151 (let (m)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
152 (while message-list
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
153 (setq m (car message-list))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
154 ;; if thread-list is null then we've already marked this
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
155 ;; message, or it doesn't need marking.
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
156 (if (null (vm-thread-list-of m))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
157 nil
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
158 (vm-mark-for-summary-update m t)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
159 (vm-set-thread-list-of m nil)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
160 (vm-set-thread-indentation-of m nil)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
161 (vm-thread-mark-for-summary-update
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
162 (get (intern (vm-su-message-id m) vm-thread-obarray)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
163 'children)))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
164 (setq message-list (cdr message-list)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (defun vm-thread-list (message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (let ((done nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (m message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 thread-list id-sym subject-sym loop-sym root-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (set-buffer (vm-buffer-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (setq id-sym (intern (vm-su-message-id m) vm-thread-obarray)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 thread-list (list id-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (fillarray vm-thread-loop-obarray 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (while (not done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (setq loop-sym (intern (symbol-name id-sym) vm-thread-loop-obarray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (if (boundp loop-sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; loop detected, bail...
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
179 (setq done t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (set loop-sym t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (if (and (boundp id-sym) (symbol-value id-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (setq id-sym (symbol-value id-sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 thread-list (cons id-sym thread-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 m (car (get id-sym 'messages))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if (null m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (setq done t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (if (null vm-thread-using-subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (setq subject-sym
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (intern (vm-so-sortable-subject m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 vm-thread-subject-obarray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if (or (not (boundp subject-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (eq (aref (symbol-value subject-sym) 0) id-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (setq done t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (setq id-sym (aref (symbol-value subject-sym) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 thread-list (cons id-sym thread-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 m (car (get id-sym 'messages)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; save the date of the oldest message in this thread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (setq root-date (get id-sym 'oldest-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (if (or (null root-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (string< (vm-so-sortable-datestring message) root-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (put id-sym 'oldest-date (vm-so-sortable-datestring message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 thread-list )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; remove message struct from thread data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; optional second arg non-nil means forget information that
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
209 ;; might be different if the message contents changed.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
211 ;; message must be a real (non-virtual) message
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (defun vm-unthread-message (message &optional message-changing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (let ((mp (cons message (vm-virtual-messages-of message)))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
215 m id-sym subject-sym vect p-sym)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (while mp
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
217 (setq m (car mp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (let ((inhibit-quit t))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
219 (vm-set-thread-list-of m nil)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
220 (vm-set-thread-indentation-of m nil)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
221 (set-buffer (vm-buffer-of m))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
222 (setq id-sym (intern (vm-su-message-id m) vm-thread-obarray)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
223 subject-sym (intern (vm-so-sortable-subject m)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 vm-thread-subject-obarray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (if (boundp id-sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (progn
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
227 (put id-sym 'messages (delq m (get id-sym 'messages)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (vm-thread-mark-for-summary-update (get id-sym 'children))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (setq p-sym (symbol-value id-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (and p-sym (put p-sym 'children
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
231 (delq m (get p-sym 'children))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (if message-changing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (set id-sym nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (if (and (boundp subject-sym) (setq vect (symbol-value subject-sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (if (not (eq id-sym (aref vect 0)))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
236 (aset vect 2 (delq m (aref vect 2)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (if message-changing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (if (null (cdr (aref vect 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (makunbound subject-sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (let ((p (aref vect 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 oldest-msg oldest-date children)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (setq oldest-msg (car p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 oldest-date (vm-so-sortable-datestring (car p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 p (cdr p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (while p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (if (and (string-lessp (vm-so-sortable-datestring (car p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 oldest-date)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
248 (not (eq m (car p))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (setq oldest-msg (car p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 oldest-date (vm-so-sortable-datestring (car p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (setq p (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (aset vect 0 (intern (vm-su-message-id oldest-msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 vm-thread-obarray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (aset vect 1 oldest-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (setq children (delq oldest-msg (aref vect 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (aset vect 2 children)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
257 (aset vect 3 (delq m (aref vect 3)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; I'm not sure there aren't situations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; where this might loop forever.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (let ((inhibit-quit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (vm-thread-mark-for-summary-update children))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (setq mp (cdr mp))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
264 (defun vm-th-references (m)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
265 (or (vm-references-of m)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
266 (vm-set-references-of
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
267 m
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
268 (let (references)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
269 (setq references (vm-get-header-contents m "References:" " "))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
270 (and references (vm-parse references "[^<]*\\(<[^>]+>\\)"))))))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
271
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (defun vm-th-parent (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (or (vm-parent-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (vm-set-parent-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 m
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
276 (or (car (vm-last (vm-th-references m)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (let (in-reply-to)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
278 (setq in-reply-to (vm-get-header-contents m "In-Reply-To:" " "))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (and in-reply-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (car (vm-parse in-reply-to "[^<]*\\(<[^>]+>\\)"))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (defun vm-th-thread-indentation (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (or (vm-thread-indentation-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (let ((p (vm-th-thread-list m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (while (and p (null (get (car p) 'messages)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (setq p (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (vm-set-thread-indentation-of m (1- (length p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (vm-thread-indentation-of m))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (defun vm-th-thread-list (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (or (vm-thread-list-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (vm-set-thread-list-of m (vm-thread-list m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (vm-thread-list-of m))))