Mercurial > emacs
annotate lisp/mail/mh-seq.el @ 49003:532fc9301fcd
* macterm.c (syms_of_macterm): Set mac-wheel-button-is-mouse-2
to default to t.
author | Steven Tamm <steventamm@mac.com> |
---|---|
date | Mon, 30 Dec 2002 17:20:06 +0000 |
parents | 8aaba207e44b |
children | 30c4902b654d |
rev | line source |
---|---|
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1 ;;; mh-seq.el --- MH-E sequences support |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
2 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
3 ;; Copyright (C) 1993, 1995, 2001, 2002 Free Software Foundation, Inc. |
6365 | 4 |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
5 ;; Author: Bill Wohler <wohler@newt.com> |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
6 ;; Maintainer: Bill Wohler <wohler@newt.com> |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
7 ;; Keywords: mail |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
8 ;; See: mh-e.el |
6365 | 9 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
14425
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
6365 | 11 |
11333 | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
6365 | 13 ;; it under the terms of the GNU General Public License as published by |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
11333 | 17 ;; GNU Emacs is distributed in the hope that it will be useful, |
6365 | 18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
6365 | 26 |
27 ;;; Commentary: | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
28 ;; |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
29 ;; This tries to implement the algorithm described at: |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
30 ;; http://www.jwz.org/doc/threading.html |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
31 ;; It is also a start to implementing the IMAP Threading extension RFC. The |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
32 ;; implementation lacks the reference and subject canonicalization of the |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
33 ;; RFC. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
34 ;; |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
35 ;; In the presentation buffer, children messages are shown indented with |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
36 ;; either [ ] or < > around them. Square brackets ([ ]) denote that the |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
37 ;; algorithm can point out some headers which when taken together implies |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
38 ;; that the unindented message is an ancestor of the indented message. If |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
39 ;; no such proof exists then angles (< >) are used. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
40 ;; |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
41 ;; Some issues and problems are as follows: |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
42 ;; |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
43 ;; (1) Scan truncates the fields at length 512. So longer references: |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
44 ;; headers get mutilated. The same kind of MH format string works when |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
45 ;; composing messages. Is there a way to avoid this? My scan command |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
46 ;; is as follows: |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
47 ;; scan +folder -width 10000 \ |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
48 ;; -format "%(msg)\n%{message-id}\n%{references}\n%{subject}\n" |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
49 ;; I would really appreciate it if someone would help me with this. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
50 ;; |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
51 ;; (2) Implement heuristics to recognize message-id's in In-Reply-To: |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
52 ;; header. Right now it just assumes that the last text between angles |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
53 ;; (< and >) is the message-id. There is the chance that this will |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
54 ;; incorrectly use an email address like a message-id. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
55 ;; |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
56 ;; (3) Error checking of found message-id's should be done. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
57 ;; |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
58 ;; (4) Since this breaks the assumption that message indices increase as |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
59 ;; one goes down the buffer, the binary search based mh-goto-msg |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
60 ;; doesn't work. I have a simpler replacement which may be less |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
61 ;; efficient. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
62 ;; |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
63 ;; (5) Better canonicalizing for message-id and subject strings. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
64 ;; |
6365 | 65 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
66 ;; Internal support for MH-E package. |
6365 | 67 |
11332 | 68 ;;; Change Log: |
69 | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
70 ;; $Id: mh-seq.el,v 1.71 2002/11/14 20:41:12 wohler Exp $ |
11332 | 71 |
6365 | 72 ;;; Code: |
73 | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
74 (require 'cl) |
6365 | 75 (require 'mh-e) |
76 | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
77 ;; Shush the byte-compiler |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
78 (defvar tool-bar-mode) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
79 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
80 ;;; Data structures (used in message threading)... |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
81 (defstruct (mh-thread-message (:conc-name mh-message-) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
82 (:constructor mh-thread-make-message)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
83 (id nil) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
84 (references ()) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
85 (subject "") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
86 (subject-re-p nil)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
87 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
88 (defstruct (mh-thread-container (:conc-name mh-container-) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
89 (:constructor mh-thread-make-container)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
90 message parent children |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
91 (real-child-p t)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
92 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
93 |
11332 | 94 ;;; Internal variables: |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
95 (defvar mh-last-seq-used nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
96 "Name of seq to which a msg was last added.") |
11332 | 97 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
98 (defvar mh-non-seq-mode-line-annotation nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
99 "Saved value of `mh-mode-line-annotation' when narrowed to a seq.") |
11332 | 100 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
101 ;;; Maps and hashes... |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
102 (defvar mh-thread-id-hash nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
103 "Hashtable used to canonicalize message-id strings.") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
104 (defvar mh-thread-subject-hash nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
105 "Hashtable used to canonicalize subject strings.") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
106 (defvar mh-thread-id-table nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
107 "Thread ID table maps from message-id's to message containers.") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
108 (defvar mh-thread-id-index-map nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
109 "Table to lookup message index number from message-id.") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
110 (defvar mh-thread-index-id-map nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
111 "Table to lookup message-id from message index.") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
112 (defvar mh-thread-scan-line-map nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
113 "Map of message index to various parts of the scan line.") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
114 (defvar mh-thread-old-scan-line-map nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
115 "Old map of message index to various parts of the scan line. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
116 This is the original map that is stored when the folder is narrowed.") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
117 (defvar mh-thread-subject-container-hash nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
118 "Hashtable used to group messages by subject.") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
119 (defvar mh-thread-duplicates nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
120 "Hashtable used to remember multiple messages with the same message-id.") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
121 (defvar mh-thread-history () |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
122 "Variable to remember the transformations to the thread tree. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
123 When new messages are added, these transformations are rewound, then the |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
124 links are added from the newly seen messages. Finally the transformations are |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
125 redone to get the new thread tree. This makes incremental threading easier.") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
126 (defvar mh-thread-body-width nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
127 "Width of scan substring that contains subject and body of message.") |
6365 | 128 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
129 (make-variable-buffer-local 'mh-thread-id-hash) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
130 (make-variable-buffer-local 'mh-thread-subject-hash) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
131 (make-variable-buffer-local 'mh-thread-id-table) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
132 (make-variable-buffer-local 'mh-thread-id-index-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
133 (make-variable-buffer-local 'mh-thread-index-id-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
134 (make-variable-buffer-local 'mh-thread-scan-line-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
135 (make-variable-buffer-local 'mh-thread-old-scan-line-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
136 (make-variable-buffer-local 'mh-thread-subject-container-hash) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
137 (make-variable-buffer-local 'mh-thread-duplicates) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
138 (make-variable-buffer-local 'mh-thread-history) |
6365 | 139 |
11332 | 140 (defun mh-delete-seq (sequence) |
6365 | 141 "Delete the SEQUENCE." |
142 (interactive (list (mh-read-seq-default "Delete" t))) | |
11332 | 143 (mh-map-to-seq-msgs 'mh-notate-if-in-one-seq sequence ? (1+ mh-cmd-note) |
144 sequence) | |
145 (mh-undefine-sequence sequence '("all")) | |
146 (mh-delete-seq-locally sequence)) | |
6365 | 147 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
148 ;; Avoid compiler warnings |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
149 (defvar view-exit-action) |
6365 | 150 |
151 (defun mh-list-sequences (folder) | |
152 "List the sequences defined in FOLDER." | |
153 (interactive (list (mh-prompt-for-folder "List sequences in" | |
154 mh-current-folder t))) | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
155 (let ((temp-buffer mh-temp-sequences-buffer) |
6365 | 156 (seq-list mh-seq-list)) |
157 (with-output-to-temp-buffer temp-buffer | |
158 (save-excursion | |
159 (set-buffer temp-buffer) | |
160 (erase-buffer) | |
161 (message "Listing sequences ...") | |
162 (insert "Sequences in folder " folder ":\n") | |
163 (while seq-list | |
164 (let ((name (mh-seq-name (car seq-list))) | |
165 (sorted-seq-msgs | |
166 (sort (copy-sequence (mh-seq-msgs (car seq-list))) '<)) | |
167 (last-col (- (window-width) 4)) | |
168 name-spec) | |
169 (insert (setq name-spec (format "%20s:" name))) | |
170 (while sorted-seq-msgs | |
171 (if (> (current-column) last-col) | |
172 (progn | |
173 (insert "\n") | |
174 (move-to-column (length name-spec)))) | |
175 (insert (format " %s" (car sorted-seq-msgs))) | |
176 (setq sorted-seq-msgs (cdr sorted-seq-msgs))) | |
177 (insert "\n")) | |
178 (setq seq-list (cdr seq-list))) | |
179 (goto-char (point-min)) | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
180 (view-mode 1) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
181 (setq view-exit-action 'kill-buffer) |
6365 | 182 (message "Listing sequences...done"))))) |
183 | |
11332 | 184 (defun mh-msg-is-in-seq (message) |
185 "Display the sequences that contain MESSAGE (default: current message)." | |
6365 | 186 (interactive (list (mh-get-msg-num t))) |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
187 (let* ((dest-folder (loop for seq in mh-refile-list |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
188 when (member message (cdr seq)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
189 return (car seq))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
190 (deleted-flag (unless dest-folder (member message mh-delete-list)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
191 (message "Message %d%s is in sequences: %s" |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
192 message |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
193 (cond (dest-folder (format " (to be refiled to %s)" dest-folder)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
194 (deleted-flag (format " (to be deleted)")) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
195 (t "")) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
196 (mapconcat 'concat |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
197 (mh-list-to-string (mh-seq-containing-msg message t)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
198 " ")))) |
6365 | 199 |
11332 | 200 (defun mh-narrow-to-seq (sequence) |
201 "Restrict display of this folder to just messages in SEQUENCE. | |
202 Use \\<mh-folder-mode-map>\\[mh-widen] to undo this command." | |
6365 | 203 (interactive (list (mh-read-seq "Narrow to" t))) |
11332 | 204 (with-mh-folder-updating (t) |
205 (cond ((mh-seq-to-msgs sequence) | |
206 (mh-widen) | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
207 (mh-remove-all-notation) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
208 (let ((eob (point-max)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
209 (msg-at-cursor (mh-get-msg-num nil))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
210 (setq mh-thread-old-scan-line-map mh-thread-scan-line-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
211 (setq mh-thread-scan-line-map (make-hash-table :test #'eql)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
212 (mh-copy-seq-to-eob sequence) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
213 (narrow-to-region eob (point-max)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
214 (mh-notate-user-sequences) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
215 (mh-notate-deleted-and-refiled) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
216 (mh-notate-seq 'cur mh-note-cur mh-cmd-note) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
217 (when msg-at-cursor (mh-goto-msg msg-at-cursor t t)) |
11332 | 218 (make-variable-buffer-local 'mh-non-seq-mode-line-annotation) |
219 (setq mh-non-seq-mode-line-annotation mh-mode-line-annotation) | |
220 (setq mh-mode-line-annotation (symbol-name sequence)) | |
221 (mh-make-folder-mode-line) | |
6365 | 222 (mh-recenter nil) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
223 (if (and (boundp 'tool-bar-mode) tool-bar-mode) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
224 (set (make-local-variable 'tool-bar-map) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
225 mh-folder-seq-tool-bar-map)) |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
226 (setq mh-narrowed-to-seq sequence) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
227 (push 'widen mh-view-ops))) |
11332 | 228 (t |
229 (error "No messages in sequence `%s'" (symbol-name sequence)))))) | |
6365 | 230 |
11332 | 231 (defun mh-put-msg-in-seq (msg-or-seq sequence) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
232 "Add MSG-OR-SEQ (default: displayed message) to SEQUENCE. |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
233 If optional prefix argument provided, then prompt for the message sequence. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
234 If variable `transient-mark-mode' is non-nil and the mark is active, then |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
235 the selected region is added to the sequence." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
236 (interactive (list (cond |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
237 ((mh-mark-active-p t) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
238 (mh-region-to-sequence (region-beginning) (region-end)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
239 'region) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
240 (current-prefix-arg |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
241 (mh-read-seq-default "Add messages from" t)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
242 (t |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
243 (mh-get-msg-num t))) |
6365 | 244 (mh-read-seq-default "Add to" nil))) |
11332 | 245 (if (not (mh-internal-seq sequence)) |
246 (setq mh-last-seq-used sequence)) | |
6365 | 247 (mh-add-msgs-to-seq (if (numberp msg-or-seq) |
248 msg-or-seq | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
249 (mh-seq-to-msgs msg-or-seq)) |
11332 | 250 sequence)) |
6365 | 251 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
252 (defun mh-valid-view-change-operation-p (op) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
253 "Check if the view change operation can be performed. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
254 OP is one of 'widen and 'unthread." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
255 (cond ((eq (car mh-view-ops) op) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
256 (pop mh-view-ops)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
257 (t nil))) |
6365 | 258 |
259 (defun mh-widen () | |
260 "Remove restrictions from current folder, thereby showing all messages." | |
261 (interactive) | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
262 (let ((msg (mh-get-msg-num nil))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
263 (when mh-narrowed-to-seq |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
264 (cond ((mh-valid-view-change-operation-p 'widen) nil) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
265 ((memq 'widen mh-view-ops) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
266 (while (not (eq (car mh-view-ops) 'widen)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
267 (setq mh-view-ops (cdr mh-view-ops))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
268 (pop mh-view-ops)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
269 (t (error "Widening is not applicable"))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
270 (when (memq 'unthread mh-view-ops) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
271 (setq mh-thread-scan-line-map mh-thread-old-scan-line-map)) |
6365 | 272 (with-mh-folder-updating (t) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
273 (delete-region (point-min) (point-max)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
274 (widen) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
275 (setq mh-mode-line-annotation mh-non-seq-mode-line-annotation) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
276 (mh-make-folder-mode-line)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
277 (if msg |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
278 (mh-goto-msg msg t t)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
279 (mh-notate-deleted-and-refiled) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
280 (mh-notate-user-sequences) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
281 (mh-notate-seq 'cur mh-note-cur mh-cmd-note) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
282 (mh-recenter nil))) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
283 (if (and (boundp 'tool-bar-mode) tool-bar-mode) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
284 (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map)) |
6365 | 285 (setq mh-narrowed-to-seq nil)) |
286 | |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
287 ;; FIXME? We may want to clear all notations and add one for current-message |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
288 ;; and process user sequences. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
289 (defun mh-notate-deleted-and-refiled () |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
290 "Notate messages marked for deletion or refiling. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
291 Messages to be deleted are given by `mh-delete-list' while messages to be |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
292 refiled are present in `mh-refile-list'." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
293 (mh-mapc #'(lambda (msg) (mh-notate msg mh-note-deleted mh-cmd-note)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
294 mh-delete-list) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
295 (mh-mapc #'(lambda (dest-msg-list) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
296 ;; foreach folder name, get the keyed sequence from mh-seq-list |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
297 (let ((msg-list (cdr dest-msg-list))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
298 (mh-mapc #'(lambda (msg) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
299 (mh-notate msg mh-note-refiled mh-cmd-note)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
300 msg-list))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
301 mh-refile-list)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
302 |
6365 | 303 |
304 | |
305 ;;; Commands to manipulate sequences. Sequences are stored in an alist | |
306 ;;; of the form: | |
307 ;;; ((seq-name msgs ...) (seq-name msgs ...) ...) | |
308 | |
309 (defun mh-read-seq-default (prompt not-empty) | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
310 "Read and return sequence name with default narrowed or previous sequence. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
311 PROMPT is the prompt to use when reading. If NOT-EMPTY is non-nil then a |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
312 non-empty sequence is read." |
11332 | 313 (mh-read-seq prompt not-empty |
314 (or mh-narrowed-to-seq | |
315 mh-last-seq-used | |
316 (car (mh-seq-containing-msg (mh-get-msg-num nil) nil))))) | |
6365 | 317 |
318 (defun mh-read-seq (prompt not-empty &optional default) | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
319 "Read and return a sequence name. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
320 Prompt with PROMPT, raise an error if the sequence is empty and the NOT-EMPTY |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
321 flag is non-nil, and supply an optional DEFAULT sequence. A reply of '%' |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
322 defaults to the first sequence containing the current message." |
6365 | 323 (let* ((input (completing-read (format "%s %s %s" prompt "sequence:" |
324 (if default | |
325 (format "[%s] " default) | |
326 "")) | |
327 (mh-seq-names mh-seq-list))) | |
11332 | 328 (seq (cond ((equal input "%") |
329 (car (mh-seq-containing-msg (mh-get-msg-num t) nil))) | |
6365 | 330 ((equal input "") default) |
331 (t (intern input)))) | |
332 (msgs (mh-seq-to-msgs seq))) | |
333 (if (and (null msgs) not-empty) | |
14425
8109feeaf627
(mh-read-seq): Fix error format string.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
334 (error "No messages in sequence `%s'" seq)) |
6365 | 335 seq)) |
336 | |
337 (defun mh-seq-names (seq-list) | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
338 "Return an alist containing the names of the SEQ-LIST." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
339 (mapcar (lambda (entry) (list (symbol-name (mh-seq-name entry)))) |
6365 | 340 seq-list)) |
341 | |
11332 | 342 (defun mh-rename-seq (sequence new-name) |
343 "Rename SEQUENCE to have NEW-NAME." | |
6365 | 344 (interactive (list (mh-read-seq "Old" t) |
345 (intern (read-string "New sequence name: ")))) | |
11332 | 346 (let ((old-seq (mh-find-seq sequence))) |
6365 | 347 (or old-seq |
11332 | 348 (error "Sequence %s does not exist" sequence)) |
349 ;; create new sequence first, since it might raise an error. | |
6365 | 350 (mh-define-sequence new-name (mh-seq-msgs old-seq)) |
11332 | 351 (mh-undefine-sequence sequence (mh-seq-msgs old-seq)) |
6365 | 352 (rplaca old-seq new-name))) |
353 | |
354 (defun mh-map-to-seq-msgs (func seq &rest args) | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
355 "Invoke the FUNC at each message in the SEQ. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
356 The remaining ARGS are passed as arguments to FUNC." |
6365 | 357 (save-excursion |
358 (let ((msgs (mh-seq-to-msgs seq))) | |
359 (while msgs | |
360 (if (mh-goto-msg (car msgs) t t) | |
361 (apply func (car msgs) args)) | |
362 (setq msgs (cdr msgs)))))) | |
363 | |
364 (defun mh-notate-seq (seq notation offset) | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
365 "Mark the scan listing. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
366 All messages in SEQ are marked with NOTATION at OFFSET from the beginning of |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
367 the line." |
6365 | 368 (mh-map-to-seq-msgs 'mh-notate seq notation offset)) |
369 | |
370 (defun mh-add-to-sequence (seq msgs) | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
371 "The sequence SEQ is augmented with the messages in MSGS." |
6365 | 372 ;; Add to a SEQUENCE each message the list of MSGS. |
373 (if (not (mh-folder-name-p seq)) | |
374 (if msgs | |
375 (apply 'mh-exec-cmd "mark" mh-current-folder "-add" | |
376 "-sequence" (symbol-name seq) | |
11332 | 377 (mh-coalesce-msg-list msgs))))) |
6365 | 378 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
379 ;; This has a tricky bug. mh-map-to-seq-msgs uses mh-goto-msg, which assumes |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
380 ;; that the folder buffer is sorted. However in this case that assumption |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
381 ;; doesn't hold. So we will do this the dumb way. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
382 ;(defun mh-copy-seq-to-point (seq location) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
383 ; ;; Copy the scan listing of the messages in SEQUENCE to after the point |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
384 ; ;; LOCATION in the current buffer. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
385 ; (mh-map-to-seq-msgs 'mh-copy-line-to-point seq location)) |
6365 | 386 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
387 (defun mh-copy-seq-to-eob (seq) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
388 "Copy SEQ to the end of the buffer." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
389 ;; It is quite involved to write something which will work at any place in |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
390 ;; the buffer, so we will write something which works only at the end of |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
391 ;; the buffer. If we ever need to insert sequences in the middle of the |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
392 ;; buffer, this will need to be fixed. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
393 (save-excursion |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
394 (let* ((msgs (mh-seq-to-msgs seq)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
395 (coalesced-msgs (mh-coalesce-msg-list msgs))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
396 (goto-char (point-max)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
397 (save-restriction |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
398 (narrow-to-region (point) (point)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
399 (mh-regenerate-headers coalesced-msgs t) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
400 (when (memq 'unthread mh-view-ops) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
401 ;; Populate restricted scan-line map |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
402 (goto-char (point-min)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
403 (while (not (eobp)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
404 (setf (gethash (mh-get-msg-num nil) mh-thread-scan-line-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
405 (mh-thread-parse-scan-line)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
406 (forward-line)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
407 ;; Remove scan lines and read results from pre-computed thread tree |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
408 (delete-region (point-min) (point-max)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
409 (let ((thread-tree (mh-thread-generate mh-current-folder ())) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
410 (mh-thread-body-width |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
411 (- (window-width) mh-cmd-note |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
412 (1- mh-scan-field-subject-start-offset)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
413 (mh-thread-generate-scan-lines thread-tree -2))))))) |
6365 | 414 |
415 (defun mh-copy-line-to-point (msg location) | |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
416 "Copy current message line to a specific location. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
417 The argument MSG is not used. The message in the current line is copied to |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
418 LOCATION." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
419 ;; msg is not used? |
6365 | 420 ;; Copy the current line to the LOCATION in the current buffer. |
421 (beginning-of-line) | |
11332 | 422 (save-excursion |
423 (let ((beginning-of-line (point)) | |
424 end) | |
425 (forward-line 1) | |
426 (setq end (point)) | |
427 (goto-char location) | |
428 (insert-buffer-substring (current-buffer) beginning-of-line end)))) | |
6365 | 429 |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
430 (defun mh-region-to-sequence (begin end) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
431 "Define sequence 'region as the messages between point and mark. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
432 When called programmatically, use arguments BEGIN and END to define region." |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
433 (interactive "r") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
434 (mh-delete-seq-locally 'region) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
435 (save-excursion |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
436 ;; If end is end of buffer back up one position |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
437 (setq end (if (equal end (point-max)) (1- end) end)) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
438 (goto-char begin) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
439 (while (<= (point) end) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
440 (mh-add-msgs-to-seq (mh-get-msg-num t) 'region t) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
441 (forward-line 1)))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
442 |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
443 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
444 |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
445 ;;; Commands to handle new 'subject sequence. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
446 ;;; Or "Poor man's threading" by psg. |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
447 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
448 (defun mh-subject-to-sequence (all) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
449 "Put all following messages with same subject in sequence 'subject. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
450 If arg ALL is t, move to beginning of folder buffer to collect all messages. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
451 If arg ALL is nil, collect only messages fron current one on forward. |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
452 |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
453 Return number of messages put in the sequence: |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
454 |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
455 nil -> there was no subject line. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
456 0 -> there were no later messages with the same subject (sequence not made) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
457 >1 -> the total number of messages including current one." |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
458 (if (not (eq major-mode 'mh-folder-mode)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
459 (error "Not in a folder buffer")) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
460 (save-excursion |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
461 (beginning-of-line) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
462 (if (or (not (looking-at mh-scan-subject-regexp)) |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
463 (not (match-string 3)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
464 (string-equal "" (match-string 3))) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
465 (progn (message "No subject line.") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
466 nil) |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
467 (let ((subject (match-string-no-properties 3)) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
468 (list)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
469 (if (> (length subject) 41) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
470 (setq subject (substring subject 0 41))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
471 (save-excursion |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
472 (if all |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
473 (goto-char (point-min))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
474 (while (re-search-forward mh-scan-subject-regexp nil t) |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
475 (let ((this-subject (match-string-no-properties 3))) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
476 (if (> (length this-subject) 41) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
477 (setq this-subject (substring this-subject 0 41))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
478 (if (string-equal this-subject subject) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
479 (setq list (cons (mh-get-msg-num t) list)))))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
480 (cond |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
481 (list |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
482 ;; If we created a new sequence, add the initial message to it too. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
483 (if (not (member (mh-get-msg-num t) list)) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
484 (setq list (cons (mh-get-msg-num t) list))) |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
485 (if (member '("subject") (mh-seq-names mh-seq-list)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
486 (mh-delete-seq 'subject)) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
487 ;; sort the result into a sequence |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
488 (let ((sorted-list (sort (copy-sequence list) 'mh-lessp))) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
489 (while sorted-list |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
490 (mh-add-msgs-to-seq (car sorted-list) 'subject nil) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
491 (setq sorted-list (cdr sorted-list))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
492 (safe-length list))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
493 (t |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
494 0)))))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
495 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
496 (defun mh-narrow-to-subject () |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
497 "Narrow to a sequence containing all following messages with same subject." |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
498 (interactive) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
499 (let ((num (mh-get-msg-num nil)) |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
500 (count (mh-subject-to-sequence t))) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
501 (cond |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
502 ((not count) ; No subject line, delete msg anyway |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
503 nil) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
504 ((= 0 count) ; No other msgs, delete msg anyway. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
505 (message "No other messages with same Subject following this one.") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
506 nil) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
507 (t ; We have a subject sequence. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
508 (message "Found %d messages for subject sequence." count) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
509 (mh-narrow-to-seq 'subject) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
510 (if (numberp num) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
511 (mh-goto-msg num t t)))))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
512 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
513 (defun mh-delete-subject () |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
514 "Mark all following messages with same subject to be deleted. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
515 This puts the messages in a sequence named subject. You can undo the last |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
516 deletion marks using `mh-undo' with a prefix argument and then specifying the |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
517 subject sequence." |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
518 (interactive) |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
519 (let ((count (mh-subject-to-sequence nil))) |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
520 (cond |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
521 ((not count) ; No subject line, delete msg anyway |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
522 (mh-delete-msg (mh-get-msg-num t))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
523 ((= 0 count) ; No other msgs, delete msg anyway. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
524 (message "No other messages with same Subject following this one.") |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
525 (mh-delete-msg (mh-get-msg-num t))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
526 (t ; We have a subject sequence. |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
527 (message "Marked %d messages for deletion" count) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
528 (mh-delete-msg 'subject))))) |
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
529 |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
530 ;;; Message threading: |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
531 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
532 (defun mh-thread-initialize () |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
533 "Make hash tables, otherwise clear them." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
534 (cond |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
535 (mh-thread-id-hash |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
536 (clrhash mh-thread-id-hash) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
537 (clrhash mh-thread-subject-hash) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
538 (clrhash mh-thread-id-table) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
539 (clrhash mh-thread-id-index-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
540 (clrhash mh-thread-index-id-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
541 (clrhash mh-thread-scan-line-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
542 (clrhash mh-thread-subject-container-hash) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
543 (clrhash mh-thread-duplicates) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
544 (setq mh-thread-history ())) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
545 (t (setq mh-thread-id-hash (make-hash-table :test #'equal)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
546 (setq mh-thread-subject-hash (make-hash-table :test #'equal)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
547 (setq mh-thread-id-table (make-hash-table :test #'eq)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
548 (setq mh-thread-id-index-map (make-hash-table :test #'eq)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
549 (setq mh-thread-index-id-map (make-hash-table :test #'eql)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
550 (setq mh-thread-scan-line-map (make-hash-table :test #'eql)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
551 (setq mh-thread-subject-container-hash (make-hash-table :test #'eq)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
552 (setq mh-thread-duplicates (make-hash-table :test #'eq)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
553 (setq mh-thread-history ())))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
554 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
555 (defsubst mh-thread-id-container (id) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
556 "Given ID, return the corresponding container in `mh-thread-id-table'. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
557 If no container exists then a suitable container is created and the id-table |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
558 is updated." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
559 (when (not id) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
560 (error "1")) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
561 (or (gethash id mh-thread-id-table) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
562 (setf (gethash id mh-thread-id-table) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
563 (let ((message (mh-thread-make-message :id id))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
564 (mh-thread-make-container :message message))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
565 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
566 (defsubst mh-thread-remove-parent-link (child) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
567 "Remove parent link of CHILD if it exists." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
568 (let* ((child-container (if (mh-thread-container-p child) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
569 child (mh-thread-id-container child))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
570 (parent-container (mh-container-parent child-container))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
571 (when parent-container |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
572 (setf (mh-container-children parent-container) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
573 (remove* child-container (mh-container-children parent-container) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
574 :test #'eq)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
575 (setf (mh-container-parent child-container) nil)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
576 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
577 (defsubst mh-thread-add-link (parent child &optional at-end-p) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
578 "Add links so that PARENT becomes a parent of CHILD. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
579 Doesn't make any changes if CHILD is already an ancestor of PARENT. If |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
580 optional argument AT-END-P is non-nil, the CHILD is added to the end of the |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
581 children list of PARENT." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
582 (let ((parent-container (cond ((null parent) nil) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
583 ((mh-thread-container-p parent) parent) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
584 (t (mh-thread-id-container parent)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
585 (child-container (if (mh-thread-container-p child) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
586 child (mh-thread-id-container child)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
587 (when (and parent-container |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
588 (not (mh-thread-ancestor-p child-container parent-container)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
589 (not (mh-thread-ancestor-p parent-container child-container))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
590 (mh-thread-remove-parent-link child-container) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
591 (cond ((not at-end-p) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
592 (push child-container (mh-container-children parent-container))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
593 ((null (mh-container-children parent-container)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
594 (push child-container (mh-container-children parent-container))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
595 (t (let ((last-child (mh-container-children parent-container))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
596 (while (cdr last-child) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
597 (setq last-child (cdr last-child))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
598 (setcdr last-child (cons child-container nil))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
599 (setf (mh-container-parent child-container) parent-container)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
600 (unless parent-container |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
601 (mh-thread-remove-parent-link child-container)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
602 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
603 (defun mh-thread-ancestor-p (ancestor successor) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
604 "Return t if ANCESTOR is really an ancestor of SUCCESSOR and nil otherwise. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
605 In the limit, the function returns t if ANCESTOR and SUCCESSOR are the same |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
606 containers." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
607 (block nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
608 (while successor |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
609 (when (eq ancestor successor) (return t)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
610 (setq successor (mh-container-parent successor))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
611 nil)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
612 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
613 (defsubst mh-thread-get-message-container (message) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
614 "Return container which has MESSAGE in it. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
615 If there is no container present then a new container is allocated." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
616 (let* ((id (mh-message-id message)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
617 (container (gethash id mh-thread-id-table))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
618 (cond (container (setf (mh-container-message container) message) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
619 container) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
620 (t (setf (gethash id mh-thread-id-table) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
621 (mh-thread-make-container :message message)))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
622 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
623 (defsubst mh-thread-get-message (id subject-re-p subject refs) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
624 "Return appropriate message. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
625 Otherwise update message already present to have the proper ID, SUBJECT-RE-P, |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
626 SUBJECT and REFS fields." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
627 (let* ((container (gethash id mh-thread-id-table)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
628 (message (if container (mh-container-message container) nil))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
629 (cond (message |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
630 (setf (mh-message-subject-re-p message) subject-re-p) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
631 (setf (mh-message-subject message) subject) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
632 (setf (mh-message-id message) id) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
633 (setf (mh-message-references message) refs) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
634 message) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
635 (container |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
636 (setf (mh-container-message container) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
637 (mh-thread-make-message :subject subject |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
638 :subject-re-p subject-re-p |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
639 :id id :references refs))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
640 (t (let ((message (mh-thread-make-message |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
641 :subject subject |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
642 :subject-re-p subject-re-p |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
643 :id id :references refs))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
644 (prog1 message |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
645 (mh-thread-get-message-container message))))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
646 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
647 (defsubst mh-thread-canonicalize-id (id) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
648 "Produce canonical string representation for ID. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
649 This allows cheap string comparison with EQ." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
650 (or (and (equal id "") (copy-sequence "")) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
651 (gethash id mh-thread-id-hash) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
652 (setf (gethash id mh-thread-id-hash) id))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
653 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
654 (defsubst mh-thread-prune-subject (subject) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
655 "Prune leading Re:'s, Fwd:'s etc. and trailing (fwd)'s from SUBJECT. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
656 If the result after pruning is not the empty string then it is canonicalized |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
657 so that subjects can be tested for equality with eq. This is done so that all |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
658 the messages without a subject are not put into a single thread." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
659 (let ((case-fold-search t) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
660 (subject-pruned-flag nil)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
661 ;; Prune subject leader |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
662 (while (or (string-match "^[ \t]*\\(re\\|fwd?\\)\\(\\[[0-9]*\\]\\)?:[ \t]*" |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
663 subject) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
664 (string-match "^[ \t]*\\[[^\\]][ \t]*" subject)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
665 (setq subject-pruned-flag t) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
666 (setq subject (substring subject (match-end 0)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
667 ;; Prune subject trailer |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
668 (while (or (string-match "(fwd)$" subject) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
669 (string-match "[ \t]+$" subject)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
670 (setq subject-pruned-flag t) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
671 (setq subject (substring subject 0 (match-beginning 0)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
672 ;; Canonicalize subject only if it is non-empty |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
673 (cond ((equal subject "") (values subject subject-pruned-flag)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
674 (t (values |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
675 (or (gethash subject mh-thread-subject-hash) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
676 (setf (gethash subject mh-thread-subject-hash) subject)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
677 subject-pruned-flag))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
678 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
679 (defun mh-thread-container-subject (container) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
680 "Return the subject of CONTAINER. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
681 If CONTAINER is empty return the subject info of one of its children." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
682 (cond ((and (mh-container-message container) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
683 (mh-message-id (mh-container-message container))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
684 (mh-message-subject (mh-container-message container))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
685 (t (block nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
686 (dolist (kid (mh-container-children container)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
687 (when (and (mh-container-message kid) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
688 (mh-message-id (mh-container-message kid))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
689 (let ((kid-message (mh-container-message kid))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
690 (return (mh-message-subject kid-message))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
691 (error "This can't happen!"))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
692 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
693 (defun mh-thread-rewind-pruning () |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
694 "Restore the thread tree to its state before pruning." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
695 (while mh-thread-history |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
696 (let ((action (pop mh-thread-history))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
697 (cond ((eq (car action) 'DROP) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
698 (mh-thread-remove-parent-link (cadr action)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
699 (mh-thread-add-link (caddr action) (cadr action))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
700 ((eq (car action) 'PROMOTE) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
701 (let ((node (cadr action)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
702 (parent (caddr action)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
703 (children (cdddr action))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
704 (dolist (child children) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
705 (mh-thread-remove-parent-link child) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
706 (mh-thread-add-link node child)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
707 (mh-thread-add-link parent node))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
708 ((eq (car action) 'SUBJECT) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
709 (let ((node (cadr action))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
710 (mh-thread-remove-parent-link node) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
711 (setf (mh-container-real-child-p node) t))))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
712 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
713 (defun mh-thread-prune-containers (roots) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
714 "Prune empty containers in the containers ROOTS." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
715 (let ((dfs-ordered-nodes ()) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
716 (work-list roots)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
717 (while work-list |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
718 (let ((node (pop work-list))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
719 (dolist (child (mh-container-children node)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
720 (push child work-list)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
721 (push node dfs-ordered-nodes))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
722 (while dfs-ordered-nodes |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
723 (let ((node (pop dfs-ordered-nodes))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
724 (cond ((gethash (mh-message-id (mh-container-message node)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
725 mh-thread-id-index-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
726 ;; Keep it |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
727 (setf (mh-container-children node) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
728 (mh-thread-sort-containers (mh-container-children node)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
729 ((and (mh-container-children node) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
730 (or (null (cdr (mh-container-children node))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
731 (mh-container-parent node))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
732 ;; Promote kids |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
733 (let ((children ())) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
734 (dolist (kid (mh-container-children node)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
735 (mh-thread-remove-parent-link kid) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
736 (mh-thread-add-link (mh-container-parent node) kid) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
737 (push kid children)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
738 (push `(PROMOTE ,node ,(mh-container-parent node) ,@children) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
739 mh-thread-history) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
740 (mh-thread-remove-parent-link node))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
741 ((mh-container-children node) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
742 ;; Promote the first orphan to parent and add the other kids as |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
743 ;; his children |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
744 (setf (mh-container-children node) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
745 (mh-thread-sort-containers (mh-container-children node))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
746 (let ((new-parent (car (mh-container-children node))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
747 (other-kids (cdr (mh-container-children node)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
748 (mh-thread-remove-parent-link new-parent) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
749 (dolist (kid other-kids) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
750 (mh-thread-remove-parent-link kid) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
751 (setf (mh-container-real-child-p kid) nil) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
752 (mh-thread-add-link new-parent kid t)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
753 (push `(PROMOTE ,node ,(mh-container-parent node) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
754 ,new-parent ,@other-kids) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
755 mh-thread-history) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
756 (mh-thread-remove-parent-link node))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
757 (t |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
758 ;; Drop it |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
759 (push `(DROP ,node ,(mh-container-parent node)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
760 mh-thread-history) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
761 (mh-thread-remove-parent-link node))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
762 (let ((results ())) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
763 (maphash #'(lambda (k v) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
764 (declare (ignore k)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
765 (when (and (null (mh-container-parent v)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
766 (gethash (mh-message-id (mh-container-message v)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
767 mh-thread-id-index-map)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
768 (push v results))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
769 mh-thread-id-table) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
770 (mh-thread-sort-containers results)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
771 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
772 (defun mh-thread-sort-containers (containers) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
773 "Sort a list of message CONTAINERS to be in ascending order wrt index." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
774 (sort containers |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
775 #'(lambda (x y) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
776 (when (and (mh-container-message x) (mh-container-message y)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
777 (let* ((id-x (mh-message-id (mh-container-message x))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
778 (id-y (mh-message-id (mh-container-message y))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
779 (index-x (gethash id-x mh-thread-id-index-map)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
780 (index-y (gethash id-y mh-thread-id-index-map))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
781 (and (integerp index-x) (integerp index-y) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
782 (< index-x index-y))))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
783 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
784 (defsubst mh-thread-group-by-subject (roots) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
785 "Group the set of message containers, ROOTS based on subject. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
786 Bug: Check for and make sure that something without Re: is made the parent in |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
787 preference to something that has it." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
788 (clrhash mh-thread-subject-container-hash) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
789 (let ((results ())) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
790 (dolist (root roots) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
791 (let* ((subject (mh-thread-container-subject root)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
792 (parent (gethash subject mh-thread-subject-container-hash))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
793 (cond (parent (mh-thread-remove-parent-link root) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
794 (mh-thread-add-link parent root t) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
795 (setf (mh-container-real-child-p root) nil) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
796 (push `(SUBJECT ,root) mh-thread-history)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
797 (t |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
798 (setf (gethash subject mh-thread-subject-container-hash) root) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
799 (push root results))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
800 (nreverse results))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
801 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
802 (defsubst mh-thread-process-in-reply-to (reply-to-header) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
803 "Extract message id's from REPLY-TO-HEADER. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
804 Ideally this should have some regexp which will try to guess if a string |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
805 between < and > is a message id and not an email address. For now it will |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
806 take the last string inside angles." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
807 (let ((end (search ">" reply-to-header :from-end t))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
808 (when (numberp end) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
809 (let ((begin (search "<" reply-to-header :from-end t :end2 end))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
810 (when (numberp begin) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
811 (list (substring reply-to-header begin (1+ end)))))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
812 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
813 (defun mh-thread-set-tables (folder) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
814 "Use the tables of FOLDER in current buffer." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
815 (flet ((mh-get-table (symbol) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
816 (save-excursion (set-buffer folder) (symbol-value symbol)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
817 (setq mh-thread-id-hash (mh-get-table 'mh-thread-id-hash)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
818 (setq mh-thread-subject-hash (mh-get-table 'mh-thread-subject-hash)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
819 (setq mh-thread-id-table (mh-get-table 'mh-thread-id-table)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
820 (setq mh-thread-id-index-map (mh-get-table 'mh-thread-id-index-map)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
821 (setq mh-thread-index-id-map (mh-get-table 'mh-thread-index-id-map)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
822 (setq mh-thread-scan-line-map (mh-get-table 'mh-thread-scan-line-map)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
823 (setq mh-thread-subject-container-hash |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
824 (mh-get-table 'mh-thread-subject-container-hash)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
825 (setq mh-thread-duplicates (mh-get-table 'mh-thread-duplicates)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
826 (setq mh-thread-history (mh-get-table 'mh-thread-history)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
827 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
828 (defsubst mh-thread-update-id-index-maps (id index) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
829 "Message with id, ID is the message in INDEX. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
830 The function also checks for duplicate messages (that is multiple messages |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
831 with the same ID). These messages are put in the `mh-thread-duplicates' hash |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
832 table." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
833 (let ((old-index (gethash id mh-thread-id-index-map))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
834 (when old-index (push old-index (gethash id mh-thread-duplicates))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
835 (setf (gethash id mh-thread-id-index-map) index) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
836 (setf (gethash index mh-thread-index-id-map) id))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
837 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
838 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
839 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
840 ;;; Generate Threads... |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
841 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
842 (defun mh-thread-generate (folder msg-list) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
843 "Scan FOLDER to get info for threading. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
844 Only information about messages in MSG-LIST are added to the tree." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
845 (save-excursion |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
846 (set-buffer (get-buffer-create "*mh-thread*")) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
847 (mh-thread-set-tables folder) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
848 (erase-buffer) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
849 (when msg-list |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
850 (apply |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
851 #'call-process (expand-file-name mh-scan-prog mh-progs) nil '(t nil) nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
852 "-width" "10000" "-format" |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
853 "%(msg)\n%{message-id}\n%{references}\n%{in-reply-to}\n%{subject}\n" |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
854 (mapcar #'(lambda (x) (format "%s" x)) msg-list))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
855 (goto-char (point-min)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
856 (let ((roots ()) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
857 (case-fold-search t)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
858 (block nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
859 (while (not (eobp)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
860 (block process-message |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
861 (let* ((index-line |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
862 (prog1 (buffer-substring (point) (line-end-position)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
863 (forward-line))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
864 (index (car (read-from-string index-line))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
865 (id (prog1 (buffer-substring (point) (line-end-position)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
866 (forward-line))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
867 (refs (prog1 (buffer-substring (point) (line-end-position)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
868 (forward-line))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
869 (in-reply-to (prog1 (buffer-substring (point) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
870 (line-end-position)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
871 (forward-line))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
872 (subject (prog1 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
873 (buffer-substring (point) (line-end-position)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
874 (forward-line))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
875 (subject-re-p nil)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
876 (unless (gethash index mh-thread-scan-line-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
877 (return-from process-message)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
878 (unless (integerp index) (return)) ;Error message here |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
879 (multiple-value-setq (subject subject-re-p) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
880 (mh-thread-prune-subject subject)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
881 (setq in-reply-to (mh-thread-process-in-reply-to in-reply-to)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
882 (setq refs (append (split-string refs) in-reply-to)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
883 (setq id (mh-thread-canonicalize-id id)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
884 (mh-thread-update-id-index-maps id index) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
885 (setq refs (mapcar #'mh-thread-canonicalize-id refs)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
886 (mh-thread-get-message id subject-re-p subject refs) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
887 (do ((ancestors refs (cdr ancestors))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
888 ((null (cdr ancestors)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
889 (when (car ancestors) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
890 (mh-thread-remove-parent-link id) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
891 (mh-thread-add-link (car ancestors) id))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
892 (mh-thread-add-link (car ancestors) (cadr ancestors))))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
893 (maphash #'(lambda (k v) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
894 (declare (ignore k)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
895 (when (null (mh-container-parent v)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
896 (push v roots))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
897 mh-thread-id-table) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
898 (setq roots (mh-thread-prune-containers roots)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
899 (prog1 (setq roots (mh-thread-group-by-subject roots)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
900 (let ((history mh-thread-history)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
901 (set-buffer folder) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
902 (setq mh-thread-history history)))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
903 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
904 (defun mh-thread-inc (folder start-point) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
905 "Update thread tree for FOLDER. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
906 All messages after START-POINT are added to the thread tree." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
907 (mh-thread-rewind-pruning) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
908 (goto-char start-point) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
909 (let ((msg-list ())) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
910 (while (not (eobp)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
911 (let ((index (mh-get-msg-num nil))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
912 (push index msg-list) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
913 (setf (gethash index mh-thread-scan-line-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
914 (mh-thread-parse-scan-line)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
915 (forward-line))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
916 (let ((thread-tree (mh-thread-generate folder msg-list)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
917 (buffer-read-only nil) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
918 (old-buffer-modified-flag (buffer-modified-p))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
919 (delete-region (point-min) (point-max)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
920 (let ((mh-thread-body-width (- (window-width) mh-cmd-note |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
921 (1- mh-scan-field-subject-start-offset)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
922 (mh-thread-generate-scan-lines thread-tree -2)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
923 (mh-notate-user-sequences) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
924 (mh-notate-deleted-and-refiled) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
925 (mh-notate-seq 'cur mh-note-cur mh-cmd-note) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
926 (set-buffer-modified-p old-buffer-modified-flag)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
927 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
928 (defun mh-thread-generate-scan-lines (tree level) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
929 "Generate scan lines. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
930 TREE is the hierarchical tree of messages, SCAN-LINE-MAP maps message indices |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
931 to the corresponding scan lines and LEVEL used to determine indentation of |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
932 the message." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
933 (cond ((null tree) nil) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
934 ((mh-thread-container-p tree) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
935 (let* ((message (mh-container-message tree)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
936 (id (mh-message-id message)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
937 (index (gethash id mh-thread-id-index-map)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
938 (duplicates (gethash id mh-thread-duplicates)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
939 (new-level (+ level 2)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
940 (dupl-flag t) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
941 (increment-level-flag nil)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
942 (dolist (scan-line (mapcar (lambda (x) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
943 (gethash x mh-thread-scan-line-map)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
944 (reverse (cons index duplicates)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
945 (when scan-line |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
946 (insert (car scan-line) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
947 (format (format "%%%ss" |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
948 (if dupl-flag level new-level)) "") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
949 (if (and (mh-container-real-child-p tree) dupl-flag) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
950 "[" "<") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
951 (cadr scan-line) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
952 (if (and (mh-container-real-child-p tree) dupl-flag) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
953 "]" ">") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
954 (truncate-string-to-width |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
955 (caddr scan-line) (- mh-thread-body-width |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
956 (if dupl-flag level new-level))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
957 "\n") |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
958 (setq increment-level-flag t) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
959 (setq dupl-flag nil))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
960 (unless increment-level-flag (setq new-level level)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
961 (dolist (child (mh-container-children tree)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
962 (mh-thread-generate-scan-lines child new-level)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
963 (t (let ((nlevel (+ level 2))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
964 (dolist (ch tree) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
965 (mh-thread-generate-scan-lines ch nlevel)))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
966 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
967 ;; Another and may be better approach would be to generate all the info from |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
968 ;; the scan which generates the threading info. For now this will have to do. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
969 (defun mh-thread-parse-scan-line (&optional string) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
970 "Parse a scan line. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
971 If optional argument STRING is given then that is assumed to be the scan line. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
972 Otherwise uses the line at point as the scan line to parse." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
973 (let* ((string (or string |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
974 (buffer-substring-no-properties (line-beginning-position) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
975 (line-end-position)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
976 (first-string (substring string 0 (+ mh-cmd-note 8)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
977 (setf (elt first-string mh-cmd-note) ? ) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
978 (when (equal (elt first-string (1+ mh-cmd-note)) (elt mh-note-seq 0)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
979 (setf (elt first-string (1+ mh-cmd-note)) ? )) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
980 (list first-string |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
981 (substring string |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
982 (+ mh-cmd-note mh-scan-field-from-start-offset) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
983 (+ mh-cmd-note mh-scan-field-from-end-offset -2)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
984 (substring string (+ mh-cmd-note mh-scan-field-from-end-offset)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
985 string))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
986 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
987 (defun mh-thread-add-spaces (count) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
988 "Add COUNT spaces to each scan line in `mh-thread-scan-line-map'." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
989 (let ((spaces (format (format "%%%ss" count) ""))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
990 (while (not (eobp)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
991 (let* ((msg-num (mh-get-msg-num nil)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
992 (old-line (nth 3 (gethash msg-num mh-thread-scan-line-map)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
993 (setf (gethash msg-num mh-thread-scan-line-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
994 (mh-thread-parse-scan-line (format "%s%s" spaces old-line)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
995 (forward-line 1)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
996 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
997 (defun mh-thread-folder () |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
998 "Generate thread view of folder." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
999 (message "Threading %s..." (buffer-name)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1000 (mh-thread-initialize) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1001 (goto-char (point-min)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1002 (while (not (eobp)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1003 (setf (gethash (mh-get-msg-num nil) mh-thread-scan-line-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1004 (mh-thread-parse-scan-line)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1005 (forward-line)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1006 (let* ((range (format "%s-%s" mh-first-msg-num mh-last-msg-num)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1007 (thread-tree (mh-thread-generate (buffer-name) (list range))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1008 (buffer-read-only nil) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1009 (old-buffer-modified-p (buffer-modified-p))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1010 (delete-region (point-min) (point-max)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1011 (let ((mh-thread-body-width (- (window-width) mh-cmd-note |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1012 (1- mh-scan-field-subject-start-offset)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1013 (mh-thread-generate-scan-lines thread-tree -2)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1014 (mh-notate-user-sequences) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1015 (mh-notate-deleted-and-refiled) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1016 (mh-notate-seq 'cur mh-note-cur mh-cmd-note) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1017 (set-buffer-modified-p old-buffer-modified-p) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1018 (message "Threading %s...done" (buffer-name)))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1019 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1020 (defun mh-toggle-threads () |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1021 "Toggle threaded view of folder. |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1022 The conversion of normal view to threaded view is exact, that is the same |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1023 messages are displayed in the folder buffer before and after threading. However |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1024 the conversion from threaded view to normal view is inexact. So more messages |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1025 than were originally present may be shown as a result." |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
1026 (interactive) |
48595
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1027 (let ((msg-at-point (mh-get-msg-num nil))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1028 (cond ((and (memq 'unthread mh-view-ops) mh-narrowed-to-seq) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1029 (unless (mh-valid-view-change-operation-p 'unthread) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1030 (error "Can't unthread folder")) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1031 (mh-scan-folder mh-current-folder |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1032 (format "%s" mh-narrowed-to-seq) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1033 t)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1034 ((memq 'unthread mh-view-ops) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1035 (unless (mh-valid-view-change-operation-p 'unthread) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1036 (error "Can't unthread folder")) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1037 (mh-scan-folder mh-current-folder |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1038 (format "%s-%s" mh-first-msg-num mh-last-msg-num) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1039 t)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1040 (t (mh-thread-folder) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1041 (push 'unthread mh-view-ops))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1042 (when msg-at-point (mh-goto-msg msg-at-point t t)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1043 (mh-recenter nil))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1044 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1045 (defun mh-thread-forget-message (index) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1046 "Forget the message INDEX from the threading tables." |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1047 (let* ((id (gethash index mh-thread-index-id-map)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1048 (id-index (gethash id mh-thread-id-index-map)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1049 (duplicates (gethash id mh-thread-duplicates))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1050 (remhash index mh-thread-index-id-map) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1051 (cond ((and (eql index id-index) (null duplicates)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1052 (remhash id mh-thread-id-index-map)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1053 ((eql index id-index) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1054 (setf (gethash id mh-thread-id-index-map) (car duplicates)) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1055 (setf (gethash (car duplicates) mh-thread-index-id-map) id) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1056 (setf (gethash id mh-thread-duplicates) (cdr duplicates))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1057 (t |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1058 (setf (gethash id mh-thread-duplicates) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1059 (remove index duplicates)))))) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1060 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1061 (provide 'mh-seq) |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1062 |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1063 ;;; Local Variables: |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1064 ;;; sentence-end-double-space: nil |
8aaba207e44b
Upgraded to MH-E version 7.0.
Bill Wohler <wohler@newt.com>
parents:
47730
diff
changeset
|
1065 ;;; End: |
47730
2568d5a27317
Upgraded to mh-e version 6.1.1.
Bill Wohler <wohler@newt.com>
parents:
38414
diff
changeset
|
1066 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
14425
diff
changeset
|
1067 ;;; mh-seq.el ends here |