diff options
| author | Karl Heuer | 1994-04-07 03:29:02 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-04-07 03:29:02 +0000 |
| commit | 15589977175b42f14f039cd088e2cf40bcd015b7 (patch) | |
| tree | f23e6bbd066e3d044e47ad20e867d699574119fd | |
| parent | ebdf372b3b04440406cdd4b3fbc9a6c093b1a8b1 (diff) | |
| download | emacs-15589977175b42f14f039cd088e2cf40bcd015b7.tar.gz emacs-15589977175b42f14f039cd088e2cf40bcd015b7.zip | |
(rmail-sort-by-keywords): New function.
| -rw-r--r-- | lisp/mail/rmailsort.el | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lisp/mail/rmailsort.el b/lisp/mail/rmailsort.el index 4099c47590d..ba11d77c8f6 100644 --- a/lisp/mail/rmailsort.el +++ b/lisp/mail/rmailsort.el | |||
| @@ -3,7 +3,7 @@ | |||
| 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: /gd/gnu/emacs/19.0/lisp/RCS/rmailsort.el,v 1.19 1994/03/30 02:21:48 kwzh Exp kwzh $ | 6 | ;; Version: $Header: /gd/gnu/emacs/19.0/lisp/RCS/rmailsort.el,v 1.20 1994/03/30 02:24:05 kwzh Exp kwzh $ |
| 7 | ;; Keywords: mail | 7 | ;; Keywords: mail |
| 8 | 8 | ||
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| @@ -109,6 +109,33 @@ If prefix argument REVERSE is non-nil, sort them in reverse order." | |||
| 109 | (lambda (msg) | 109 | (lambda (msg) |
| 110 | (count-lines (rmail-msgbeg msg) | 110 | (count-lines (rmail-msgbeg msg) |
| 111 | (rmail-msgend msg)))))) | 111 | (rmail-msgend msg)))))) |
| 112 | |||
| 113 | (defun rmail-sort-by-keywords (reverse labels) | ||
| 114 | "Sort messages of current Rmail file by labels. | ||
| 115 | If prefix argument REVERSE is non-nil, sort them in reverse order. | ||
| 116 | KEYWORDS is a comma-separated list of labels." | ||
| 117 | (interactive "P\nsSort by labels: ") | ||
| 118 | (or (string-match "[^ \t]" labels) | ||
| 119 | (error "No labels specified")) | ||
| 120 | (setq labels (concat (substring labels (match-beginning 0)) ",")) | ||
| 121 | (let (labelvec) | ||
| 122 | (while (string-match "[ \t]*,[ \t]*" labels) | ||
| 123 | (setq labelvec (cons | ||
| 124 | (concat ", ?\\(" | ||
| 125 | (substring labels 0 (match-beginning 0)) | ||
| 126 | "\\),") | ||
| 127 | labelvec)) | ||
| 128 | (setq labels (substring labels (match-end 0)))) | ||
| 129 | (setq labelvec (apply 'vector (nreverse labelvec))) | ||
| 130 | (rmail-sort-messages reverse | ||
| 131 | (function | ||
| 132 | (lambda (msg) | ||
| 133 | (let ((n 0)) | ||
| 134 | (while (and (< n (length labelvec)) | ||
| 135 | (not (rmail-message-labels-p | ||
| 136 | msg (aref labelvec n)))) | ||
| 137 | (setq n (1+ n))) | ||
| 138 | n)))))) | ||
| 112 | 139 | ||
| 113 | ;; Basic functions | 140 | ;; Basic functions |
| 114 | 141 | ||