annotate lisp/mail/rmailsum.el @ 573:f0ffd1764382

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