annotate lisp/vm/vm-sort.el @ 147:e186c2b7192d xemacs-20-2

Added tag r20-2p1 for changeset 2af401a6ecca
author cvs
date Mon, 13 Aug 2007 09:34:48 +0200
parents 7d55a9ba150c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; Sorting and moving messages inside VM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Copyright (C) 1993, 1994 Kyle E. Jones
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 (provide 'vm-sort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (defun vm-move-message-forward (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 "Move a message forward in a VM folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 Prefix arg COUNT causes the current message to be moved COUNT messages forward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 A negative COUNT causes movement to be backward instead of forward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 COUNT defaults to 1. The current message remains selected after being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 If vm-move-messages-physically is non-nil, the physical copy of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 the message in the folder is moved. A nil value means just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 change the presentation order and leave the physical order of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 the folder undisturbed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (vm-follow-summary-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (if vm-move-messages-physically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (vm-error-if-folder-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (vm-display nil nil '(vm-move-message-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 vm-move-message-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 vm-move-message-forward-physically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 vm-move-message-backward-physically)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (list this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (let* ((ovmp vm-message-pointer) vmp-prev ovmp-prev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (vm-message-pointer vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (direction (if (> count 0) 'forward 'backward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (count (vm-abs count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (while (not (zerop count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (vm-move-message-pointer direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (vm-decrement count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (if (> (string-to-int (vm-number-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (string-to-int (vm-number-of (car ovmp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (setq vm-message-pointer (cdr vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (if (eq vm-message-pointer ovmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (if (null vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (setq vmp-prev (vm-last vm-message-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (setq vmp-prev (vm-reverse-link-of (car vm-message-pointer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (setq ovmp-prev (vm-reverse-link-of (car ovmp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; lock out interrupts to preserve message list integrity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (if ovmp-prev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (setcdr ovmp-prev (cdr ovmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (and (cdr ovmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (vm-set-reverse-link-of (car (cdr ovmp)) ovmp-prev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (setq vm-message-list (cdr ovmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (vm-set-reverse-link-of (car vm-message-list) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (if vmp-prev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (setcdr vmp-prev ovmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (vm-set-reverse-link-of (car ovmp) vmp-prev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (setq vm-message-list ovmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (vm-set-reverse-link-of (car vm-message-list) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (setcdr ovmp vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (and vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (vm-set-reverse-link-of (car vm-message-pointer) ovmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (if (and vm-move-messages-physically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (not (eq major-mode 'vm-virtual-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (vm-physically-move-message (car ovmp) (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (setq vm-ml-sort-keys nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (if (not vm-folder-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (setq vm-message-order-changed t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (vm-set-buffer-modified-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (vm-clear-modification-flag-undos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (cond ((null ovmp-prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (setq vm-numbering-redo-start-point vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 vm-numbering-redo-end-point vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 vm-summary-pointer (car vm-message-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ((null vmp-prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (setq vm-numbering-redo-start-point vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 vm-numbering-redo-end-point (cdr ovmp-prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 vm-summary-pointer (car ovmp-prev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ((or (not vm-message-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (< (string-to-int (vm-number-of (car ovmp-prev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (string-to-int (vm-number-of (car vm-message-pointer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (setq vm-numbering-redo-start-point (cdr ovmp-prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 vm-numbering-redo-end-point (cdr ovmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 vm-summary-pointer (car (cdr ovmp-prev))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq vm-numbering-redo-start-point ovmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 vm-numbering-redo-end-point (cdr ovmp-prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 vm-summary-pointer (car ovmp-prev))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (if vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (let (list mp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (vm-copy-local-variables vm-summary-buffer 'vm-summary-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (setq vm-need-summary-pointer-update t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (setq mp vm-numbering-redo-start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (while (not (eq mp vm-numbering-redo-end-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (vm-mark-for-summary-update (car mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (setq list (cons (car mp) list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 mp (cdr mp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (vm-mapc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (lambda (m p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (vm-set-su-start-of m (car p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (vm-set-su-end-of m (car (cdr p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (setq list (nreverse list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (lambda (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (list (vm-su-start-of p) (vm-su-end-of p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (lambda (p q)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (< (car p) (car q))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (if vm-move-messages-physically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; clip region is messed up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (vm-preview-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (vm-update-summary-and-mode-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defun vm-move-message-backward (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 "Move a message backward in a VM folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Prefix arg COUNT causes the current message to be moved COUNT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 messages backward. A negative COUNT causes movement to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 forward instead of backward. COUNT defaults to 1. The current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 message remains selected after being moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 If vm-move-messages-physically is non-nil, the physical copy of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 the message in the folder is moved. A nil value means just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 change the presentation order and leave the physical order of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 the folder undisturbed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (vm-move-message-forward (- count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (defun vm-move-message-forward-physically (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 "Like vm-move-message-forward but always move the message physically."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (let ((vm-move-messages-physically t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (vm-move-message-forward count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defun vm-move-message-backward-physically (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 "Like vm-move-message-backward but always move the message physically."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (let ((vm-move-messages-physically t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (vm-move-message-backward count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; move message m to be before m-dest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; and fix up the location markers afterwards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; m better not equal m-dest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; of m-dest is nil, move m to the end of buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; consider carefully the effects of insertion on markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; and variables containg markers before you modify this code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (defun vm-physically-move-message (m m-dest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (vm-save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; Make sure vm-headers-of and vm-text-of are non-nil in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; their slots before we try to move them. (Simply
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; referencing the slot with their slot function is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; sufficient to guarantee this.) Otherwise, they be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; initialized in the middle of the message move and get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; offset applied to them twice by way of a relative offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; from one of the other location markers that has already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; been moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; Also, and more importantly, vm-vheaders-of might run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; vm-reorder-message-headers, which can add text to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; message. This MUST NOT happen after offsets have been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; computed for the message move or varying levels of chaos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; will ensue. In the case of BABYL files, where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; vm-reorder-message-headers can add a lot of new text,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; folder curroption can be massive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (vm-text-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (vm-vheaders-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (let ((dest-start (if m-dest (vm-start-of m-dest) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 offset doomed-start doomed-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (goto-char dest-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (insert-buffer-substring (current-buffer) (vm-start-of m) (vm-end-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (setq doomed-start (marker-position (vm-start-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 doomed-end (marker-position (vm-end-of m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 offset (- (vm-start-of m) dest-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (set-marker (vm-start-of m) (- (vm-start-of m) offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (set-marker (vm-headers-of m) (- (vm-headers-of m) offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (set-marker (vm-text-end-of m) (- (vm-text-end-of m) offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (set-marker (vm-end-of m) (- (vm-end-of m) offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (set-marker (vm-text-of m) (- (vm-text-of m) offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (set-marker (vm-vheaders-of m) (- (vm-vheaders-of m) offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; now fix the start of m-dest since it didn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; move forward with its message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (and m-dest (set-marker (vm-start-of m-dest) (vm-end-of m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; delete the old copy of the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (delete-region doomed-start doomed-end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (defun vm-so-sortable-datestring (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (or (vm-sortable-datestring-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (vm-set-sortable-datestring-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 m
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 102
diff changeset
215 (condition-case nil
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 102
diff changeset
216 (timezone-make-date-sortable
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 102
diff changeset
217 (or (vm-get-header-contents m "Date:")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 102
diff changeset
218 (vm-grok-From_-date m)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 102
diff changeset
219 "Thu, 1 Jan 1970 00:00:00 GMT")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 102
diff changeset
220 "GMT" "GMT")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 102
diff changeset
221 (error "1970010100:00:00")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (vm-sortable-datestring-of m))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (defun vm-so-sortable-subject (m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (or (vm-sortable-subject-of m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (vm-set-sortable-subject-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (subject (vm-su-subject m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (if (and vm-subject-ignored-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (string-match vm-subject-ignored-prefix subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (zerop (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (setq subject (substring subject (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (if (and vm-subject-ignored-suffix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (string-match vm-subject-ignored-suffix subject)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (= (match-end 0) (length subject)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq subject (substring subject 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 subject ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (vm-sortable-subject-of m))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (defun vm-sort-messages (keys &optional lets-get-physical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 "Sort message in a folder by the specified KEYS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 You may sort by more than one particular message key. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 messages compare equal by the first key, the second key will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 compared and so on. When called interactively the keys will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 read from the minibuffer. Valid keys are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 \"date\" \"reversed-date\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 \"author\" \"reversed-author\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 \"subject\" \"reversed-subject\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 \"recipients\" \"reversed-recipients\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 \"line-count\" \"reversed-line-count\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 \"byte-count\" \"reversed-byte-count\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 \"physical-order\" \"reversed-physical-order\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 Optional second arg (prefix arg interactively) means the sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 should change the physical order of the messages in the folder.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 Normally VM changes presentation order only, leaving the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 folder in the order in which the messages arrived."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (let ((last-command last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (this-command this-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (list (vm-read-string (if (or current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 vm-move-messages-physically)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 "Physically sort messages by: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 "Sort messages by: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 vm-supported-sort-keys t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 current-prefix-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; only squawk if interactive. The thread display uses this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; function and doesn't expect errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (vm-error-if-folder-empty))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; ditto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (if (and (interactive-p) (or vm-move-messages-physically lets-get-physical))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (vm-error-if-folder-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (vm-display nil nil '(vm-sort-messages) '(vm-sort-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (let (key-list key-funcs key ml-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 physical-order-list old-message-list new-message-list mp-old mp-new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 old-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 doomed-start doomed-end offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (order-did-change nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 virtual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 physical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (setq key-list (vm-parse keys "[ \t]*\\([^ \t]+\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ml-keys (and key-list (mapconcat (function identity) key-list "/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 key-funcs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 old-message-list vm-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 virtual (eq major-mode 'vm-virtual-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 physical (and (or lets-get-physical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 vm-move-messages-physically)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (not vm-folder-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (not virtual)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (or key-list (error "No sort keys specified."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (while key-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq key (car key-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (cond ((equal key "thread")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (vm-build-threads-if-unbuilt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (setq key-funcs (cons 'vm-sort-compare-thread key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ((equal key "author")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (setq key-funcs (cons 'vm-sort-compare-author key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ((equal key "reversed-author")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (setq key-funcs (cons 'vm-sort-compare-author-r key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ((equal key "date")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (setq key-funcs (cons 'vm-sort-compare-date key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ((equal key "reversed-date")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq key-funcs (cons 'vm-sort-compare-date-r key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ((equal key "subject")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (setq key-funcs (cons 'vm-sort-compare-subject key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ((equal key "reversed-subject")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (setq key-funcs (cons 'vm-sort-compare-subject-r key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ((equal key "recipients")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (setq key-funcs (cons 'vm-sort-compare-recipients key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ((equal key "reversed-recipients")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (setq key-funcs (cons 'vm-sort-compare-recipients-r key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ((equal key "byte-count")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (setq key-funcs (cons 'vm-sort-compare-byte-count key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ((equal key "reversed-byte-count")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (setq key-funcs (cons 'vm-sort-compare-byte-count-r key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ((equal key "line-count")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (setq key-funcs (cons 'vm-sort-compare-line-count key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ((equal key "reversed-line-count")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (setq key-funcs (cons 'vm-sort-compare-line-count-r key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ((equal key "physical-order")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (setq key-funcs (cons 'vm-sort-compare-physical-order key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ((equal key "reversed-physical-order")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (setq key-funcs (cons 'vm-sort-compare-physical-order-r key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (t (error "Unknown key: %s" key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (setq key-list (cdr key-list)))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 70
diff changeset
332 (message "Sorting...")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (let ((vm-key-functions (nreverse key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (setq new-message-list (sort (copy-sequence old-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 'vm-sort-compare-xxxxxx))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; only need to do this sort if we're going to physically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; move messages later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (if physical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (setq vm-key-functions '(vm-sort-compare-physical-order)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 physical-order-list (sort (copy-sequence old-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 'vm-sort-compare-xxxxxx))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 70
diff changeset
342 (message "Sorting... done")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (setq mp-old old-message-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 mp-new new-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (while mp-new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (if (eq (car mp-old) (car mp-new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (setq mp-old (cdr mp-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 mp-new (cdr mp-new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (setq order-did-change t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ;; unless a full redo has been requested, the numbering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;; start point now points to a cons in the old message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ;; list. therefore we just change the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ;; directly to avoid the list scan that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;; vm-set-numbering-redo-start-point does.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (cond ((not (eq vm-numbering-redo-start-point t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq vm-numbering-redo-start-point mp-new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 vm-numbering-redo-end-point nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (if vm-summary-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (setq vm-need-summary-pointer-update t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;; same logic as numbering reset above...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (cond ((not (eq vm-summary-redo-start-point t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (setq vm-summary-redo-start-point mp-new)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;; start point of this message's summary is now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; wrong relative to where it is in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;; message list. fix it and the summary rebuild
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;; will take care of the rest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (vm-set-su-start-of (car mp-new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (vm-su-start-of (car mp-old)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (setq mp-new nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (if (and order-did-change physical)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ;; the folder is being physically ordered so we don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;; need a message order header to be stuffed, nor do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; we need to retain one in the folder buffer. so we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;; strip out any existing message order header and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;; say there are no changes to prevent a message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;; order header from being stuffed later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (vm-remove-message-order)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (setq vm-message-order-changed nil)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 70
diff changeset
382 (message "Moving messages... ")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (setq mp-old physical-order-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 mp-new new-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (setq old-start (vm-start-of (car mp-old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (while mp-new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (if (< (vm-start-of (car mp-old)) old-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;; already moved this message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (setq mp-old (cdr mp-old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (if (eq (car mp-old) (car mp-new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (setq mp-old (cdr mp-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 mp-new (cdr mp-new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ;; move message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (vm-physically-move-message (car mp-new) (car mp-old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;; record start position. if vm-start-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;; mp-old ever becomes less than old-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;; we're running into messages that have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;; already been moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (setq old-start (vm-start-of (car mp-old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 ;; move mp-new but not mp-old because we moved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ;; mp-old down one message by inserting a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;; message in front of it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (setq mp-new (cdr mp-new)))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 70
diff changeset
405 (message "Moving messages... done")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (vm-set-buffer-modified-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (vm-clear-modification-flag-undos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (if (and order-did-change (not vm-folder-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (setq vm-message-order-changed t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (vm-set-buffer-modified-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (vm-clear-modification-flag-undos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (setq vm-ml-sort-keys ml-keys)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (intern (buffer-name) vm-buffers-needing-display-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (cond (order-did-change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (setq vm-message-list new-message-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (vm-reverse-link-messages)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (if vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (setq vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (or (cdr (vm-reverse-link-of (car vm-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 vm-message-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (if vm-last-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (setq vm-last-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (or (cdr (vm-reverse-link-of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (car vm-last-message-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 vm-message-list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (if (and vm-message-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 order-did-change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (or lets-get-physical vm-move-messages-physically))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;; clip region is most likely messed up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (vm-preview-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (vm-update-summary-and-mode-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (defun vm-sort-compare-xxxxxx (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (let ((key-funcs vm-key-functions) result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (while (and key-funcs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (eq '= (setq result (funcall (car key-funcs) m1 m2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq key-funcs (cdr key-funcs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (and key-funcs result) ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (defun vm-sort-compare-thread (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (let ((list1 (vm-th-thread-list m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (list2 (vm-th-thread-list m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (if (not (eq (car list1) (car list2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (let ((date1 (get (car list1) 'oldest-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (date2 (get (car list2) 'oldest-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (cond ((string-lessp date1 date2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ((string-equal date1 date2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (while (and list1 list2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (cond ((string-lessp (car list1) (car list2)) (throw 'done t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ((not (string-equal (car list1) (car list2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (throw 'done nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (setq list1 (cdr list1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 list2 (cdr list2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (cond ((and list1 (not list2)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ((and list2 (not list1)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (t '=))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (defun vm-sort-compare-author (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (let ((s1 (vm-su-from m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (s2 (vm-su-from m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (cond ((string-lessp s1 s2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ((string-equal s1 s2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (defun vm-sort-compare-author-r (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (let ((s1 (vm-su-from m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (s2 (vm-su-from m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (cond ((string-lessp s1 s2) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ((string-equal s1 s2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (t t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defun vm-sort-compare-date (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (let ((s1 (vm-so-sortable-datestring m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (s2 (vm-so-sortable-datestring m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (cond ((string-lessp s1 s2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ((string-equal s1 s2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (defun vm-sort-compare-date-r (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (let ((s1 (vm-so-sortable-datestring m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (s2 (vm-so-sortable-datestring m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (cond ((string-lessp s1 s2) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ((string-equal s1 s2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (t t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (defun vm-sort-compare-recipients (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (let ((s1 (vm-su-to m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (s2 (vm-su-to m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (cond ((string-lessp s1 s2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ((string-equal s1 s2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (defun vm-sort-compare-recipients-r (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (let ((s1 (vm-su-to m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (s2 (vm-su-to m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (cond ((string-lessp s1 s2) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ((string-equal s1 s2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (t t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (defun vm-sort-compare-subject (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (let ((s1 (vm-so-sortable-subject m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (s2 (vm-so-sortable-subject m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (cond ((string-lessp s1 s2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ((string-equal s1 s2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (defun vm-sort-compare-subject-r (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (let ((s1 (vm-so-sortable-subject m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (s2 (vm-so-sortable-subject m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (cond ((string-lessp s1 s2) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ((string-equal s1 s2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (t t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (defun vm-sort-compare-line-count (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (let ((n1 (string-to-int (vm-su-line-count m1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (n2 (string-to-int (vm-su-line-count m2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (cond ((< n1 n2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ((= n1 n2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (defun vm-sort-compare-line-count-r (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (let ((n1 (string-to-int (vm-su-line-count m1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (n2 (string-to-int (vm-su-line-count m2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (cond ((> n1 n2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ((= n1 n2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (defun vm-sort-compare-byte-count (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (let ((n1 (string-to-int (vm-su-byte-count m1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (n2 (string-to-int (vm-su-byte-count m2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (cond ((< n1 n2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 ((= n1 n2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (defun vm-sort-compare-byte-count-r (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (let ((n1 (string-to-int (vm-su-byte-count m1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (n2 (string-to-int (vm-su-byte-count m2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (cond ((> n1 n2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ((= n1 n2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (defun vm-sort-compare-physical-order (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (let ((n1 (vm-start-of m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (n2 (vm-start-of m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (cond ((< n1 n2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ((= n1 n2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (defun vm-sort-compare-physical-order-r (m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (let ((n1 (vm-start-of m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (n2 (vm-start-of m2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (cond ((> n1 n2) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ((= n1 n2) '=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (t nil))))