Mercurial > emacs
comparison lisp/mail/rmailsort.el @ 3878:fab096be7274
Don't touch rmail-summary-mode-map.
Don't touch rmail-mode-map. Don't require rmail or sort.
(rmail-summary-sort-...): Moved to rmailsum.el.
(rmail-sort-from-summary): Likewise.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 22 Jun 1993 05:55:41 +0000 |
parents | 2c1553d7aad1 |
children | 484e65abfdea |
comparison
equal
deleted
inserted
replaced
3877:da9b565f9878 | 3878:fab096be7274 |
---|---|
1 ;;; rmailsort.el --- Rmail: sort messages. | 1 ;;; rmailsort.el --- Rmail: sort messages. |
2 | 2 |
3 ;; Copyright (C) 1990, 1993 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1990, 1993 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp> | 5 ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp> |
6 ;; Version: $Header: rmailsort.el,v 1.6 93/05/26 22:24:42 umerin Exp $ | 6 ;; Version: $Header: /home/fsf/rms/e19/lisp/RCS/rmailsort.el,v 1.14 1993/05/26 20:28:11 rms Exp rms $ |
7 ;; Keywords: mail | 7 ;; Keywords: mail |
8 | 8 |
9 ;; This file is part of GNU Emacs. | 9 ;; This file is part of GNU Emacs. |
10 | 10 |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | 11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
20 | 20 |
21 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;; LCD Archive Entry: | |
28 ;; rmailsort|Masanobu UMEDA|umerin@mse.kyutech.ac.jp| | |
29 ;; Rmail: sort messages.| | |
30 ;; $Date: 93/05/26 22:24:42 $|$Revision: 1.6 $|~/misc/rmailsort.el.Z| | |
31 | |
32 ;;; Code: | 25 ;;; Code: |
33 | 26 |
34 (require 'rmail) | |
35 (require 'sort) | 27 (require 'sort) |
36 | 28 |
37 (autoload 'timezone-make-date-sortable "timezone") | 29 (autoload 'timezone-make-date-sortable "timezone") |
38 | 30 |
39 ;; GNUS compatible key bindings. | |
40 | |
41 (define-key rmail-mode-map "\C-c\C-s\C-d" 'rmail-sort-by-date) | |
42 (define-key rmail-mode-map "\C-c\C-s\C-s" 'rmail-sort-by-subject) | |
43 (define-key rmail-mode-map "\C-c\C-s\C-a" 'rmail-sort-by-author) | |
44 (define-key rmail-mode-map "\C-c\C-s\C-r" 'rmail-sort-by-recipient) | |
45 (define-key rmail-mode-map "\C-c\C-s\C-c" 'rmail-sort-by-correspondent) | |
46 (define-key rmail-mode-map "\C-c\C-s\C-l" 'rmail-sort-by-lines) | |
47 | |
48 ;; Key binding may not be installed unless Rmail Summary mode is loaded. | |
49 (if (boundp 'rmail-summary-mode-map) | |
50 (progn | |
51 (define-key rmail-summary-mode-map | |
52 "\C-c\C-s\C-d" 'rmail-summary-sort-by-date) | |
53 (define-key rmail-summary-mode-map | |
54 "\C-c\C-s\C-s" 'rmail-summary-sort-by-subject) | |
55 (define-key rmail-summary-mode-map | |
56 "\C-c\C-s\C-a" 'rmail-summary-sort-by-author) | |
57 (define-key rmail-summary-mode-map | |
58 "\C-c\C-s\C-r" 'rmail-summary-sort-by-recipient) | |
59 (define-key rmail-summary-mode-map | |
60 "\C-c\C-s\C-c" 'rmail-summary-sort-by-correspondent) | |
61 (define-key rmail-summary-mode-map | |
62 "\C-c\C-s\C-l" 'rmail-summary-sort-by-lines) | |
63 )) | |
64 | |
65 | |
66 ;; Sorting messages in Rmail buffer | 31 ;; Sorting messages in Rmail buffer |
67 | 32 |
68 (defun rmail-sort-by-date (reverse) | 33 (defun rmail-sort-by-date (reverse) |
69 "Sort messages of current Rmail file by date. | 34 "Sort messages of current Rmail file by date. |
70 If prefix argument REVERSE is non-nil, sort them in reverse order." | 35 If prefix argument REVERSE is non-nil, sort them in reverse order." |
133 (or (rmail-fetch-field msg (car fields)) "")))) | 98 (or (rmail-fetch-field msg (car fields)) "")))) |
134 (setq fields (cdr fields))) | 99 (setq fields (cdr fields))) |
135 ans)) | 100 ans)) |
136 | 101 |
137 (defun rmail-sort-by-lines (reverse) | 102 (defun rmail-sort-by-lines (reverse) |
138 "Sort messages of current Rmail file by lines of the message. | 103 "Sort messages of current Rmail file by number of lines. |
139 If prefix argument REVERSE is non-nil, sort them in reverse order." | 104 If prefix argument REVERSE is non-nil, sort them in reverse order." |
140 (interactive "P") | 105 (interactive "P") |
141 (rmail-sort-messages reverse | 106 (rmail-sort-messages reverse |
142 (function | 107 (function |
143 (lambda (msg) | 108 (lambda (msg) |
144 (count-lines (rmail-msgbeg msgnum) | 109 (count-lines (rmail-msgbeg msgnum) |
145 (rmail-msgend msgnum)))))) | 110 (rmail-msgend msgnum)))))) |
146 | |
147 ;; Sorting messages in Rmail Summary buffer. | |
148 | |
149 (defun rmail-summary-sort-by-date (reverse) | |
150 "Sort messages of current Rmail summary by date. | |
151 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
152 (interactive "P") | |
153 (rmail-sort-from-summary (function rmail-sort-by-date) reverse)) | |
154 | |
155 (defun rmail-summary-sort-by-subject (reverse) | |
156 "Sort messages of current Rmail summary by subject. | |
157 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
158 (interactive "P") | |
159 (rmail-sort-from-summary (function rmail-sort-by-subject) reverse)) | |
160 | |
161 (defun rmail-summary-sort-by-author (reverse) | |
162 "Sort messages of current Rmail summary by author. | |
163 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
164 (interactive "P") | |
165 (rmail-sort-from-summary (function rmail-sort-by-author) reverse)) | |
166 | |
167 (defun rmail-summary-sort-by-recipient (reverse) | |
168 "Sort messages of current Rmail summary by recipient. | |
169 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
170 (interactive "P") | |
171 (rmail-sort-from-summary (function rmail-sort-by-recipient) reverse)) | |
172 | |
173 (defun rmail-summary-sort-by-correspondent (reverse) | |
174 "Sort messages of current Rmail summary by other correspondent. | |
175 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
176 (interactive "P") | |
177 (rmail-sort-from-summary (function rmail-sort-by-correspondent) reverse)) | |
178 | |
179 (defun rmail-summary-sort-by-lines (reverse) | |
180 "Sort messages of current Rmail summary by lines of the message. | |
181 If prefix argument REVERSE is non-nil, sort them in reverse order." | |
182 (interactive "P") | |
183 (rmail-sort-from-summary (function rmail-sort-by-lines) reverse)) | |
184 | |
185 | 111 |
186 ;; Basic functions | 112 ;; Basic functions |
187 | 113 |
188 (defun rmail-sort-messages (reverse keyfun) | 114 (defun rmail-sort-messages (reverse keyfun) |
189 "Sort messages of current Rmail file. | 115 "Sort messages of current Rmail file. |
248 (buffer-enable-undo) | 174 (buffer-enable-undo) |
249 (rmail-set-message-counters) | 175 (rmail-set-message-counters) |
250 (rmail-show-message current-message)) | 176 (rmail-show-message current-message)) |
251 )) | 177 )) |
252 | 178 |
253 (defun rmail-sort-from-summary (sortfun reverse) | |
254 "Sort Rmail messages from Summary buffer and update it after sorting." | |
255 (pop-to-buffer rmail-buffer) | |
256 (funcall sortfun reverse) | |
257 (rmail-summary)) | |
258 | |
259 (defun rmail-fetch-field (msg field) | 179 (defun rmail-fetch-field (msg field) |
260 "Return the value of the header FIELD of MSG. | 180 "Return the value of the header FIELD of MSG. |
261 Arguments are MSG and FIELD." | 181 Arguments are MSG and FIELD." |
262 (save-restriction | 182 (save-restriction |
263 (widen) | 183 (widen) |
273 (defun rmail-make-date-sortable (date) | 193 (defun rmail-make-date-sortable (date) |
274 "Make DATE sortable using the function string-lessp." | 194 "Make DATE sortable using the function string-lessp." |
275 ;; Assume the default time zone is GMT. | 195 ;; Assume the default time zone is GMT. |
276 (timezone-make-date-sortable date "GMT" "GMT")) | 196 (timezone-make-date-sortable date "GMT" "GMT")) |
277 | 197 |
278 ;; Copy of the function gnus-comparable-date in gnus.el version 3.13 | |
279 ; | |
280 ;(defun rmail-make-date-sortable (date) | |
281 ; "Make sortable string by string-lessp from DATE." | |
282 ; (let ((month '(("JAN" . " 1")("FEB" . " 2")("MAR" . " 3") | |
283 ; ("APR" . " 4")("MAY" . " 5")("JUN" . " 6") | |
284 ; ("JUL" . " 7")("AUG" . " 8")("SEP" . " 9") | |
285 ; ("OCT" . "10")("NOV" . "11")("DEC" . "12"))) | |
286 ; (date (or date ""))) | |
287 ; ;; Can understand the following styles: | |
288 ; ;; (1) 14 Apr 89 03:20:12 GMT | |
289 ; ;; (2) Fri, 17 Mar 89 4:01:33 GMT | |
290 ; (if (string-match | |
291 ; "\\([0-9]+\\) \\([^ ,]+\\) \\([0-9]+\\) \\([0-9:]+\\)" date) | |
292 ; (concat | |
293 ; ;; Year | |
294 ; (substring date (match-beginning 3) (match-end 3)) | |
295 ; ;; Month | |
296 ; (cdr | |
297 ; (assoc | |
298 ; (upcase (substring date (match-beginning 2) (match-end 2))) month)) | |
299 ; ;; Day | |
300 ; (format "%2d" (string-to-int | |
301 ; (substring date | |
302 ; (match-beginning 1) (match-end 1)))) | |
303 ; ;; Time | |
304 ; (substring date (match-beginning 4) (match-end 4))) | |
305 ; ;; Cannot understand DATE string. | |
306 ; date | |
307 ; ) | |
308 ; )) | |
309 | |
310 (provide 'rmailsort) | 198 (provide 'rmailsort) |
311 | 199 |
312 ;;; rmailsort.el ends here | 200 ;;; rmailsort.el ends here |