Mercurial > emacs
annotate lisp/mail/rmailsort.el @ 15097:32c26cb9e078
(Fexpand_file_name, Ffile_name_absolute_p): Doc fixes.
(Ffile_exists_p, Ffile_executable_p, Ffile_readable_p)
(Ffile_writable_p, Ffile_directory_p, Ffile_regular_p)
(Ffile_modes, Fset_file_modes, Ffile_newer_than_file_p)
(expand_and_dir_to_file): Rename abspath to absname.
(CORRECT_DIR_SEPS) [DOS_NT]: New macro.
(IS_DRIVE) [DOS_NT]: Added separate definitions for DOS and NT.
(Ffile_name_directory) [DOS_NT]: Simplify code to match change in
getdefdir in msdos.c. Ignore embedded colons. Correct dir seps.
(Ffile_name_nondirectory) [DOS_NT]: Ignore embedded colons.
Correct IS_ANY_SEP to IS_DIRECTORY_SEP.
(file_name_as_directory) [DOS_NT]: Correct dir seps.
Correct IS_ANY_SEP to IS_DIRECTORY_SEP.
(directory_file_name) [DOS_NT]: Correct dir seps.
(Fmake_temp_name) [DOS_NT: Correct dir seps.
(Fexpand_file_name) [mostly DOS_NT]: Remove relpath, tmp and
defdir variables; init drive to 0.
Correctly detect when default_directory is absolute.
Be strict when looking for MSDOS drive specifier; defer calling
getdefdir. Ignore drive specifier if name now has UNC prefix.
Correctly recognise if name is not absolute when trying simple
method to expand; return original string if possible.
Skip dir sep after ~ or ~user.
Use getpwnam instead of HOME for ~user on NT.
Handle error return from getdefdir.
Correctly detect if newdir is absolute before using default_directory.
Handle case where newdir is not absolute - expand relative to
current working dir if necessary (instead of calling getdisk
later). Only keep UNC prefix if nm starts with dir sep.
Replace kludgy handling of drive spec in newdir. Correct dir seps.
(Fexpand_file_name) [!DOS_NT]: Fix incorrect expansion of
"/foo/../bar" -> "//bar".
(Fsubstitute_in_file_name) [DOS_NT]: Correct dir seps for NT as
well. Merge equivalent #ifdef APOLLO and WINDOWSNT cases. Ignore
embedded colons and be strict about drive specs.
(Fcopy_file) [DOS_NT]: Do dev/inode check on NT.
(Ffile_name_absolute_p) [DOS_NT]: Be strict about drive specs.
(check_executable) [DOS_NT]: Test st_mode on NT.
(Ffile_readable_p) [DOS_NT]: Use access instead of open on NT.
(Ffile_modes) [DOS_NT]: Don't embelish st_mode value on NT.
(Fread_file_name) [DOS_NT]: Correct dir seps in HOME.
(syms_of_fileio): Add Vdirectory_sep_char.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 27 Apr 1996 01:14:17 +0000 |
parents | 48efd0c5b5dc |
children | 2cf33d3c5540 |
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 |
7298 | 3 ;; Copyright (C) 1990, 1993, 1994 Free Software Foundation, Inc. |
845 | 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> |
14235 | 6 ;; Version: $Header: /home/gd/gnu/emacs/19.0/lisp/RCS/rmailsort.el,v 1.23 1996/01/14 14:30:11 kwzh Exp kwzh $ |
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 | 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 | 15 |
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 | 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 |
14171 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
767
02bfc9709961
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
658
diff
changeset
|
25 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
767
diff
changeset
|
26 ;;; Code: |
90 | 27 |
28 (require 'sort) | |
29 | |
14235 | 30 ;; For rmail-select-summary |
31 (require 'rmail) | |
32 | |
3133
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
33 (autoload 'timezone-make-date-sortable "timezone") |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
34 |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
35 ;; Sorting messages in Rmail buffer |
90 | 36 |
37 (defun rmail-sort-by-date (reverse) | |
38 "Sort messages of current Rmail file by date. | |
39 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
40 (interactive "P") | |
41 (rmail-sort-messages reverse | |
42 (function | |
43 (lambda (msg) | |
3133
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
44 (rmail-make-date-sortable |
90 | 45 (rmail-fetch-field msg "Date")))))) |
46 | |
47 (defun rmail-sort-by-subject (reverse) | |
48 "Sort messages of current Rmail file by subject. | |
49 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
50 (interactive "P") | |
51 (rmail-sort-messages reverse | |
52 (function | |
53 (lambda (msg) | |
54 (let ((key (or (rmail-fetch-field msg "Subject") "")) | |
55 (case-fold-search t)) | |
56 ;; Remove `Re:' | |
6490
8c6205143fb1
(rmail-sort-by-subject): Fix `Re:' regexp.
Karl Heuer <kwzh@gnu.org>
parents:
6315
diff
changeset
|
57 (if (string-match "^\\(re:[ \t]*\\)*" key) |
8c6205143fb1
(rmail-sort-by-subject): Fix `Re:' regexp.
Karl Heuer <kwzh@gnu.org>
parents:
6315
diff
changeset
|
58 (substring key (match-end 0)) |
8c6205143fb1
(rmail-sort-by-subject): Fix `Re:' regexp.
Karl Heuer <kwzh@gnu.org>
parents:
6315
diff
changeset
|
59 key)))))) |
90 | 60 |
61 (defun rmail-sort-by-author (reverse) | |
62 "Sort messages of current Rmail file by author. | |
63 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
64 (interactive "P") | |
65 (rmail-sort-messages reverse | |
66 (function | |
67 (lambda (msg) | |
3133
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
68 (downcase ;Canonical name |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
69 (mail-strip-quoted-names |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
70 (or (rmail-fetch-field msg "From") |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
71 (rmail-fetch-field msg "Sender") ""))))))) |
90 | 72 |
73 (defun rmail-sort-by-recipient (reverse) | |
74 "Sort messages of current Rmail file by recipient. | |
75 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
76 (interactive "P") | |
77 (rmail-sort-messages reverse | |
78 (function | |
79 (lambda (msg) | |
3133
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
80 (downcase ;Canonical name |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
81 (mail-strip-quoted-names |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
82 (or (rmail-fetch-field msg "To") |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
83 (rmail-fetch-field msg "Apparently-To") "") |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
84 )))))) |
90 | 85 |
131 | 86 (defun rmail-sort-by-correspondent (reverse) |
87 "Sort messages of current Rmail file by other correspondent. | |
88 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
89 (interactive "P") | |
90 (rmail-sort-messages reverse | |
91 (function | |
92 (lambda (msg) | |
93 (rmail-select-correspondent | |
94 msg | |
95 '("From" "Sender" "To" "Apparently-To")))))) | |
96 | |
97 (defun rmail-select-correspondent (msg fields) | |
98 (let ((ans "")) | |
3133
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
99 (while (and fields (string= ans "")) |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
100 (setq ans |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
101 (rmail-dont-reply-to |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
102 (mail-strip-quoted-names |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
103 (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
|
104 (setq fields (cdr fields))) |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
105 ans)) |
148
a099f0c77321
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
131
diff
changeset
|
106 |
3133
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
107 (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
|
108 "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
|
109 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
|
110 (interactive "P") |
a099f0c77321
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
131
diff
changeset
|
111 (rmail-sort-messages reverse |
a099f0c77321
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
131
diff
changeset
|
112 (function |
a099f0c77321
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
131
diff
changeset
|
113 (lambda (msg) |
6315
f6a596a8a248
(rmail-sort-by-lines): msgnum variable should be msg.
Karl Heuer <kwzh@gnu.org>
parents:
5159
diff
changeset
|
114 (count-lines (rmail-msgbeg msg) |
f6a596a8a248
(rmail-sort-by-lines): msgnum variable should be msg.
Karl Heuer <kwzh@gnu.org>
parents:
5159
diff
changeset
|
115 (rmail-msgend msg)))))) |
6718
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
116 |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
117 (defun rmail-sort-by-keywords (reverse labels) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
118 "Sort messages of current Rmail file by labels. |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
119 If prefix argument REVERSE is non-nil, sort them in reverse order. |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
120 KEYWORDS is a comma-separated list of labels." |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
121 (interactive "P\nsSort by labels: ") |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
122 (or (string-match "[^ \t]" labels) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
123 (error "No labels specified")) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
124 (setq labels (concat (substring labels (match-beginning 0)) ",")) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
125 (let (labelvec) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
126 (while (string-match "[ \t]*,[ \t]*" labels) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
127 (setq labelvec (cons |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
128 (concat ", ?\\(" |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
129 (substring labels 0 (match-beginning 0)) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
130 "\\),") |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
131 labelvec)) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
132 (setq labels (substring labels (match-end 0)))) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
133 (setq labelvec (apply 'vector (nreverse labelvec))) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
134 (rmail-sort-messages reverse |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
135 (function |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
136 (lambda (msg) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
137 (let ((n 0)) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
138 (while (and (< n (length labelvec)) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
139 (not (rmail-message-labels-p |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
140 msg (aref labelvec n)))) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
141 (setq n (1+ n))) |
c13953896b24
(rmail-sort-by-keywords): New function.
Karl Heuer <kwzh@gnu.org>
parents:
6584
diff
changeset
|
142 n)))))) |
90 | 143 |
3133
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
144 ;; Basic functions |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
145 |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
146 (defun rmail-sort-messages (reverse keyfun) |
90 | 147 "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
|
148 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
|
149 2nd argument KEYFUN is called with a message number, and should return a key." |
5159
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
150 (save-excursion |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
151 ;; If we are in a summary buffer, operate on the Rmail buffer. |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
152 (if (eq major-mode 'rmail-summary-mode) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
153 (set-buffer rmail-buffer)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
154 (let ((buffer-read-only nil) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
155 (predicate nil) ;< or string-lessp |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
156 (sort-lists nil)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
157 (message "Finding sort keys...") |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
158 (widen) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
159 (let ((msgnum 1)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
160 (while (>= rmail-total-messages msgnum) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
161 (setq sort-lists |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
162 (cons (list (funcall keyfun msgnum) ;Make sorting key |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
163 (eq rmail-current-message msgnum) ;True if current |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
164 (aref rmail-message-vector msgnum) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
165 (aref rmail-message-vector (1+ msgnum))) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
166 sort-lists)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
167 (if (zerop (% msgnum 10)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
168 (message "Finding sort keys...%d" msgnum)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
169 (setq msgnum (1+ msgnum)))) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
170 (or reverse (setq sort-lists (nreverse sort-lists))) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
171 ;; Decide predicate: < or string-lessp |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
172 (if (numberp (car (car sort-lists))) ;Is a key numeric? |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
173 (setq predicate (function <)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
174 (setq predicate (function string-lessp))) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
175 (setq sort-lists |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
176 (sort sort-lists |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
177 (function |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
178 (lambda (a b) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
179 (funcall predicate (car a) (car b)))))) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
180 (if reverse (setq sort-lists (nreverse sort-lists))) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
181 ;; Now we enter critical region. So, keyboard quit is disabled. |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
182 (message "Reordering messages...") |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
183 (let ((inhibit-quit t) ;Inhibit quit |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
184 (current-message nil) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
185 (msgnum 1) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
186 (msginfo nil)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
187 ;; There's little hope that we can easily undo after that. |
6584
ec24b7ded9bc
(rmail-sort-messages): Use buffer-disable-undo, not buffer-flush-undo.
Karl Heuer <kwzh@gnu.org>
parents:
6583
diff
changeset
|
188 (buffer-disable-undo (current-buffer)) |
5159
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
189 (goto-char (rmail-msgbeg 1)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
190 ;; To force update of all markers. |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
191 (insert-before-markers ?Z) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
192 (backward-char 1) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
193 ;; Now reorder messages. |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
194 (while sort-lists |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
195 (setq msginfo (car sort-lists)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
196 ;; Swap two messages. |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
197 (insert-buffer-substring |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
198 (current-buffer) (nth 2 msginfo) (nth 3 msginfo)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
199 (delete-region (nth 2 msginfo) (nth 3 msginfo)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
200 ;; Is current message? |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
201 (if (nth 1 msginfo) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
202 (setq current-message msgnum)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
203 (setq sort-lists (cdr sort-lists)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
204 (if (zerop (% msgnum 10)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
205 (message "Reordering messages...%d" msgnum)) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
206 (setq msgnum (1+ msgnum))) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
207 ;; Delete the garbage inserted before. |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
208 (delete-char 1) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
209 (setq quit-flag nil) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
210 (buffer-enable-undo) |
484e65abfdea
(rmail-sort-messages): In summary buf, go to rmail buf.
Richard M. Stallman <rms@gnu.org>
parents:
3878
diff
changeset
|
211 (rmail-set-message-counters) |
6583
363f38b4648a
(rmail-sort-messages): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
6490
diff
changeset
|
212 (rmail-show-message current-message) |
363f38b4648a
(rmail-sort-messages): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
6490
diff
changeset
|
213 (if (rmail-summary-exists) |
363f38b4648a
(rmail-sort-messages): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
6490
diff
changeset
|
214 (rmail-select-summary |
363f38b4648a
(rmail-sort-messages): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
6490
diff
changeset
|
215 (rmail-update-summary))))))) |
3133
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
216 |
90 | 217 (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
|
218 "Return the value of the header FIELD of MSG. |
90 | 219 Arguments are MSG and FIELD." |
3133
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
220 (save-restriction |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
221 (widen) |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
222 (let ((next (rmail-msgend msg))) |
90 | 223 (goto-char (rmail-msgbeg msg)) |
224 (narrow-to-region (if (search-forward "\n*** EOOH ***\n" next t) | |
225 (point) | |
226 (forward-line 1) | |
227 (point)) | |
228 (progn (search-forward "\n\n" nil t) (point))) | |
229 (mail-fetch-field field)))) | |
230 | |
3133
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
231 (defun rmail-make-date-sortable (date) |
2c1553d7aad1
New version from Umeda. Needs detailed entry.
Richard M. Stallman <rms@gnu.org>
parents:
2851
diff
changeset
|
232 "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
|
233 ;; 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
|
234 (timezone-make-date-sortable date "GMT" "GMT")) |
90 | 235 |
584 | 236 (provide 'rmailsort) |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
237 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
238 ;;; rmailsort.el ends here |