X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/d733c5ec034baf089cdc50bc79b919897ab98bec..d33e73c1eb79ebf599a896a4e05ec9cc28f470b2:/lisp/mail/rmailsort.el diff --git a/lisp/mail/rmailsort.el b/lisp/mail/rmailsort.el index be9d69700f..3194358451 100644 --- a/lisp/mail/rmailsort.el +++ b/lisp/mail/rmailsort.el @@ -1,9 +1,9 @@ -;;; rmailsort.el --- Rmail: sort messages. +;;; rmailsort.el --- Rmail: sort messages -;; Copyright (C) 1990, 1993, 1994 Free Software Foundation, Inc. +;; Copyright (C) 1990, 1993, 1994, 2001 Free Software Foundation, Inc. ;; Author: Masanobu UMEDA -;; Version: $Header: /gd/gnu/emacs/19.0/lisp/RCS/rmailsort.el,v 1.21 1994/04/07 03:29:02 kwzh Exp kwzh $ +;; Maintainer: FSF ;; Keywords: mail ;; This file is part of GNU Emacs. @@ -19,17 +19,24 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: ;;; Code: (require 'sort) +;; For rmail-select-summary +(require 'rmail) + (autoload 'timezone-make-date-sortable "timezone") ;; Sorting messages in Rmail buffer +;;;###autoload (defun rmail-sort-by-date (reverse) "Sort messages of current Rmail file by date. If prefix argument REVERSE is non-nil, sort them in reverse order." @@ -40,6 +47,7 @@ If prefix argument REVERSE is non-nil, sort them in reverse order." (rmail-make-date-sortable (rmail-fetch-field msg "Date")))))) +;;;###autoload (defun rmail-sort-by-subject (reverse) "Sort messages of current Rmail file by subject. If prefix argument REVERSE is non-nil, sort them in reverse order." @@ -54,6 +62,7 @@ If prefix argument REVERSE is non-nil, sort them in reverse order." (substring key (match-end 0)) key)))))) +;;;###autoload (defun rmail-sort-by-author (reverse) "Sort messages of current Rmail file by author. If prefix argument REVERSE is non-nil, sort them in reverse order." @@ -66,6 +75,7 @@ If prefix argument REVERSE is non-nil, sort them in reverse order." (or (rmail-fetch-field msg "From") (rmail-fetch-field msg "Sender") ""))))))) +;;;###autoload (defun rmail-sort-by-recipient (reverse) "Sort messages of current Rmail file by recipient. If prefix argument REVERSE is non-nil, sort them in reverse order." @@ -79,6 +89,7 @@ If prefix argument REVERSE is non-nil, sort them in reverse order." (rmail-fetch-field msg "Apparently-To") "") )))))) +;;;###autoload (defun rmail-sort-by-correspondent (reverse) "Sort messages of current Rmail file by other correspondent. If prefix argument REVERSE is non-nil, sort them in reverse order." @@ -100,6 +111,7 @@ If prefix argument REVERSE is non-nil, sort them in reverse order." (setq fields (cdr fields))) ans)) +;;;###autoload (defun rmail-sort-by-lines (reverse) "Sort messages of current Rmail file by number of lines. If prefix argument REVERSE is non-nil, sort them in reverse order." @@ -110,7 +122,8 @@ If prefix argument REVERSE is non-nil, sort them in reverse order." (count-lines (rmail-msgbeg msg) (rmail-msgend msg)))))) -(defun rmail-sort-by-keywords (reverse labels) +;;;###autoload +(defun rmail-sort-by-labels (reverse labels) "Sort messages of current Rmail file by labels. If prefix argument REVERSE is non-nil, sort them in reverse order. KEYWORDS is a comma-separated list of labels." @@ -120,7 +133,7 @@ KEYWORDS is a comma-separated list of labels." (setq labels (concat (substring labels (match-beginning 0)) ",")) (let (labelvec) (while (string-match "[ \t]*,[ \t]*" labels) - (setq labelvec (cons + (setq labelvec (cons (concat ", ?\\(" (substring labels 0 (match-beginning 0)) "\\),") @@ -143,11 +156,12 @@ KEYWORDS is a comma-separated list of labels." "Sort messages of current Rmail file. If 1st argument REVERSE is non-nil, sort them in reverse order. 2nd argument KEYFUN is called with a message number, and should return a key." - (save-excursion + (save-current-buffer ;; If we are in a summary buffer, operate on the Rmail buffer. (if (eq major-mode 'rmail-summary-mode) (set-buffer rmail-buffer)) (let ((buffer-read-only nil) + (point-offset (- (point) (point-min))) (predicate nil) ;< or string-lessp (sort-lists nil)) (message "Finding sort keys...") @@ -206,6 +220,7 @@ If 1st argument REVERSE is non-nil, sort them in reverse order. (buffer-enable-undo) (rmail-set-message-counters) (rmail-show-message current-message) + (goto-char (+ point-offset (point-min))) (if (rmail-summary-exists) (rmail-select-summary (rmail-update-summary))))))) @@ -231,4 +246,5 @@ Arguments are MSG and FIELD." (provide 'rmailsort) +;;; arch-tag: 0d90896b-0c35-46ac-b240-38be5ada2360 ;;; rmailsort.el ends here