annotate lisp/mail/rmailsort.el @ 4127:d253c8a4b7e5

* wakeup.c: Use CPP tangle from autoconf manual to #include the correct combination of <time.h> and <sys/time.h>.
author Jim Blandy <jimb@redhat.com>
date Sun, 18 Jul 1993 06:13:07 +0000
parents fab096be7274
children 484e65abfdea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; rmailsort.el --- Rmail: sort messages.
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
3 ;; Copyright (C) 1990, 1993 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
4
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
5 ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp>
3878
fab096be7274 Don't touch rmail-summary-mode-map.
Richard M. Stallman <rms@gnu.org>
parents: 3133
diff changeset
6 ;; Version: $Header: /home/fsf/rms/e19/lisp/RCS/rmailsort.el,v 1.14 1993/05/26 20:28:11 rms Exp rms $
814
38b2499cb3e9 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
7 ;; Keywords: mail
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 767
diff changeset
8
767
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
9 ;; This file is part of GNU Emacs.
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
767
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 767
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
767
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
14 ;; any later version.
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
767
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
19 ;; GNU General Public License for more details.
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
767
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
21 ;; You should have received a copy of the GNU General Public License
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
02bfc9709961 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 658
diff changeset
24
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 767
diff changeset
25 ;;; Code:
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 (require 'sort)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
29 (autoload 'timezone-make-date-sortable "timezone")
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
30
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
31 ;; Sorting messages in Rmail buffer
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 (defun rmail-sort-by-date (reverse)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 "Sort messages of current Rmail file by date.
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 If prefix argument REVERSE is non-nil, sort them in reverse order."
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (interactive "P")
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 (rmail-sort-messages reverse
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 (function
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (lambda (msg)
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
40 (rmail-make-date-sortable
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 (rmail-fetch-field msg "Date"))))))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (defun rmail-sort-by-subject (reverse)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 "Sort messages of current Rmail file by subject.
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 If prefix argument REVERSE is non-nil, sort them in reverse order."
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (interactive "P")
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (rmail-sort-messages reverse
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (function
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (lambda (msg)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (let ((key (or (rmail-fetch-field msg "Subject") ""))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (case-fold-search t))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; Remove `Re:'
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (if (string-match "^\\(re:[ \t]+\\)*" key)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (substring key (match-end 0)) key))))))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (defun rmail-sort-by-author (reverse)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 "Sort messages of current Rmail file by author.
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 If prefix argument REVERSE is non-nil, sort them in reverse order."
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (interactive "P")
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (rmail-sort-messages reverse
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (function
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (lambda (msg)
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
63 (downcase ;Canonical name
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
64 (mail-strip-quoted-names
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
65 (or (rmail-fetch-field msg "From")
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
66 (rmail-fetch-field msg "Sender") "")))))))
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (defun rmail-sort-by-recipient (reverse)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 "Sort messages of current Rmail file by recipient.
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 If prefix argument REVERSE is non-nil, sort them in reverse order."
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (interactive "P")
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (rmail-sort-messages reverse
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (function
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (lambda (msg)
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
75 (downcase ;Canonical name
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
76 (mail-strip-quoted-names
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
77 (or (rmail-fetch-field msg "To")
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
78 (rmail-fetch-field msg "Apparently-To") "")
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
79 ))))))
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
131
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
81 (defun rmail-sort-by-correspondent (reverse)
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
82 "Sort messages of current Rmail file by other correspondent.
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
83 If prefix argument REVERSE is non-nil, sort them in reverse order."
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
84 (interactive "P")
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
85 (rmail-sort-messages reverse
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
86 (function
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
87 (lambda (msg)
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
88 (rmail-select-correspondent
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
89 msg
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
90 '("From" "Sender" "To" "Apparently-To"))))))
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
91
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
92 (defun rmail-select-correspondent (msg fields)
d4c523560fe8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 92
diff changeset
93 (let ((ans ""))
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
94 (while (and fields (string= ans ""))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
95 (setq ans
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
96 (rmail-dont-reply-to
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
97 (mail-strip-quoted-names
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
98 (or (rmail-fetch-field msg (car fields)) ""))))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
99 (setq fields (cdr fields)))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
100 ans))
148
a099f0c77321 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 131
diff changeset
101
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
102 (defun rmail-sort-by-lines (reverse)
3878
fab096be7274 Don't touch rmail-summary-mode-map.
Richard M. Stallman <rms@gnu.org>
parents: 3133
diff changeset
103 "Sort messages of current Rmail file by number of lines.
148
a099f0c77321 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 131
diff changeset
104 If prefix argument REVERSE is non-nil, sort them in reverse order."
a099f0c77321 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 131
diff changeset
105 (interactive "P")
a099f0c77321 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 131
diff changeset
106 (rmail-sort-messages reverse
a099f0c77321 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 131
diff changeset
107 (function
a099f0c77321 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 131
diff changeset
108 (lambda (msg)
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
109 (count-lines (rmail-msgbeg msgnum)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
110 (rmail-msgend msgnum))))))
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
112 ;; Basic functions
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
113
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
114 (defun rmail-sort-messages (reverse keyfun)
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 "Sort messages of current Rmail file.
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
116 If 1st argument REVERSE is non-nil, sort them in reverse order.
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
117 2nd argument KEYFUN is called with a message number, and should return a key."
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (let ((buffer-read-only nil)
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
119 (predicate nil) ;< or string-lessp
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (sort-lists nil))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (message "Finding sort keys...")
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (widen)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (let ((msgnum 1))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (while (>= rmail-total-messages msgnum)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (setq sort-lists
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
126 (cons (list (funcall keyfun msgnum) ;Make sorting key
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
127 (eq rmail-current-message msgnum) ;True if current
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
128 (aref rmail-message-vector msgnum)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
129 (aref rmail-message-vector (1+ msgnum)))
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 sort-lists))
148
a099f0c77321 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 131
diff changeset
131 (if (zerop (% msgnum 10))
a099f0c77321 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 131
diff changeset
132 (message "Finding sort keys...%d" msgnum))
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (setq msgnum (1+ msgnum))))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (or reverse (setq sort-lists (nreverse sort-lists)))
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
135 ;; Decide predicate: < or string-lessp
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
136 (if (numberp (car (car sort-lists))) ;Is a key numeric?
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
137 (setq predicate (function <))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
138 (setq predicate (function string-lessp)))
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (setq sort-lists
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (sort sort-lists
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (function
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (lambda (a b)
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
143 (funcall predicate (car a) (car b))))))
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (if reverse (setq sort-lists (nreverse sort-lists)))
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
145 ;; Now we enter critical region. So, keyboard quit is disabled.
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
146 (message "Reordering messages...")
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
147 (let ((inhibit-quit t) ;Inhibit quit
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
148 (current-message nil)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
149 (msgnum 1)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
150 (msginfo nil))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
151 ;; There's little hope that we can easily undo after that.
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
152 (buffer-flush-undo (current-buffer))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
153 (goto-char (rmail-msgbeg 1))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
154 ;; To force update of all markers.
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
155 (insert-before-markers ?Z)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
156 (backward-char 1)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
157 ;; Now reorder messages.
148
a099f0c77321 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 131
diff changeset
158 (while sort-lists
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
159 (setq msginfo (car sort-lists))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
160 ;; Swap two messages.
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
161 (insert-buffer-substring
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
162 (current-buffer) (nth 2 msginfo) (nth 3 msginfo))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
163 (delete-region (nth 2 msginfo) (nth 3 msginfo))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
164 ;; Is current message?
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
165 (if (nth 1 msginfo)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
166 (setq current-message msgnum))
148
a099f0c77321 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 131
diff changeset
167 (setq sort-lists (cdr sort-lists))
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
168 (if (zerop (% msgnum 10))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
169 (message "Reordering messages...%d" msgnum))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
170 (setq msgnum (1+ msgnum)))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
171 ;; Delete the garbage inserted before.
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
172 (delete-char 1)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
173 (setq quit-flag nil)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
174 (buffer-enable-undo)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
175 (rmail-set-message-counters)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
176 (rmail-show-message current-message))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
177 ))
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
178
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (defun rmail-fetch-field (msg field)
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
180 "Return the value of the header FIELD of MSG.
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 Arguments are MSG and FIELD."
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
182 (save-restriction
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
183 (widen)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
184 (let ((next (rmail-msgend msg)))
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (goto-char (rmail-msgbeg msg))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (narrow-to-region (if (search-forward "\n*** EOOH ***\n" next t)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (point)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (forward-line 1)
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (point))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (progn (search-forward "\n\n" nil t) (point)))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (mail-fetch-field field))))
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192
3133
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
193 (defun rmail-make-date-sortable (date)
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
194 "Make DATE sortable using the function string-lessp."
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
195 ;; Assume the default time zone is GMT.
2c1553d7aad1 New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents: 2851
diff changeset
196 (timezone-make-date-sortable date "GMT" "GMT"))
90
92266e9b90bb Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 150
diff changeset
198 (provide 'rmailsort)
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
199
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
200 ;;; rmailsort.el ends here