]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/rmailsort.el
(rmail-convert-to-babyl-format): Display a message while converting to Babyl.
[gnu-emacs] / lisp / mail / rmailsort.el
index 53974220c200f56e2fc63a01d896bdf0a739f0a3..3194358451cab8ea49933b53cccd8023ea125785 100644 (file)
@@ -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 <umerin@mse.kyutech.ac.jp>
-;; Version: $Header: /home/gd/gnu/emacs/19.0/lisp/RCS/rmailsort.el,v 1.23 1996/01/14 14:30:11 kwzh Exp kwzh $
+;; Maintainer: FSF
 ;; Keywords: mail
 
 ;; This file is part of GNU Emacs.
@@ -23,6 +23,8 @@
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
+;;; Commentary:
+
 ;;; Code:
 
 (require 'sort)
@@ -34,6 +36,7 @@
 
 ;; 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."
@@ -44,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."
@@ -58,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."
@@ -70,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."
@@ -83,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."
@@ -104,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."
@@ -114,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."
@@ -124,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))
                              "\\),")
@@ -147,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...")
@@ -210,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)))))))
@@ -235,4 +246,5 @@ Arguments are MSG and FIELD."
 
 (provide 'rmailsort)
 
+;;; arch-tag: 0d90896b-0c35-46ac-b240-38be5ada2360
 ;;; rmailsort.el ends here