annotate lisp/mail/rmailsum.el @ 1955:8ac912d2d369

(point-to-register): Make arg ARG optional. (window-configuration-to-register): Likewise. (frame-configuration-to-register): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Thu, 25 Feb 1993 06:39:57 +0000
parents 213978acbc1e
children 6885836c2f98
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 130
diff changeset
1 ;;; rmailsum.el --- "RMAIL" mail reader for Emacs.
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 130
diff changeset
2
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
5 ;; Maintainer: FSF
814
38b2499cb3e9 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
6 ;; Keywords: mail
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
7
130
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
130
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; any later version.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
24 ;;; Code:
130
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 ;; summary things
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 (defun rmail-summary ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 "Display a summary of all messages, one line per message."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 (rmail-new-summary "All" nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 (defun rmail-summary-by-labels (labels)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 "Display a summary of all messages with one or more LABELS.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 LABELS should be a string containing the desired labels, separated by commas."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 (interactive "sLabels to summarize by: ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 (if (string= labels "")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 (setq labels (or rmail-last-multi-labels
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 (error "No label specified"))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 (setq rmail-last-multi-labels labels)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 (rmail-new-summary (concat "labels " labels)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 'rmail-message-labels-p
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 (concat ", \\(" (mail-comma-list-regexp labels) "\\),")))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 (defun rmail-summary-by-recipients (recipients &optional primary-only)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 "Display a summary of all messages with the given RECIPIENTS.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 Normally checks the To, From and Cc fields of headers;
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 but if PRIMARY-ONLY is non-nil (prefix arg given),
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 only look in the To and From fields.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 RECIPIENTS is a string of names separated by commas."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 (interactive "sRecipients to summarize by: \nP")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 (rmail-new-summary
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 (concat "recipients " recipients)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 'rmail-message-recipients-p
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (mail-comma-list-regexp recipients) primary-only))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (defun rmail-message-recipients-p (msg recipients &optional primary-only)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 (save-restriction
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (goto-char (rmail-msgbeg msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (search-forward "\n*** EOOH ***\n")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (narrow-to-region (point) (progn (search-forward "\n\n") (point)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 (or (string-match recipients (or (mail-fetch-field "To") ""))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 (string-match recipients (or (mail-fetch-field "From") ""))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 (if (not primary-only)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 (string-match recipients (or (mail-fetch-field "Cc") ""))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 (defun rmail-summary-by-regexp (regexp)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 "Display a summary of all messages according to regexp REGEXP.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 If the regular expression is found in the header of the message
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 \(including in the date and other lines, as well as the subject line),
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 Emacs will list the header line in the RMAIL-summary."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 (interactive "sRegexp to summarize by: ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 (if (string= regexp "")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 (setq regexp (or rmail-last-regexp
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 (error "No regexp specified"))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 (setq rmail-last-regexp regexp)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 (rmail-new-summary (concat "regexp " regexp)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 'rmail-message-regexp-p
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 regexp))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 (defun rmail-message-regexp-p (msg regexp)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 "Return t, if for message number MSG, regexp REGEXP matches in the header."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 (goto-char (rmail-msgbeg msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 (let ((end
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 (save-excursion
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 (search-forward "*** EOOH ***" (point-max)) (point))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 (re-search-forward regexp end t)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 (defun rmail-new-summary (description function &rest args)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 "Create a summary of selected messages.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 DESCRIPTION makes part of the mode line of the summary buffer.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 For each message, FUNCTION is applied to the message number and ARGS...
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 and if the result is non-nil, that message is included.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 nil for FUNCTION means all messages."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 (message "Computing summary lines...")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 (or (and rmail-summary-buffer
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 (buffer-name rmail-summary-buffer))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 (setq rmail-summary-buffer
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 (generate-new-buffer (concat (buffer-name) "-summary"))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (let ((summary-msgs ())
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 (new-summary-line-count 0))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 (let ((msgnum 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 (buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 (save-restriction
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 (save-excursion
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 (widen)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (goto-char (point-min))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 (while (>= rmail-total-messages msgnum)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 (if (or (null function)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (apply function (cons msgnum args)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (setq summary-msgs
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 (cons (rmail-make-summary-line msgnum)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 summary-msgs)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 (setq msgnum (1+ msgnum))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 (let ((sbuf rmail-summary-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 (rbuf (current-buffer))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 (total rmail-total-messages)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 (mesg rmail-current-message))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 (pop-to-buffer sbuf)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 ;; Our scroll command should always scroll the Rmail buffer.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 (make-local-variable 'other-window-scroll-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 (setq other-window-scroll-buffer rbuf)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 (let ((buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 (erase-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (cond (summary-msgs
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (princ (nreverse summary-msgs) sbuf)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 (delete-char -1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 (subst-char-in-region 1 2 ?\( ?\ ))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 (setq buffer-read-only t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 (goto-char (point-min))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 (rmail-summary-mode)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 (make-local-variable 'minor-mode-alist)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (setq minor-mode-alist (list ": " description))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 (setq rmail-buffer rbuf
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 rmail-total-messages total)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (rmail-summary-goto-msg mesg t)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 (message "Computing summary lines...done"))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 (defun rmail-make-summary-line (msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (let ((line (or (aref rmail-summary-vector (1- msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 (setq new-summary-line-count
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 (1+ new-summary-line-count))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (if (zerop (% new-summary-line-count 10))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 (message "Computing summary lines...%d"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 new-summary-line-count))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (rmail-make-summary-line-1 msg)))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 ;; Fix up the part of the summary that says "deleted" or "unseen".
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 (aset line 4
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 (if (rmail-message-deleted-p msg) ?\D
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (if (= ?0 (char-after (+ 3 (rmail-msgbeg msg))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 ?\- ?\ )))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 line))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 (defun rmail-make-summary-line-1 (msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (goto-char (rmail-msgbeg msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (let* ((lim (save-excursion (forward-line 2) (point)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 pos
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 (labels
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 (forward-char 3)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 (concat
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 ; (if (save-excursion (re-search-forward ",answered," lim t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 ; "*" "")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 ; (if (save-excursion (re-search-forward ",filed," lim t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 ; "!" "")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 (if (progn (search-forward ",,") (eolp))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 ""
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 (concat "{"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 (buffer-substring (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 (progn (end-of-line) (point)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 "} ")))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 (line
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 (forward-line 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 (if (looking-at "Summary-line: ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 (goto-char (match-end 0))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 (setq line
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 (buffer-substring (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 (progn (forward-line 1) (point)))))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 ;; Obsolete status lines lacking a # should be flushed.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 (and line
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 (not (string-match "#" line))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 (delete-region (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 (progn (forward-line -1) (point)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 (setq line nil)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 ;; If we didn't get a valid status line from the message,
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 ;; make a new one and put it in the message.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (or line
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (let* ((case-fold-search t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 (next (rmail-msgend msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 (beg (if (progn (goto-char (rmail-msgbeg msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 (search-forward "\n*** EOOH ***\n" next t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 (forward-line 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 (point)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 (end (progn (search-forward "\n\n" nil t) (point))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (save-restriction
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 (narrow-to-region beg end)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 (goto-char beg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 (setq line (rmail-make-basic-summary-line)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 (goto-char (rmail-msgbeg msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 (forward-line 2)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 (insert "Summary-line: " line)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 (setq pos (string-match "#" line))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 (aset rmail-summary-vector (1- msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 (concat (format "%4d " msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 (substring line 0 pos)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 labels
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (substring line (1+ pos))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 (defun rmail-make-basic-summary-line ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 (goto-char (point-min))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (concat (save-excursion
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (if (not (re-search-forward "^Date:" nil t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 " "
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 (cond ((re-search-forward "\\([^0-9:]\\)\\([0-3]?[0-9]\\)\\([- \t_]+\\)\\([adfjmnos][aceopu][bcglnprtvy]\\)"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (save-excursion (end-of-line) (point)) t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (format "%2d-%3s"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 (string-to-int (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (match-beginning 2)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (match-end 2)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (match-beginning 4) (match-end 4))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 ((re-search-forward "\\([^a-z]\\)\\([adfjmnos][acepou][bcglnprtvy]\\)\\([-a-z \t_]*\\)\\([0-9][0-9]?\\)"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (save-excursion (end-of-line) (point)) t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 (format "%2d-%3s"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 (string-to-int (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (match-beginning 4)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 (match-end 4)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 (match-beginning 2) (match-end 2))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (t "??????"))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 " "
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 (save-excursion
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 (if (not (re-search-forward "^From:[ \t]*" nil t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 " "
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (let* ((from (mail-strip-quoted-names
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 (1- (point))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (progn (end-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 (skip-chars-backward " \t")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 (point)))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 len mch lo)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 (if (string-match (concat "^"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (regexp-quote (user-login-name))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 "\\($\\|@\\)")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 from)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (save-excursion
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (goto-char (point-min))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (if (not (re-search-forward "^To:[ \t]*" nil t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 nil
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (setq from
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (concat "to: "
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 (mail-strip-quoted-names
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 (progn (end-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (skip-chars-backward " \t")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 (point)))))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 (setq len (length from))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 (setq mch (string-match "[@%]" from))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 (format "%25s"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 (if (or (not mch) (<= len 25))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (substring from (max 0 (- len 25)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (substring from
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (setq lo (cond ((< (- mch 9) 0) 0)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 ((< len (+ mch 16))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 (- len 25))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 (t (- mch 9))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (min len (+ lo 25))))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 " #"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (if (re-search-forward "^Subject:" nil t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (progn (skip-chars-forward " \t")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (buffer-substring (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (progn (end-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (point))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 (re-search-forward "[\n][\n]+" nil t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 (buffer-substring (point) (progn (end-of-line) (point))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 "\n"))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 (defun rmail-summary-next-all (&optional number)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (interactive "p")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (forward-line (if number number 1))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 (rmail-summary-goto-msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 (defun rmail-summary-previous-all (&optional number)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 (interactive "p")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (forward-line (- (if number number 1)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (rmail-summary-goto-msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 (defun rmail-summary-next-msg (&optional number)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (interactive "p")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 (forward-line 0)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 (and (> number 0) (forward-line 1))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 (let ((count (if (< number 0) (- number) number))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 (search (if (> number 0) 're-search-forward 're-search-backward))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 end)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 (while (and (> count 0) (funcall search "^.....[^D]" nil t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 (setq count (1- count)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 (rmail-summary-goto-msg)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 (defun rmail-summary-previous-msg (&optional number)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 (interactive "p")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 (rmail-summary-next-msg (- (if number number 1))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 (defun rmail-summary-delete-forward ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 (let (end)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 (rmail-summary-goto-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (pop-to-buffer rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 (rmail-delete-message)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 (pop-to-buffer rmail-summary-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 (let ((buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 (skip-chars-forward " ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 (skip-chars-forward "[0-9]")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 (delete-char 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 (insert "D"))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 (rmail-summary-next-msg 1)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 (defun rmail-summary-delete-backward ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 (let (end)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 (rmail-summary-goto-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (pop-to-buffer rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 (rmail-delete-message)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (pop-to-buffer rmail-summary-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 (let ((buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 (skip-chars-forward " ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 (skip-chars-forward "[0-9]")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 (delete-char 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 (insert "D"))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 (rmail-summary-next-msg -1)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (defun rmail-summary-undelete ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 (let ((buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 (end-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (cond ((re-search-backward "\\(^ *[0-9]*\\)\\(D\\)" nil t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 (replace-match "\\1 ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 (rmail-summary-goto-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 (pop-to-buffer rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 (and (rmail-message-deleted-p rmail-current-message)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 (rmail-undelete-previous-message))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 (pop-to-buffer rmail-summary-buffer))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 (t
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 (rmail-summary-goto-msg)))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 ;; Rmail Summary mode is suitable only for specially formatted data.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 (put 'rmail-summary-mode 'mode-class 'special)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 (defun rmail-summary-mode ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 "Major mode in effect in Rmail summary buffer.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 A subset of the Rmail mode commands are supported in this mode.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 As commands are issued in the summary buffer the corresponding
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 mail message is displayed in the rmail buffer.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 n Move to next undeleted message, or arg messages.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 p Move to previous undeleted message, or arg messages.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 M-n Move to next, or forward arg messages.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 M-p Move to previous, or previous arg messages.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 j Jump to the message at the cursor location.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 d Delete the message at the cursor location and move to next message.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 C-d Delete the message at the cursor location and move to previous message.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 u Undelete this or previous deleted message.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 q Quit Rmail.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 x Exit and kill the summary window.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 space Scroll message in other window forward.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 delete Scroll message backward.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 Entering this mode calls value of hook variable rmail-summary-mode-hook."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (kill-all-local-variables)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (make-local-variable 'rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 (make-local-variable 'rmail-total-messages)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 (setq major-mode 'rmail-summary-mode)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 (setq mode-name "RMAIL Summary")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 (use-local-map rmail-summary-mode-map)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 (setq truncate-lines t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 (setq buffer-read-only t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 (set-syntax-table text-mode-syntax-table)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 (run-hooks 'rmail-summary-mode-hook))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 (defun rmail-summary-goto-msg (&optional n nowarn)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 (interactive "P")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 (if (consp n) (setq n (prefix-numeric-value n)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 (if (eobp) (forward-line -1))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 (beginning-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 (let ((buf rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 (cur (point))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 (curmsg (string-to-int
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 (buffer-substring (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 (min (point-max) (+ 5 (point)))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 (if (not n)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 (setq n curmsg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 (if (< n 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 (progn (message "No preceding message")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 (setq n 1)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (if (> n rmail-total-messages)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (progn (message "No following message")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 (goto-char (point-max))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 (rmail-summary-goto-msg)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 (goto-char (point-min))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 (if (not (re-search-forward (concat "^ *" (int-to-string n)) nil t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 (progn (or nowarn (message "Message %d not found" n))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 (setq n curmsg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 (goto-char cur))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 (beginning-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 (skip-chars-forward " ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (skip-chars-forward "0-9")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (save-excursion (if (= (following-char) ?-)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (let ((buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 (delete-char 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (insert " "))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 (beginning-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 (pop-to-buffer buf)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (rmail-show-message n)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 (pop-to-buffer rmail-summary-buffer)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 (defvar rmail-summary-mode-map nil)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 (if rmail-summary-mode-map
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 nil
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 (setq rmail-summary-mode-map (make-keymap))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (suppress-keymap rmail-summary-mode-map)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 (define-key rmail-summary-mode-map "j" 'rmail-summary-goto-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (define-key rmail-summary-mode-map "n" 'rmail-summary-next-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (define-key rmail-summary-mode-map "p" 'rmail-summary-previous-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (define-key rmail-summary-mode-map "\en" 'rmail-summary-next-all)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (define-key rmail-summary-mode-map "\ep" 'rmail-summary-previous-all)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (define-key rmail-summary-mode-map " " 'rmail-summary-scroll-msg-up)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 (define-key rmail-summary-mode-map "q" 'rmail-summary-quit)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 (define-key rmail-summary-mode-map "u" 'rmail-summary-undelete)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 (define-key rmail-summary-mode-map "x" 'rmail-summary-exit)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (define-key rmail-summary-mode-map "\177" 'rmail-summary-scroll-msg-down)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 (define-key rmail-summary-mode-map "d" 'rmail-summary-delete-forward)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (define-key rmail-summary-mode-map "\C-d" 'rmail-summary-delete-backward))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 (defun rmail-summary-scroll-msg-up (&optional dist)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 "Scroll other window forward."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 (interactive "P")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 (let ((window (selected-window))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (new-window (display-buffer rmail-buffer)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 (unwind-protect
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 (select-window new-window)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 (scroll-up dist))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 (select-window window))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 (defun rmail-summary-scroll-msg-down (&optional dist)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 "Scroll other window backward."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 (interactive "P")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (let ((window (selected-window))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 (new-window (display-buffer rmail-buffer)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 (unwind-protect
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (select-window new-window)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 (scroll-down dist))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 (select-window window))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 (defun rmail-summary-quit ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 "Quit out of rmail and rmail summary."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 (rmail-summary-exit)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 (rmail-quit))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (defun rmail-summary-exit ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 "Exit rmail summary, remaining within rmail."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 (bury-buffer (current-buffer))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 (if (get-buffer-window rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 ;; Select the window with rmail in it, then delete this window.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (select-window (prog1
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 (get-buffer-window rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 (delete-window (selected-window))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 ;; Switch to the rmail buffer in this window.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 (switch-to-buffer rmail-buffer)))
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 130
diff changeset
480
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 130
diff changeset
481 ;;; rmailsum.el ends here