1 ;;; mew-sort.el --- Sorting messages for Mew
3 ;; Author: Takashi P.KATOH <p-katoh@shiratori.riec.tohoku.ac.jp>
4 ;; Created: Feb 6, 1996
5 ;; Revised: Aug 30, 1999
9 (defconst mew-sort-version "mew-sort.el version 0.15")
13 (defun mew-summary-sort-subr (msgs &optional method from)
14 (if (not (mew-summary-exclusive-p))
17 (let* ((folder (buffer-name))
18 (sort-key (or (cdr (assoc folder
19 mew-sort-default-key-alist))
20 mew-sort-default-key))
21 (field-mode (mew-input-sort-key sort-key))
22 (field (car field-mode))
23 (mode (cdr field-mode))
25 (if (not (listp msgs)) (setq msgs (list msgs)))
26 (setq mew-summary-buffer-process t)
27 (message "Sorting %s by %s (%s mode) ... " folder field mode)
28 (apply (function call-process)
31 (concat "--src=" folder)
32 (concat "--field=" field)
33 (concat "--mode=" mode)
34 (append mew-prog-im-arg msgs)) ;; xxx
35 (message "Sorting %s by %s ... done" folder field)
36 (setq mew-summary-buffer-process nil)
38 (progn (mew-summary-jump-message from)
39 (setq rbeg (point)))) ;; beginning of region
42 (delete-region (or rbeg (point-min)) (point-max))) ;; for update
43 (mew-summary-scan-body mew-prog-imls
47 (mew-update-range)))))
49 (defun mew-summary-sort (&optional arg)
50 "Sort messages in the folder according to inputed key."
54 (mew-summary-sort-region (region-beginning) (region-end) "region")
55 (mew-summary-sort-region (point-min) (point-max)))))
57 (defun mew-summary-sort-region (r1 r2 &optional method)
58 "Sort messages in the region according to inputed key."
63 (goto-char (min r1 r2))
65 (or (mew-summary-message-number)
67 (re-search-backward mew-summary-message-regex nil t)
68 (mew-summary-message-number))))
69 (goto-char (max r1 r2))
71 (or (mew-summary-message-number)
73 (re-search-backward mew-summary-message-regex nil t)
74 (mew-summary-message-number))))
75 (goto-char (min r1 r2))
77 (mew-summary-sort-subr (concat from "-" to) method from)))))
79 (defun mew-summary-mark-sort (&optional r1 r2)
81 "Sort message marked with '*'."
83 (mew-summary-sort-subr
84 (mew-summary-mark-collect
85 mew-mark-review (or r1 (point-min)) (or r2 (point-max)))
92 ;; Copyright (C) 1996, 1997, 1998, 1999 Mew developing team.
93 ;; All rights reserved.
95 ;; Redistribution and use in source and binary forms, with or without
96 ;; modification, are permitted provided that the following conditions
99 ;; 1. Redistributions of source code must retain the above copyright
100 ;; notice, this list of conditions and the following disclaimer.
101 ;; 2. Redistributions in binary form must reproduce the above copyright
102 ;; notice, this list of conditions and the following disclaimer in the
103 ;; documentation and/or other materials provided with the distribution.
104 ;; 3. Neither the name of the team nor the names of its contributors
105 ;; may be used to endorse or promote products derived from this software
106 ;; without specific prior written permission.
108 ;; THIS SOFTWARE IS PROVIDED BY THE TEAM AND CONTRIBUTORS ``AS IS'' AND
109 ;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
110 ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
111 ;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TEAM OR CONTRIBUTORS BE
112 ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
113 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
114 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
115 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
116 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
117 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
118 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
120 ;;; mew-sort.el ends here